Drawing a coloured Rectangle
Forums › ProRealTime English forum › ProBuilder support › Drawing a coloured Rectangle
- This topic has 9 replies, 3 voices, and was last updated 1 year ago by Nicolas.
-
-
04/18/2023 at 11:22 AM #21343804/18/2023 at 11:56 AM #213440
Just made this one, can you help to Stop the last Rectangle when a new one is formed?
12345678910111213141516171819TopImbalance = low[2] <= open[1] and high[0] >= close[1]TopImbalancesize = low[2] - high[0]if TopImbalance and TopImbalancesize > 0 thendrawcandle(low[2], low[2], high[0], high[0]) coloured(255,255,0)if Tracage thendrawrectangle(BarIndex[2],low[2],BarIndex + 10,high[0])coloured (255,204,204,255) bordercolor(204,0,0)endifendifBottomInbalance = high[2] >= open[1] and low[0] <= close[1]BottomInbalancesize = low[0] - high[2]if BottomInbalance and BottomInbalancesize > 0 thendrawcandle(low[0], low[0], high[2], high[2]) coloured(255,255,0)if Tracage thendrawrectangle(BarIndex[2],high[2],BarIndex + 10,low[0]) coloured(204,255,204,255) bordercolor(0,204,0)endifendifreturn04/18/2023 at 9:08 PM #213460Add this line at the very beginning of your code:
1Defparam DrawOnLastBarOnly = True04/20/2023 at 9:16 AM #213535Thank you
I have 2 questions:
- How to limite a nombre of rectangle drawing in the past instead of having only the last?
For example to have the last 10 rectangle only?
2) How can i display a rectangle for example of a 15 minutes time frame in a 2 minutes chart?
04/20/2023 at 10:11 AM #2135441/ Must use arrays for that: store each of the coordinates of the rectangle into different variables arrays and plot them in the past from the last candle.
(I’m looking for an example in the forum..)
2/ use TIMEFRAME instruction to store the values from that timeframe only.
04/20/2023 at 11:11 AM #21354604/20/2023 at 12:04 PM #213548There is no way to create a condition block that embed the TIMEFRAME instruction. However there is a workaround with CALL, see complete discussion here: https://www.prorealcode.com/topic/condition-et-timeframe/
04/20/2023 at 12:36 PM #213553Here is a draft version of the MTF indicator:
123456789101112131415161718192021222324252627282930313233343536373839404142434445defparam drawonlastbaronly=truetimeframe(default) //!!DO NOT CHANGE TIMEFRAME HERE!!ibar=max(1,barindex)timeframe(15 minutes,updateonclose) //<=== CHANGE TIMEFRAME HERE (default is for the current timeframe of the chart)//timeframe(default) //<== example with timeframe of the chart.//timeframe(1 hour,updateonclose) //<== example with timeframe 1-hour.//timemframe(1 day,updateonclose) //<== example with timeframe daily.TopImbalance = low[2] <= open[1] and high[0] >= close[1]TopImbalancesize = low[2] - high[0]if TopImbalance and TopImbalancesize > 0 thena=a+1$y1[a]=low[2]$y2[a]=high[0]$dir[a] = 1$x1[a]=ibar$x2[a]=ibar+10//drawrectangle(BarIndex[2],low[2],BarIndex + 10,high[0])coloured (255,204,204,255) bordercolor(204,0,0)endifBottomInbalance = high[2] >= open[1] and low[0] <= close[1]BottomInbalancesize = low[0] - high[2]if BottomInbalance and BottomInbalancesize > 0 thena=a+1$y1[a]=high[2]$y2[a]=low[0]$dir[a] = -1$x1[a]=ibar$x2[a]=ibar+10//drawrectangle(BarIndex[2],high[2],BarIndex + 10,low[0]) coloured(204,255,204,255) bordercolor(0,204,0)endiftimeframe(default)if islastbarupdate and a>1 thenfor i=a downto 1 doif $dir[i]=1 thendrawrectangle($x1[i],$y1[i],$x2[i],$y2[i])coloured (255,204,204,255) bordercolor(204,0,0)elsif $dir[i]=-1 thendrawrectangle($x1[i],$y1[i],$x2[i],$y2[i])coloured (204,255,204,255) bordercolor(0,204,0)endifnextendifreturn04/20/2023 at 5:48 PM #21356004/21/2023 at 10:23 AM #213573 -
AuthorPosts