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 ....
zig code 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 | // Amibroker AFL code by Edward Pottasch, Nov 2012 // Alternative ZIG type function based on the ATR and VSTOP functions // Added multiple timeframes. Maximum timeframe set to 1440 minutes // Added Channel type indicator after idea by Carl Vanhaesendonck // Added pivot based trendlines + 2 convergence patterns x=xx= BarIndex (); dispZIG= ParamToggle ( "Display ZIG" , "Off|On" ,1); dispVSTOP= ParamToggle ( "Display VSTOP" , "Off|On" ,0); dispCHANNEL= ParamToggle ( "Display CHANNEL" , "Off|On" ,1); dispTRENDLINES= ParamToggle ( "Display TRENDLINES" , "Off|On" ,0); dispSR= ParamToggle ( "Display S/R levels" , "Off|On" ,1); npivTL= Param ( "N Pivots Used (TRENDLINES)" ,2,1,5,1); percSR= Param ( "Percentage Range (S/R LINES)" ,20,0.05,100,0.01); npivSR= Param ( "N Pivots Used (S/R LINES)" ,1,1,250,1); lastMiniPivot= ParamToggle ( "Mini Pivot (use with CHANNEL display)" , "Furthest|Last" ,0); disp0= ParamToggle ( "Display labels" , "Off|On" ,1); tf= Param ( "Time Frame (min)" ,60,1,1440,1);tfrm= in1Minute *tf; perBull= Param ( "perBull" ,20,1,150,1); perBear= Param ( "perBear" ,20,1,150,1); multBull= Param ( "multBull" ,2,0.05,4,0.05); multBear= Param ( "multBear" ,2,0.05,4,0.05); TimeFrameSet (tfrm); function vstop_func(trBull,trBear) { trailArray[0]= C [0]; for (i=1;i< BarCount ;i++) { prev=trailArray[i-1]; if ( C [i]>prev AND C [i-1]>prev) { trailArray[i]= Max (prev, C [i]-trBull[i]); } else if ( C [i]<prev AND C [i-1]< prev) { trailArray[i]= Min (prev, C [i]+trBear[i]); } else if ( C [i]>prev) { trailArray[i]= C [i]-trBull[i]; } else { trailArray[i]= C [i]+trBear[i]; } } return trailArray; } trBull=multBull* ATR (perBull); trBear=multBear* ATR (perBear); trailArray = vstop_func(trBull,trBear); ts= IIf (trailArray> C ,trailArray, Null ); tl= IIf (trailArray< C ,trailArray, Null ); el= Ref (ts,-1)- Ref (multBear* ATR (perBear),-1); es= Ref (tl,-1)+ Ref (multBull* ATR (perBull),-1); TimeFrameRestore (); ts= TimeFrameExpand (ts,tfrm,expandLast); tl= TimeFrameExpand (tl,tfrm,expandLast); el= TimeFrameExpand (el,tfrm,expandLast); es= TimeFrameExpand (es,tfrm,expandLast); GraphXSpace = 5; SetChartOptions (0, chartShowDates ); SetBarFillColor ( IIf ( C > O , colorBrightGreen , IIf ( C <= O , colorRed , colorLightGrey ))); Plot ( C , "Price" , IIf ( C > O , ColorRGB (0,255,0), IIf ( C <= O , ColorRGB (255,0,0), colorLightGrey )),64,0,0,0,0,1); lll= LLV ( L , BarsSince (! IsEmpty (tl)));lll= IIf (ts,lll, Null );llls=lll; ttt1= IIf ((! IsEmpty (ts) AND IsEmpty ( Ref (ts,1))) OR BarIndex ()== BarCount -1,1, Null ); ttt= ValueWhen (ttt1,lll,0);ttt= IIf (ts,ttt, Null );ttt= IIf (ttt1, Ref (ttt,-1),ttt); tr= L ==ttt;lll= Sum (tr, BarsSince (! IsEmpty (tl))); qqq= ValueWhen (ttt1,lll,0);qqq= IIf (ts,qqq, Null );qqq= IIf (ttt1, Ref (qqq,-1),qqq);tr=tr AND lll==qqq; tr= IIf ((! IsEmpty (ts) AND IsEmpty ( Ref (ts,1)) AND IsEmpty ( Ref (ts,-1))),1,tr); //exception hhh= HHV ( H , BarsSince (! IsEmpty (ts)));hhh= IIf (tl,hhh, Null );hhhs=hhh; ttt1= IIf ((! IsEmpty (tl) AND IsEmpty ( Ref (tl,1))) OR BarIndex ()== BarCount -1,1, Null ); ttt= ValueWhen (ttt1,hhh,0);ttt= IIf (tl,ttt, Null );ttt= IIf (ttt1, Ref (ttt,-1),ttt); pk= H ==ttt;hhh= Sum (pk, BarsSince (! IsEmpty (ts))); sss= ValueWhen (ttt1,hhh,0);sss= IIf (tl,sss, Null );sss= IIf (ttt1, Ref (sss,-1),sss);pk=pk AND hhh==sss; pk= IIf ((! IsEmpty (tl) AND IsEmpty ( Ref (tl,1)) AND IsEmpty ( Ref (tl,-1))),1,pk); //exception px0= ValueWhen (pk,x,0); tx0= ValueWhen (tr,x,0); px1= ValueWhen (pk,x,1); tx1= ValueWhen (tr,x,1); px2= ValueWhen (pk,x,2); tx2= ValueWhen (tr,x,2); ph0= ValueWhen (pk, H ,0); tl0= ValueWhen (tr, L ,0); ph1= ValueWhen (pk, H ,1); tl1= ValueWhen (tr, L ,1); ph2= ValueWhen (pk, H ,2); tl2= ValueWhen (tr, L ,2); minipk= H >= Ref ( HHV ( H ,1),-1) AND Ref ( HHV ( H ,1),1)< H ; minitr= L <= Ref ( LLV ( L ,1),-1) AND Ref ( LLV ( L ,1),1)> L ; ll=tr AND tl1<tl2; hl=tr AND tl1>tl2; hh=pk AND ph1>ph2; lh=pk AND ph1<ph2; dt=pk AND ph1==ph2; db=tr AND tl1==tl2; if (dispZIG) { aa1= IIf (px0>tx1,(ph0-tl1)/(px0-tx1),0);aa1= IIf (pk, Ref (aa1,-1),aa1);ls1=aa1*(xx-tx1)+tl1; bb1= IIf (px0>tx1 AND px1<tx1,1,0);bb1=bb1+ Ref (bb1,-1);bb1= IIf (bb1,1,0);ls1= IIf (bb1,ls1, Null ); Plot (ls1, "" , colorBlue , styleLine ,0,0,0,-1,3); aa1= IIf (tx0>px1,(tl0-ph1)/(tx0-px1),0);aa1= IIf (tr, Ref (aa1,-1),aa1);ls1=aa1*(xx-px1)+ph1; bb1= IIf (tx0>px1 AND tx1<px1,1,0);bb1=bb1+ Ref (bb1,-1);bb1= IIf (bb1,1,0);ls1= IIf (bb1,ls1, Null ); Plot (ls1, "" , colorOrange , styleLine ,0,0,0,-1); } if (dispVSTOP) { Plot (ts, "\ntrailShort" , colorRed , styleLine ,0,0,0,-1,1); //Plot(el,"",colorYellow,1,0,0,0,1,3); Plot ( Ref (llls,-1), "" , colorRed , styleDashed ,0,0,0,-1,1); Plot (tl, "\ntrailLong" , colorGreen , styleLine ,0,0,0,-1,1); //Plot(es,"",colorBlue,1,0,0,0,1,3); Plot ( Ref (hhhs,-1), "" , colorGreen , styleDashed ,0,0,0,-1,1); } if (dispCHANNEL) { aa1= IIf (px0>tx1,(ph0-tl1)/(px0-tx1),0);aa1= IIf (pk, Ref (aa1,-1),aa1);ls1=aa1*(xx-tx1)+tl1; bb1= IIf (px0>tx1 AND px1<tx1,1,0);bb1=bb1+ Ref (bb1,-1);bb1= IIf (bb1,1,0);ls1= IIf (bb1,ls1, Null ); sm= IIf (bb1, Sum (minitr, BarsSince (tr)),0);lv= ValueWhen (pk,sm,0);lv= Ref (lv,-1);sm= IIf (minitr,sm,0); lastMinitr=bb1 AND sm==lv AND sm!=0; sm= IIf (bb1, Sum ( IIf (minitr,ls1- L == HHV ( IIf (minitr,ls1- L ,0), BarsSince (tr)),0), BarsSince (tr)),0); lv= ValueWhen (pk,sm,0);lv= Ref (lv,-1);sm= IIf (minitr,sm,0); furthestMinitr=bb1 AND sm==lv AND sm!=0;furthestMinitr= ExRem (furthestMinitr,pk); if (lastMiniPivot) mp=lastMinitr; else mp=furthestMinitr; ltr= ValueWhen (mp, L ,0);ltr= ValueWhen (tr,ltr);vls1= ValueWhen (mp,ls1,0);vls1= ValueWhen (tr,vls1); dv=vls1-ltr;ls2=ls1-dv;ls2= IIf (ls2< ValueWhen (tr, L ), Null ,ls2);Ls2= IIf (Ls2<0, Null ,Ls2); ls2e= ValueWhen (pk,ls2)+ ValueWhen (pk,aa1)*(xx-px1);ls2e= IIf (ls2e> ValueWhen (pk, H ), Null ,ls2e); Plot (ls1, "" , colorBlue , styleThick ,0,0,0,-1,2); //PlotShapes(IIf(minitr AND bb1 AND BarsSince(tr)>1,shapeSmallCircle,shapeNone),ColorRGB(0,30,0),0,L,-10); PlotShapes ( IIf (mp, shapeHollowSmallCircle , shapeNone ), colorWhite ,0, L ,-10); Plot (ls2, "" , colorBlue , styleDashed ,0,0,0,-1,1); Plot ( IIf ( (tx0>px1 AND tx1<px1) OR (px0==px1 AND tx0==tx1),ls2e, Null ), "" , colorBlue , styleDashed ,0,0,0,-1,1); aa1= IIf (tx0>px1,(tl0-ph1)/(tx0-px1),0);aa1= IIf (tr, Ref (aa1,-1),aa1);ls1=aa1*(xx-px1)+ph1; bb1= IIf (tx0>px1 AND tx1<px1,1,0);bb1=bb1+ Ref (bb1,-1);bb1= IIf (bb1,1,0);ls1= IIf (bb1,ls1, Null ); sm= IIf (bb1, Sum (minipk, BarsSince (pk)),0);lv= ValueWhen (tr,sm,0);lv= Ref (lv,-1);sm= IIf (minipk,sm,0); lastMinipk=bb1 AND sm==lv AND sm!=0; sm= IIf (bb1, Sum ( IIf (minipk, H -ls1== HHV ( IIf (minipk, H -ls1,0), BarsSince (pk)),0), BarsSince (pk)),0); lv= ValueWhen (tr,sm,0);lv= Ref (lv,-1);sm= IIf (minipk,sm,0); furthestMinipk=bb1 AND sm==lv AND sm!=0;furthestMinipk= ExRem (furthestMinipk,tr); if (lastMiniPivot) mp=lastMinipk; else mp=furthestMinipk; htr= ValueWhen (mp, H ,0);htr= ValueWhen (pk,htr);vls1= ValueWhen (mp,ls1,0);vls1= ValueWhen (pk,vls1); dv=htr-vls1;ls2=ls1+dv;ls2= IIf (ls2> ValueWhen (pk, H ), Null ,ls2);Ls2= IIf (Ls2<0, Null ,Ls2); ls2e= ValueWhen (tr,ls2)+ ValueWhen (tr,aa1)*(xx-tx1);ls2e= IIf (ls2e< ValueWhen (tr, L ), Null ,ls2e); Plot (ls1, "" , colorOrange , styleThick ,0,0,0,-1,2); //PlotShapes(IIf(minipk AND bb1 AND BarsSince(pk)>1,shapeSmallCircle,shapeNone),ColorRGB(50,0,0),0,H,10); PlotShapes ( IIf (mp, shapeHollowSmallCircle , shapeNone ), colorWhite ,0, H ,10); Plot (ls2, "" , colorOrange , styleDashed ,0,0,0,-1,1); Plot ( IIf ( (px0>tx1 AND px1<tx1) OR (px0==px1 AND tx0==tx1),ls2e, Null ), "" , colorOrange , styleDashed ,0,0,0,-1,1); } if (dispTRENDLINES) { ll_h= IIf (ll,1,0); hl_h= IIf (hl,2,0); hh_h= IIf (hh,3,0); lh_h= IIf (lh,4,0); dt_h= IIf (dt,5,0); db_h= IIf (db,6,0); combi=ll_h+hl_h+lh_h+hh_h; t0= ValueWhen (combi,combi,0); t1= ValueWhen (combi,combi,1); t2= ValueWhen (combi,combi,2); t3= ValueWhen (combi,combi,3); t4= ValueWhen (combi,combi,4); // bullish pattern LH followed by HL bullish_LH_HL=(t1==2 AND tr) AND t2==4;valid_LH_HL= Flip (bullish_LH_HL,pk); //PlotShapes(shapeCircle*bullish_LH_HL,colorWhite,0,L,-50); // bearisch pattern HL followed by LH bearish_HL_LH=(t1==4 AND pk) AND t2==2;valid_HL_LH= Flip (bearish_HL_LH,tr); //PlotShapes(shapeCircle*bearish_HL_LH,colorWhite,0,H,50); upchan= Flip (tr,pk); dnchan= Flip (pk,tr); miny=LastVisibleValue( C )-LastVisibleValue( C )/100*10000; maxy=LastVisibleValue( C )+LastVisibleValue( C )/100*10000; ss= ValueWhen (tr, L ,1);ss= IIf (ss>maxy OR ss<miny, Null ,ss); invalid_ss= IIf ( BarsSince (tr)>0 AND ts AND upchan,ss, Null ); valid_ss1= IIf ( BarsSince (tr)>0 AND tl AND upchan,ss, Null ); valid_ss2= IIf ( BarsSince (tr)>0 AND tl AND dnchan,ss, Null ); valid_ss3= IIf ( BarsSince (tr)>0 AND ts AND dnchan,ss, Null ); valid_ss= IIf (valid_ss1,valid_ss1, IIf (valid_ss2,valid_ss2, IIf (valid_ss3,valid_ss3, Null ))); rr= ValueWhen (pk, H ,1);rr= IIf (rr>maxy OR rr<miny, Null ,rr); invalid_rr= IIf ( BarsSince (pk)>0 AND tl AND dnchan,rr, Null ); valid_rr1= IIf ( BarsSince (pk)>0 AND ts AND dnchan,rr, Null ); valid_rr2= IIf ( BarsSince (pk)>0 AND ts AND upchan,rr, Null ); valid_rr3= IIf ( BarsSince (pk)>0 AND tl AND upchan,rr, Null ); valid_rr= IIf (valid_rr1,valid_rr1, IIf (valid_rr2,valid_rr2, IIf (valid_rr3,valid_rr3, Null ))); for (i=1;i<=npivTL;i++) { y0= ValueWhen (tr, L ,i-1); y1= ValueWhen (tr, L ,i); x0= ValueWhen (tr,xx,i-1); x1= ValueWhen (tr,xx,i); aa=(y0-y1)/(x0-x1); ls1=aa*(xx-x1)+y1; dls1=ls1- Ref (ls1,-1); ls1= IIf (dls1<0, Null ,ls1); if (i>2) ls1= IIf (tr, Null ,ls1); if (i==1) Plot (ls1, "" , colorBrightGreen , styleLine | styleNoRescale ,0,0,0,-1); if (i==2) { Plot ( IIf (invalid_ss,ls1, Null ), "" , colorLightGrey , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); Plot ( IIf (valid_ss,ls1, Null ), "" , colorDarkGreen , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); vv= IIf (valid_ss,ls1, Null ); Short =valid_HL_LH AND Cross (vv, C ); Short = ExRem ( Short ,tr); ShortPrice = C ; PlotShapes ( IIf ( Short , shapeSmallDownTriangle , shapeNone ), colorRed ,0, H ,-15); PlotShapes ( IIf ( Short , shapeSmallCircle , shapeNone ), colorWhite ,0, ShortPrice ,0); } if (i>2) { Plot (ls1, "" , colorDarkGreen , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); } y0= ValueWhen (pk, H ,i-1); y1= ValueWhen (pk, H ,i); x0= ValueWhen (pk,xx,i-1); x1= ValueWhen (pk,xx,i); aa=(y0-y1)/(x0-x1); hs1=aa*(xx-x1)+y1; dhs1=hs1- Ref (hs1,-1); hs1= IIf (dhs1>0, Null ,hs1); if (i>2) hs1= IIf (pk, Null ,hs1); if (i==1) Plot (hs1, "" , colorRed , styleLine | styleNoRescale ,0,0,0,-1); if (i==2) { Plot ( IIf (invalid_rr,hs1, Null ), "" , colorLightGrey , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); Plot ( IIf (valid_rr,hs1, Null ), "" , colorOrange , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); vv= IIf (valid_rr,hs1, Null ); Buy =valid_LH_HL AND Cross ( C ,vv); Buy = ExRem ( Buy ,pk); BuyPrice = C ; PlotShapes ( IIf ( Buy , shapeUpArrow , shapeNone ), colorDarkGreen ,0, L ,-15); PlotShapes ( IIf ( Buy , shapeSmallCircle , shapeNone ), colorWhite ,0, BuyPrice ,0); } if (i>2) { Plot (hs1, "" , colorOrange , styleNoLine | styleDots | styleThick | styleNoRescale ,0,0,0,-1); } } } Buy =0; Short =0; if (dispSR) { upchan= Flip (tr,pk); dnchan= Flip (pk,tr); miny=LastVisibleValue( C )-LastVisibleValue( C )/100*percSR; maxy=LastVisibleValue( C )+LastVisibleValue( C )/100*percSR; ss= ValueWhen (tr, L ,1);ss= IIf (ss>maxy OR ss<miny, Null ,ss); invalid_ss= IIf ( BarsSince (tr)>0 AND ts AND upchan,ss, Null ); valid_ss1= IIf ( BarsSince (tr)>0 AND tl AND upchan,ss, Null ); valid_ss2= IIf ( BarsSince (tr)>0 AND tl AND dnchan,ss, Null ); valid_ss3= IIf ( BarsSince (tr)>0 AND ts AND dnchan,ss, Null ); valid_ss= IIf (valid_ss1,valid_ss1, IIf (valid_ss2,valid_ss2, IIf (valid_ss3,valid_ss3, Null ))); rr= ValueWhen (pk, H ,1);rr= IIf (rr>maxy OR rr<miny, Null ,rr); invalid_rr= IIf ( BarsSince (pk)>0 AND tl AND dnchan,rr, Null ); valid_rr1= IIf ( BarsSince (pk)>0 AND ts AND dnchan,rr, Null ); valid_rr2= IIf ( BarsSince (pk)>0 AND ts AND upchan,rr, Null ); valid_rr3= IIf ( BarsSince (pk)>0 AND tl AND upchan,rr, Null ); valid_rr= IIf (valid_rr1,valid_rr1, IIf (valid_rr2,valid_rr2, IIf (valid_rr3,valid_rr3, Null ))); for (i=1;i<=npivSR;i++) { if (i==1) { Plot (invalid_ss, "" , colorLightGrey , styleNoLine | styleDots ,0,0,0,-1); Plot (valid_ss, "" , colorRed , styleNoLine | styleDots ,0,0,0,-1); Plot (invalid_rr, "" , colorLightGrey , styleNoLine | styleDots ,0,0,0,-1); Plot (valid_rr, "" , colorBlue , styleNoLine | styleDots ,0,0,0,-1); Buy = Buy +( Cross ( C ,valid_rr) AND valid_rr); Short = Short +( Cross (valid_ss, C ) AND valid_ss); } else if (i>1) { rr= ValueWhen (pk, H ,i);rr= IIf (rr>maxy OR rr<miny, Null ,rr); ss= ValueWhen (tr, L ,i);ss= IIf (ss>maxy OR ss<miny, Null ,ss); Plot (ss, "" , colorRed , styleNoLine | styleDots ,0,0,0,-1); Plot (rr, "" , colorBlue , styleNoLine | styleDots ,0,0,0,-1); } } } PlotShapes ( shapeSmallCircle *tr, colorGreen ,0, L ,-10); PlotShapes ( shapeSmallCircle *pk, colorRed ,0, H ,10); Buy = Ref ( Buy ,-1); Short = Ref ( Short ,-1); Buy = ExRem ( Buy ,tr); BuyPrice = O ; Short = ExRem ( Short ,pk); ShortPrice = O ; PlotShapes ( IIf ( Buy , shapeUpTriangle , shapeNone ), colorBrightGreen ,0, L ,-15); PlotShapes ( IIf ( Buy , shapeSmallCircle , shapeNone ), colorWhite ,0, BuyPrice ,0); PlotShapes ( IIf ( Short , shapeDownTriangle , shapeNone ), colorOrange ,0, H ,-15); PlotShapes ( IIf ( Short , shapeSmallCircle , shapeNone ), colorWhite ,0, ShortPrice ,0); qq= Interval ()/60; if (qq < 60){tf= " min" ;tt=qq;} else if (qq >= 60 AND qq < 1440){tf= " hrs" ;tt=qq/60;} else if (qq >= 1440){tf= " days" ;tt=(qq/60)/24;} qq= Max (tfrm/60, Interval ()/60); if (qq < 60){tfa= " min" ;tta=qq;} else if (qq >= 60 AND qq < 1440){tfa= " hrs" ;tta=qq/60;} else if (qq >= 1440){tfa= " days" ;tta=(qq/60)/24;} Title = Name () + "\nChart TF: " + tt + tf + "\nZig TF: " + tta + tfa; dxhm=14;dxlm=10;dxh=0;dxl=0;dyhm=5;dylm=3;dyh=18;dyl=29;hm=30;lm=30; dyl2=42;dylm2=16;dyhm2=18;dyh2=31; function GetVisibleBarCount() { lvb= Status ( "lastvisiblebar" ); fvb= Status ( "firstvisiblebar" ); return Min (lvb-fvb, BarCount -fvb); } function GfxConvertPixelsToBarX(Pixels) { lvb= Status ( "lastvisiblebar" ); fvb= Status ( "firstvisiblebar" ); pxchartleft= Status ( "pxchartleft" ); pxchartwidth= Status ( "pxchartwidth" ); fac=pxchartwidth/Pixels; bar=(lvb-fvb)/fac; return bar; } function GfxConvertPixelToValueY(Pixels) { local Miny,Maxy,pxchartbottom,pxchartheight; Miny= Status ( "axisminy" ); Maxy= Status ( "axismaxy" ); pxchartbottom= Status ( "pxchartbottom" ); pxchartheight= Status ( "pxchartheight" ); fac=pxchartheight/Pixels; Value=(Maxy-Miny)/fac; return Value; } miny= Status ( "axisminy" ); maxy= Status ( "axismaxy" ); AllVisibleBars=GetVisibleBarCount(); fvb= Status ( "firstvisiblebar" ); LowMargin=Miny+GfxConvertPixelToValueY(lm); HighMargin=Maxy-GfxConvertPixelToValueY(hm); dyllm=GfxConvertPixelToValueY(dylm); dyhhm=GfxConvertPixelToValueY(dyhm); dyll=GfxConvertPixelToValueY(dyl); dyhh=GfxConvertPixelToValueY(dyh); dxllm=GfxConvertPixelsToBarX(dxlm); dxhhm=GfxConvertPixelsToBarX(dxhm); dxll=GfxConvertPixelsToBarX(dxl); dxhh=GfxConvertPixelsToBarX(dxh); dyllm2=GfxConvertPixelToValueY(dylm2); dyll2=GfxConvertPixelToValueY(dyl2); dyhhm2=GfxConvertPixelToValueY(dyhm2); dyhh2=GfxConvertPixelToValueY(dyh2); dyllv=GfxConvertPixelToValueY(dyl+26); dyhhv=GfxConvertPixelToValueY(dyhm+39); if (disp0) { for (i=0;i<AllVisibleBars;i++) { if (ll[i+fvb]) { PlotText ( "LL" ,i+fvb+dxll, L [i+fvb]-dyll, colorWhite , colorDefault ); PlotText ( "" + L [i+fvb],i+fvb+dxll, L [i+fvb]-dyll2, colorWhite , colorDefault ); } if (hl[i+fvb]) { PlotText ( "HL" ,i+fvb+dxll, L [i+fvb]-dyll, colorWhite , colorDefault ); PlotText ( "" + L [i+fvb],i+fvb+dxll, L [i+fvb]-dyll2, colorWhite , colorDefault ); } if (db[i+fvb]) { PlotText ( "DB" ,i+fvb+dxll, L [i+fvb]-dyll, colorWhite , colorDefault ); PlotText ( "" + L [i+fvb],i+fvb+dxll, L [i+fvb]-dyll2, colorWhite , colorDefault ); } if (hh[i+fvb]) { PlotText ( "HH" ,i+fvb+dxhh, H [i+fvb]+dyhh, colorWhite , colorDefault ); PlotText ( "" + H [i+fvb],i+fvb+dxhh, H [i+fvb]+dyhh2, colorWhite , colorDefault ); } if (lh[i+fvb]) { PlotText ( "LH" ,i+fvb+dxhh, H [i+fvb]+dyhh, colorWhite , colorDefault ); PlotText ( "" + H [i+fvb],i+fvb+dxhh, H [i+fvb]+dyhh2, colorWhite , colorDefault ); } if (dt[i+fvb]) { PlotText ( "DT" ,i+fvb+dxhh, H [i+fvb]+dyhh, colorWhite , colorDefault ); PlotText ( "" + H [i+fvb],i+fvb+dxhh, H [i+fvb]+dyhh2, colorWhite , colorDefault ); } } } |