Smaller Timeframe drawline/rectangle issues
Forums › ProRealTime English forum › ProBuilder support › Smaller Timeframe drawline/rectangle issues
- This topic has 8 replies, 2 voices, and was last updated 6 years ago by kastin.
-
-
07/10/2018 at 12:36 PM #75715
Hello, i have a piece of code that i have assembled/Frankensteined, it works well on hourly and above, but when i swap down to lower timeframes something odd happens,
the problem is with the drawing the lines and rectangle, when i move to a smaller timeframe they either dont draw, or the vertical axis is way out?
I apologize for the messy code, i am no professional
A mess1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374defparam drawonlastbaronly=trueATRperiod = 20dTR = 0for i = 0 to ATRperioddTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))nextavg = dTR/ATRperiodconverted = round(avg/pointsize*10)/10//TimeRange = ( Time < 130100 AND Time > 135959 )IF time = 150000 THENbegin=BarIndexdaysopen = closeelse//backwards = barindex-begin//daysopen = close[backwards]ENDIF//bindex = IntradayBarIndexbindex = BarIndexIF bindex-begin < 1 THENDdhigh = highest[1](high)Ddlow = lowest[1](low)daysopen = close[1]ELSEbsince = (bindex-(begin))Ddhigh = highest[bsince](high)Ddlow = lowest[bsince](low)daysopen = close[bsince]ENDIF//Ddhigh = highest[bsince](high)htr = Ddlow+avg[1]ltr = Ddhigh-avg[1]bhtr = daysopen+(.3*avg[1])bltr = daysopen-(.3*avg[1])//just for calculation of textbounce = (.3*avg[1])drawsegment(begin,htr,bindex,htr) coloured(200,100,0)drawtext("#htr# - (D1atr: #converted#)",bindex,htr+10*pointsize,Dialog,Bold,10) coloured(200,100,0)drawsegment(begin,ltr,bindex,ltr) coloured(200,100,0)drawtext("#ltr# - (D1atr: #converted#)",bindex,ltr-10*pointsize,Dialog,Bold,10) coloured(200,100,0)drawsegment(begin,bhtr,bindex,bhtr) coloured(255,255,0)drawtext("#bhtr# - (Short openers area: #bounce#)",bindex,bhtr+10*pointsize,Dialog,Bold,15) coloured(200,200,0)// DRAWRECTANGLE (x1, y1, x2, y2) COLOURED (R, V, B, a)DRAWRECTANGLE (begin, daysopen+bounce, bindex, daysopen) coloured(150,150,150)//just to see if BLTR had anumber on smaller tf drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,ddhigh-10*pointsize,Dialog,Bold,15) coloured(200,200,0)drawsegment(begin,bltr,bindex,bltr) coloured(255,255,0)drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,bltr-10*pointsize,Dialog,Bold,15) coloured(200,200,0)drawsegment(begin,daysopen,bindex,daysopen) coloured(0,0,255)drawsegment(begin,ddhigh,bindex,ddhigh) coloured(0,50,0)drawsegment(begin,ddlow,bindex,ddlow) coloured(0,50,0)return07/10/2018 at 12:48 PM #7572107/10/2018 at 1:07 PM #7572407/10/2018 at 1:38 PM #75728In this line you are adding text 10 points away from the “bltr” line:
1drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,bltr-10*pointsize,Dialog,Bold,15) coloured(200,200,0)While it is close to the line on a larger timeframe, it could be far away on a very small one (or if you zoom in on the chart).
A rough solution could be to adapt this spread automatically with an indicator value in points, like the ATR for instance:
12atr=averagetruerange[14]drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,bltr-atr/2,Dialog,Bold,15) coloured(200,200,0)07/10/2018 at 2:02 PM #75732Ok i see what you mean,
but all that did was change the text position on the hourly, it had no effect on smaller timeframes,
i think the problem lies with not calculating the “daysopen” (the open price at 1600 which is pretty close to close price at 1500) on smaller timeframes.
How would you normally draw a rectangle that starts at a specific time, then +/- percentage of price?
07/10/2018 at 4:23 PM #7574107/10/2018 at 4:43 PM #7574607/10/2018 at 4:46 PM #7574707/10/2018 at 5:03 PM #75749 -
AuthorPosts
Find exclusive trading pro-tools on