Stock Portfolio Organizer
The ultimate porfolio management solution.
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
VierBox.afl for Amibroker for Amibroker (AFL)
Copy & Paste Friendly
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | /* VierBox ver 0.1. Messy programming, rough plotting, barely usable :D ver 0.2. * Parameter VierBox per saham bisa di save. Tidak perlu lagi memakai Draw Rectangle. Big time saver :D * Plot yang lebih halus * fitur untuk menampilkan/menyembunyikan VierBox * fitur untuk menampilkan/menyembunyikan garis vertikal * fitur untuk menampilkan dan merubah warna VierBox (masih sangat sederhana) * fitur untuk merubah warna garis * Bagian Title akan memberikan informasi jika ada parameter yang berubah sejak disave dan memberi rekomendasi apa yang hrs dilakukan. ver 0.3. * Warna box sesuai rules pak Vier. Maap pak Vier, baru kelar sekarang . Ternyata susah juga buatnya :D * text di box untuk menandakan box uptrend, downtrend, stackingBox, etc. * Warna Outline candlestick bisa dirubah di parameter ver 0.3.1 * text di box untuk ExplosiveBox Cara penggunaan: Dari Menu Parameters, Klik "RESET ALL" untuk menampilkan parameter yang telah disave atau Dari Menu Parameters, Klik "SAVE" untuk menyimpan parameter yang telah dirubah Catatan teknis: parameter setiap saham disimpan di directory C:\amibroker\vierbox\namasaham.txt Saran, usul dan komentar dipersilahkan. */ //bikin fungsi start warna box function startWarna( y1, y2, range ) { result = colorWhite ; if ( AlmostEqual ( y1, y2 + range* 1 / 2 ) ) result = colorRose ; //downTrend if ( AlmostEqual ( y1, y2 + range*3 / 2 ) ) result = colorPink ; //reversal if ( AlmostEqual ( y1, y2 + range*5 / 2 ) ) result = colorRed ; //Crash if ( AlmostEqual ( y1, y2 + range*7 / 2 ) ) result = colorDarkRed ; //Crash2 if ( AlmostEqual ( y1, y2 + range*9 / 2 ) ) result = colorDarkRed ; //Crash3 if ( AlmostEqual ( y1, y2 - range* 1 / 2 ) ) result = colorAqua ; //upTrend if ( AlmostEqual ( y1, y2 - range* 3 / 2 ) ) result = colorTurquoise ; //stackingBox if ( AlmostEqual ( y1, y2 - range* 5 / 2 ) ) result = colorTeal ; //ExplosiveBox if ( AlmostEqual ( y1, y2 - range* 7 / 2 ) ) result = colorDarkGreen ; //ExplosiveBox2 if ( AlmostEqual ( y1, y2 - range* 9 / 2 ) ) result = colorDarkOliveGreen ; //ExplosiveBox3 return result; } //end function ColorWhite function textTrend( y1, y2, range ) { result = "?" ; if ( AlmostEqual ( y1, y2 + range* 1 / 2 ) ) result = "DownTrend" ; if ( AlmostEqual ( y1, y2 + range* 3 / 2 ) ) result = "Reversal" ; if ( AlmostEqual ( y1, y2 + range* 5 / 2 ) ) result = "Crash" ; if ( AlmostEqual ( y1, y2 + range* 7 / 2 ) ) result = "Crash2" ; if ( AlmostEqual ( y1, y2 + range* 9 / 2 ) ) result = "Crash3" ; if ( AlmostEqual ( y1, y2 - range* 1 / 2 ) ) result = "UpTrend" ; if ( AlmostEqual ( y1, y2 - range* 3 / 2 ) ) result = "StackingBox" ; if ( AlmostEqual ( y1, y2 - range* 5 / 2 ) ) result = "ExplosiveBox" ; if ( AlmostEqual ( y1, y2 - range* 7 / 2 ) ) result = "ExplosiveBox2" ; if ( AlmostEqual ( y1, y2 - range* 9 / 2 ) ) result = "ExplosiveBox3" ; return result; } //end function textTrend _SECTION_BEGIN ( "Save" ); save = ParamTrigger ( "Save Parameter VierBox?" , "KLIK DISINI UNTUK SAVE" ) ; _SECTION_END (); //end section "Save" _SECTION_BEGIN ( "Price" ); SetChartOptions ( 0, chartShowArrows | chartShowDates ); Plot ( C , "Close" , ParamColor ( "Warna Outline Candlestick" , colorBlack ), styleNoTitle | GetPriceStyle () ); _SECTION_END (); //end section "Price" _SECTION_BEGIN ( "Tampilkan VierBox" ); DisplayVierBox = ParamToggle ( "Tampilkan VierBox?" , "Tidak|Ya" , 1 ); _SECTION_END (); //end section "Tampilkan VierBox" _SECTION_BEGIN ( "VierBox by DF" ); //tampilanVierBox=ParamToggle("VierBox yang Ditampilkan","Permanen|Setup",0); //jumlahBarDiBox = Param("Jumlah Bar di Box", 15, 5, 20); //Offset= Param("Start mundur berapa bar",75,1,200); //LineColor = ParamColor("Warna Garis Outline", colorGreen); //ColorStartBox = ParamColor("Warna Box Start",colorLightYellow); //ColorBox2 = ParamColor("Warna Box 2",colorAqua); //DisplayBoxColor=ParamToggle("Display Box Color","Yes|No",0); //displayBoxLine=ParamToggle("Tampilkan Garis Outline Box","Ya|Tidak",0); SetChartOptions ( 0, chartShowArrows | chartShowDates ); SetBarsRequired ( 100000, 100000 ); //use all bars //EnableTextOutput( False ); if ( displayVierBox == 1 ) //section vierbox by DF hanya akan ditampilkan kalau displayVierBox==1 { //Buka file input_file = Name () + ".txt" ; input_folder = "vierbox" ; fh = fopen ( input_folder + "\\" + input_file, "r" ); if ( fh ) { strFile = fgets ( fh ); fclose ( fh ); strStartBar = StrExtract ( strfile, 0 ); strJumlahBarDiBox = StrExtract ( strFile, 1 ); strdisplayBoxLine = StrExtract ( strFile, 2 ); strDisplayBoxColor = StrExtract ( strFile, 3 ); strlineColor = StrExtract ( strFile, 4 ); strColorStartBox = StrExtract ( strFile, 5 ); //strColorBox2 = StrExtract( strFile, 6 ); startBar = StrToNum ( strStartBar ); lastBar = LastValue ( BarIndex () ); //value jumlah total bar . Base 0 Offset = Lastbar - startBar; //box mulai di sini. Nilai offset keluar cuma sekali di sini! Offset = Param ( "Start Mundur Berapa Bar?" , Offset, 1, 200 ); startBar = LastBar - Offset; jumlahBarDiBox = StrToNum ( strJumlahBarDiBox ); jumlahBarDiBox = Param ( "Jumlah Bar di Box" , StrToNum ( strJumlahBarDiBox ), 5, 20 ); displayBoxLine = ParamToggle ( "Tampilkan Garis Outline Box" , "Tidak|Ya" , StrToNum ( strdisplayBoxLine ) ); lineColor = ParamColor ( "Warna Garis Outline Box" , StrToNum ( strLineColor ) ); DisplayBoxColor = ParamToggle ( "Tampilkan Warna Box" , "Tidak|Ya" , StrToNum ( strDisplayBoxColor ) ); ColorStartBox = ParamColor ( "Warna Start Box" , StrToNum ( strColorStartBox ) ); //ColorBox2 = ParamColor( "Warna Box 2", StrToNum( strColorBox2 ) ); } else //jika file yang mau dibuka gak ada, bikin jadi default dan save { printf ( "error open file" ); Offset = Param ( "Start Mundur Berapa Bar?" , 75, 1, 200 ); lastBar = LastValue ( BarIndex () ); startBar = Lastbar - Offset; jumlahBarDiBox = Param ( "Jumlah Bar di Box" , 15, 5, 20 ); displayBoxLine = ParamToggle ( "Tampilkan Garis Outline Box" , "Tidak|Ya" , 0 ); LineColor = ParamColor ( "Warna Garis Outline" , colorGreen ); DisplayBoxColor = ParamToggle ( "Display Box Color" , "Tidak|Ya" , 1 ); ColorStartBox = ParamColor ( "Warna Start Box" , colorLightYellow ); //ColorBox2 = ParamColor( "Warna Box 2", colorAqua ); //save Output_file = Name () + ".txt" ; Output_folder = "vierbox" ; fmkdir ( Output_folder ); fh = fopen ( Output_folder + "\\" + Output_file, "w" ); fputs ( NumToStr ( startBar, 1.0, False ) + "," + NumToStr ( jumlahBarDiBox, 1.0, False ) + "," + NumToStr ( displayBoxLine, 1.0, False ) + "," + NumToStr ( displayBoxColor, 1.0, False ) + "," + NumToStr ( Linecolor, 1.0, False ) + "," + NumToStr ( ColorStartBox, 1.0, False ) + "," , fh ); fclose ( fh ); fclose ( fh ); } ; //end if fh lastBar = LastValue ( BarIndex () ); //value jumlah total bar lArray = LLV ( Low , jumlahBardiBox ); //cari Low terendah di box awal hArray = HHV ( High , jumlahBardiBox ); //cari High tertinggi di box awal VierL = Larray[startBar-1]; //convert lArray jadi value VierH = Harray[startBar-1]; //convert hArray jadi value range = VierH - VierL; //hitung tinggi box awal //cari baseline box, sedekat mungkin dengan harga 0 //berguna agar box-box di depan selalu berada dekat bar-bar harga baselineBoxGenap = VierL - int ( VierL / range ) * range; baselineBoxGanjil = VierL - int ( VierL / range ) * range - range / 2; //start Buat box awal x0 = -jumlahBarDiBox + startBar; x1 = startBar ; garisBawah = LineArray ( x0, VierL, x1 - 1, VierL, 0 ); garisAtas = LineArray ( x0, VierH, x1 - 1, VierH, 0 ); if ( displayBoxLine == 1 ) { garisKiriBawah = LineArray ( x0 - 1, VierL + range / 2, x0, VierL , 0 ); garisKiriAtas = LineArray ( x0 - 1, VierL + range / 2, x0, VierL + range, 0 ); garisKananBawah = LineArray ( x1 - 1, VierL , x1, VierL + range / 2, 0 ); garisKananAtas = LineArray ( x1 - 1, VierL + range, x1, VierL + range / 2, 0 ); Plot ( garisBawah, "" , LineColor, styleNoLabel ); Plot ( garisatas, "" , LineColor ); Plot ( garisKiriBawah, "" , LineColor, styleNoLabel ); Plot ( garisKiriAtas, "" , LineColor, styleNoLabel ); Plot ( garisKananBawah, "" , LineColor, styleNoLabel ); Plot ( garisKananAtas, "" , LineColor, styleNoLabel ); } //selesai buat box awal //hitung harus buat berapa box ke depan(horisontal dan vertikal) jumlahBoxH = int ( ( LastBar - startBar ) / jumlahBarDiBox ) + 1; //jumlah box ke depan yang akan dibuat /*unused. replaced with new code. //Plot Vertical Line if ( displayBoxLine == 1 ) { for ( k = 0;k < jumlahBoxH + 1;k++ ) { x0 = -jumlahBarDiBox + startBar + k * jumlahBarDiBox; Plot( BarIndex() == x0, "", LineColor, styleOwnScale + styleHistogram + styleNoLabel ); } //end for } */ if ( displayBoxColor == 1 ) { PlotOHLC ( Null , garisAtas, garisBawah, Null , "" , ColorStartBox, styleCloud + styleNoLabel ); PlotText ( "Start" , startBar - jumlahBarDiBox*2 / 3, VierL + Range / 2 , colorBlack , colorYellow ); } //end if displayBoxColor baselineBox[0] = VierL; //akan dipakai untuk nilai y1 di box horisontal ke 1 //buat baselineBox[boxNo] dari box horisontal pertama sampai terakhir for ( boxNo = 1;boxNo <= jumlahBoxH;boxNo++ ) { testGanjil = frac ( boxNo / 2 ) != 0; //genap jika nilainya 0 if ( testGanjil == 0 ) { baselineBox[boxNo] = BaselineBoxGenap; } else { baselineBox[boxNo] = BaselineBoxGanjil; } //end testGanjil } //end for buat baselineBox[boxNo] for ( boxNo = 1;boxNo < jumlahBoxH;boxNo++ ) //mulai buat box didepan sebanyak jumlahBoxH { boxL = lArray[startBar-1 + boxNo*jumlahBarDiBox]; //nilai minimum harga di box no k boxH = hArray[startBar-1 + boxNo*jumlahBarDiBox]; //nilai maksimum harga di box no k //hitung jumlahBoxV for ( i = 0;baselineBox[boxNo] + i*Range <= boxH;i++ ) { jumlahBoxV = i + 1; } ClosingPriceBoxSebelumnya = C [startBar-1 + ( boxNo-1 )*jumlahBarDiBox]; //harga penutupan di ujung kanan box sebelumnya. //Cari garis bawah terdekat dengan ClosingPriceBoxSebelumnya for ( i = 0;( baselineBox[boxNo-1] + i*range ) <= ClosingPriceBoxSebelumnya ;i++ ) { y1 = baselineBox[BoxNo-1] + i * range; } //hitung garis bawah terdekat dengan boxL for ( i = 0;( baselineBox[boxNo] + i*range ) <= boxL;i++ ) { y2 = baselineBox[boxNo] + i * range; } //printf( "\nClosingPriceBoxSebelumnya=" + ClosingPriceBoxSebelumnya ); //printf( "\ny1=" + y1 ); //printf( "\ny2=" + y2 ); //buat Plot di box-box di depan for ( j = 1;j <= jumlahBoxV;j++ ) { if ( ( baselineBox[boxNo] + j*range ) > boxL ) //buat plot hanya kalau dekat dengan bar { x0 = -jumlahBarDiBox + startBar + boxNo * jumlahBarDiBox; x1 = startBar + boxNo * jumlahBarDiBox; y = baselineBox[boxNo] + ( j - 1 ) * range; garisBawah = LineArray ( x0, y, x1 - 1 , y, 0 ); garisAtas = LineArray ( x0, y + range, x1 - 1 , y + range, 0 ); if ( displayBoxLine == 1 ) { garisKiriBawah = LineArray ( x0 - 1, y + range / 2, x0, y, 0 ); garisKiriAtas = LineArray ( x0 - 1, y + range / 2, x0, y + range, 0 ); garisKananBawah = LineArray ( x1 - 1, y , x1, y + range / 2, 0 ); garisKananAtas = LineArray ( x1 - 1, y + range, x1, y + range / 2, 0 ); Plot ( garisBawah, "" , LineColor, styleNoLabel ); Plot ( garisatas, "" , LineColor ); Plot ( garisKiriBawah, "" , LineColor, styleNoLabel ); Plot ( garisKiriAtas, "" , LineColor, styleNoLabel ); Plot ( garisKananBawah, "" , LineColor, styleNoLabel ); Plot ( garisKananAtas, "" , LineColor, styleNoLabel ); } //end if displayBoxLine if ( displayBoxColor == 1 ) { ColorBoxBawah = startWarna( y1, y2, range ); PlotOHLC ( Null , garisAtas, garisBawah, Null , "" , ColorBoxBawah, styleCloud ); PlotText ( textTrend( y1, y2, range ), x0 + jumlahBarDiBox / 3, y + Range / 2, colorBlack , colorYellow ); y2 = y2 + range; //rubah warna untuk box diatas box sekarang } //end if displayBoxColor } //end if dekat dengan bar } //end for } //end for //sekarang plot khusus di box paling kanan. Like I said, messy :( boxNo = jumlahBoxH; //no box yang paling kanan //BoxL dan BoxH di box terakhir. Very-very messy. Try and error. boxL = LastValue ( LLV ( Low , ( 1 + Offset - jumlahBarDiBox * ( jumlahBoxH - 1 ) ) ) ); //nilai minimum harga di box terakhir boxH = LastValue ( HHV ( High , ( 1 + Offset - jumlahBarDiBox * ( jumlahBoxH - 1 ) ) ) ); //nilai maksimum harga di box terakhir //printf( "\nmundur berapa periode di bar terakhir=" + ( 1 + ( Offset - jumlahBarDiBox*( ( jumlahBoxH - 1 ) ) ) ) ); //printf( "\nboxL=" + boxL ); //printf( "\nboxH=" + boxH ); //hitung jumlahBoxV for ( i = 0;baselineBox[boxNo] + i*Range <= boxH;i++ ) { jumlahBoxV = i + 1; } ClosingPriceBoxSebelumnya = C [startBar-1 + ( boxNo-1 )*jumlahBarDiBox]; //harga penutupan di ujung kanan box sebelumnya. //Cari garis bawah terdekat dengan ClosingPriceBoxSebelumnya for ( i = 0;( baselineBox[boxNo-1] + i*range ) <= ClosingPriceBoxSebelumnya ;i++ ) { y1 = baselineBox[BoxNo-1] + i * range; } //hitung garis bawah terdekat dengan boxL for ( i = 0;( baselineBox[boxNo] + i*range ) <= boxL;i++ ) { y2 = baselineBox[boxNo] + i * range; } //printf( "\nClosingPriceBoxSebelumnya=" + ClosingPriceBoxSebelumnya ); //printf( "\ny1=" + y1 ); //printf( "\ny2=" + y2 ); //printf( "\nboxNo=" + boxNo ); //buat plot box paling kanan for ( j = 1;j <= jumlahBoxV;j++ ) { if ( ( baselineBox[boxNo] + j*range ) > boxL ) //buat plot hanya kalau dekat dengan bar { x0 = -jumlahBarDiBox + startBar + boxNo * jumlahBarDiBox; x1 = startBar + boxNo * jumlahBarDiBox; y = baselineBox[boxNo] + ( j - 1 ) * range; garisBawah = LineArray ( x0, y, x1 - 1, y, 0 ); garisAtas = LineArray ( x0, y + range, x1 - 1, y + range, 0 ); displace = jumlahBarDiBox - ( LastBar - x0 ) - 1; //printf( "\ndisplace=" + displace ); if ( displayBoxLine == 1 ) { garisKiriBawah = LineArray ( x0 - 1, y + range / 2, x0, y, 0 ); garisKiriAtas = LineArray ( x0 - 1, y + range / 2, x0, y + range, 0 ); garisKananBawah = LineArray ( x1 - 1 , y , x1, y + range / 2, 0 ); garisKananAtas = LineArray ( x1 - 1 , y + range, x1, y + range / 2, 0 ); Plot ( Ref ( garisbawah, displace ), "" , LineColor, styleLine + styleNoLabel , 0, 0, displace ); //garis bawah box Plot ( Ref ( garisAtas, displace ), "" , LineColor, styleLine , 0, 0, displace ); //garis atas box Plot ( garisKiriBawah, "" , LineColor, styleNoLabel ); Plot ( garisKiriAtas, "" , LineColor, styleNoLabel ); Plot ( garisKananBawah, "" , LineColor, styleNoLabel , 0, 0, displace ); Plot ( garisKananAtas, "" , LineColor, styleNoLabel , 0, 0, displace ); } if ( displayBoxColor == 1 ) { ColorBoxBawah = startWarna( y1, y2, range ); // PlotOHLC ( Null , Ref ( garisbawah, displace ), Ref ( garisAtas, displace ), Null , "" , ColorBoxBawah, styleCloud + styleNoLabel , 0, 0, displace ); PlotText ( textTrend( y1, y2, range ), x0 + jumlahBarDiBox / 3, y + Range / 2, colorBlack , colorYellow ); y2 = y2 + range; //rubah warna untuk box diatas box sekarang } } //end if } //end for stringTitleOri = StrFormat ( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal ( V , 1.0 ) + " {{VALUES}}" , O , H , L , C , SelectedValue ( ROC ( C , 1 ) ) ) ; stringVierBox = WriteIf ( jumlahBarDiBox != StrToNum ( strJumlahBarDiBox ) OR startBar != StrToNum ( strStartBar ) OR displayBoxLine != StrToNum ( strdisplayBoxLine ) OR displayBoxColor != StrToNum ( strDisplayBoxColor ) OR Linecolor != StrToNum ( strLineColor ) OR ColorStartBox != StrToNum ( strColorStartBox ), EncodeColor ( colorRed ) + "VierBox " + Name () + " belum disimpan." + "\nUntuk menyimpan VierBox ini, masuk ke menu Parameters dan klik SAVE." + "\nUntuk memanggil VierBox yang telah disimpan, masuk ke menu Parameters dan klik RESET ALL." , EncodeColor ( colorBlue ) + "VierBox " + Name () + " sudah disimpan" ); Title = stringVierBox + "\n\n" + EncodeColor ( colorBlack ) + stringTitleOri; if ( save == 1 ) { Output_file = Name () + ".txt" ; Output_folder = "vierbox" ; fmkdir ( Output_folder ); fh = fopen ( Output_folder + "\\" + Output_file, "w" ); fputs ( NumToStr ( startBar, 1.0, False ) + "," + NumToStr ( jumlahBarDiBox, 1.0, False ) + "," + NumToStr ( displayBoxLine, 1.0, False ) + "," + NumToStr ( displayBoxColor, 1.0, False ) + "," + NumToStr ( Linecolor, 1.0, False ) + "," + NumToStr ( ColorStartBox, 1.0, False ) + "," , fh ); fclose ( fh ); } //end if } //end if displayVierBox |