A Previous 20 & 40 Day Rectangle – A Request Please?
Forums › ProRealTime English forum › ProBuilder support › A Previous 20 & 40 Day Rectangle – A Request Please?
- This topic has 14 replies, 4 voices, and was last updated 9 months ago by PeterSt.
-
-
03/01/2024 at 1:53 AM #229010
Hi all! I’d like to humbly ask a request from someone to code a dynamic rectangle with a centre line for me that marks the high and low of the past 20 & 40 days from the 1st of the current and previous month. I’d like there to be no borders but just a coloured but transparent rectangle of a 20 and 40 daily high and low? I searched the forum and found this as the closest example.
I’d be very much grateful. Thank you.
03/01/2024 at 8:07 AM #229014You need 8 lines:
- 4 lines marking the high and low of the last 20 and 40 periods starting from day 1 of the previous month
- 4 lines marking the high and low of the last 20 and 40 periods starting from day 1 of the current month.
- All these lines need to be embedded in a rectangle.
- The lines need to be at the center of the rectangle, so the rectangle has to have both the upper and lower border at the same distance from the outer lines.
Is that correct?
03/01/2024 at 1:43 PM #22903103/01/2024 at 11:00 PM #229063Hi Roberto, I’ve just re-read this post from this morning. Maybe I didn’t read it properly, if you mean 4 lines as in both sides of a rectangle then yes if that is how it will turn out if you can do it for me. You can see the attachment I posted above to see what I was try to explain. You will see from the 1st of the month one rectangle is 20 days and the second rectangle would mark forth days from the same point. The rectangles are not attached to each other, they are just on top of each other or can be toggled on or off. Hope that helps.
03/02/2024 at 1:29 PM #229085Hi Andre, have a look at this!
I just through this together to get something up and running based on your description, but what i’m thinking may not the same as you.
It could help if you elaborate more on the reasoning why you want the rectangles and how you intend to use and interpret them and where.
If you import the .itf file you can dynamically change the variables through the indicator config setting. If you cut/paste you will have to remove the ‘//’ at the beginning of lines 4-9 and save again via [Apply to… xxxxxxx…] button .
regard druby
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576defparam drawonlastbaronly = true////dynamic variables with default values//current = 1 // boolean, display current month rectangles//previous = 1 // boolean, display previous month rectangles//draw1 = 1 // boolean, draw lbk1 rectangle(s)//draw2 = 1 // boolean, draw lbk2 rectangle(s)//lbk1 = 20 // integer, lookback 'n' bars//lbk2 = 40 // integer, lookback 'n' barsonce idx = -1// entry guardlbk1 = abs(max(lbk1,1)) // positive, not zerolbk2 = abs(max(lbk2,1)) // positive, not zeroif month <> month[1] then // change of monthidx = idx + 1 // increment the array index$bar[idx] = barindex // store bar and highs and lows$HH1[idx] = highest[lbk1](high)$HH2[idx] = highest[lbk2](high)$LL1[idx] = lowest[lbk1](low)$LL2[idx] = lowest[lbk2](low)endif// rgba settingsr = 100g = 150b = 255a = 255if islastbarupdate thenif isset($bar[1]) thenfor i = lastset($bar)-1 to lastset($bar) // loop the last two entries// switch for previous and currentif previous and lastset($bar)-1 = i or current and lastset($bar) = i then// retrieve data from arraysbar = $bar[i]HH1 = $HH1[i]HH2 = $HH2[i]LL1 = $LL1[i]LL2 = $LL2[i]for i = 0 to 1 // loop for lbk1 and lbk2's datalbk = lbk1-1HH = HH1LL = LL1if i = 1 thenlbk = lbk2-1HH = HH2LL = LL2endif// switch for draw1 and draw2if draw1 and i = 0 or draw2 and i = 1 thenx1 = barindex - bary1 = HHx2 = x1+lbky2 = LLendifdrawrectangle(barindex[x1],y1,barindex[x2],y2)bordercolor(r,g,b,0)coloured(r,g,b,a/5)drawsegment(barindex[x1],((y1-y2)/2)+y2,barindex[x2],((y1-y2)/2)+y2)style(dottedline,1)coloured(0,0,0,a/2)drawtext(y1,barindex+15,y1)drawtext(y2,barindex+15,y2)nextendifnextendifendifreturn2 users thanked author for this post.
03/02/2024 at 2:33 PM #229091HI Druby! This is exactly what I wanted! I applied it to my chart and you have understood it perfectly, thank you so much! What I was trying to re-create is an institutional reference point for how price moves in a given market. They are called IPDA ranges. I’m learning to trade from the teachings of ICT, this is his Youtube if you aren’t familiar with him. This is the particular lesson I wanted to re-create the indicator from. If you get to watch the lesson, you’ll see there are actually 20,40 and 60 days reference points but for my trading setup I don’t need to see the 60. Your time and gift to me is appreciated. Thank you very much.
03/05/2024 at 12:49 PM #229243Hi Andre, took a look at that video, thought the ‘Open Interest’ looked we’ll, interesting but not expecting that to appear any time soon.
Having been inspired, I did another version which should at default be the same as other with reference to the rectangles.
New features are:
To add a third lookback rectangle, if you want to go there 60 !
‘num’ allows more than 1 previous month to be displayed.
‘back’ allow shifting of the blocks back a month at a time to look at previous situations.
‘mnLine’ displays some guidelines on every month and highlights the quarters.
Also a 20 bar look forward box is displayed.
‘text’ allow hiding the text,, encoding 0 = all, 1 = price , 2 month/array data index
Known issues…
using ‘back’ only goes back so far, using more units can get around this if its a deal breaker.
The future quarterly highlight doesn’t show until its current bar.
lookforward box may not be 20 bars, because of divergence between time/bars and market closed.
And doesn’t choose right level as intended at times. Needs work!
I think this type of indicator would be best implemented as just 1 rectangle and then multiple indicators could be added to a chart in a similar way as if you have multiple moving averages.
Arrr we’ll…
druby
2 users thanked author for this post.
03/07/2024 at 11:03 PM #229426Found a new issue with V1.03…
- Not displaying any rectangles with chart units less than 150
This appears to be the same issue affecting ‘back’, and only being able to go back so many months.
Changing line 48
- From… if isset($bar[1]) and start > $bar[1] then
- To… if isset($bar[1]) and start > isset($bar[1]) then
solves both issues.
1 user thanked author for this post.
03/13/2024 at 12:21 AM #229666Found a new issue with V1.03…
- Not displaying any rectangles with chart units less than 150
This appears to be the same issue affecting ‘back’, and only being able to go back so many months.
Changing line 48
- From… if isset($bar[1]) and start > $bar[1] then
- To… if isset($bar[1]) and start > isset($bar[1]) then
solves both issues.
Hey, Sorry for the late reply, I didn’t see your replies. Thanks very much for all the updates. This is just as well because I’ve updated my trading plan for the indicator to what it was originally indented for which is how it should be used in the first place – up to 60 day lookbacks and look forwards like you mentioned. The look backs and forwards are only valid at a break or shift of structure.
I will install the updates and get back to you.
Thank you!
03/13/2024 at 3:35 AM #229667Hi Andre, took a look at that video, thought the ‘Open Interest’ looked we’ll, interesting but not expecting that to appear any time soon.
Having been inspired, I did another version which should at default be the same as other with reference to the rectangles.
New features are:
To add a third lookback rectangle, if you want to go there 60 !
‘num’ allows more than 1 previous month to be displayed.
‘back’ allow shifting of the blocks back a month at a time to look at previous situations.
‘mnLine’ displays some guidelines on every month and highlights the quarters.
Also a 20 bar look forward box is displayed.
‘text’ allow hiding the text,, encoding 0 = all, 1 = price , 2 month/array data index
Known issues…
using ‘back’ only goes back so far, using more units can get around this if its a deal breaker.
The future quarterly highlight doesn’t show until its current bar.
lookforward box may not be 20 bars, because of divergence between time/bars and market closed.
And doesn’t choose right level as intended at times. Needs work!
I think this type of indicator would be best implemented as just 1 rectangle and then multiple indicators could be added to a chart in a similar way as if you have multiple moving averages.
Arrr we’ll…
druby
Hey Druby. The Indicator was working fine for me. But then my charts started freezing and the interface went dark. Never happened before. I restarted my laptop and I haven’t had the freezing so far. I haven’t activated it again. Could there be something in the code causing this?
03/13/2024 at 11:42 AM #229686Hi Andre, been using this version since a wrote it several days ago , not seen a problem like what you describe and its been running in a chart for at least 12 hours a day over 2 desktop PC at different locations and internet.
Since I have been programming with PRT and ProBuilder I have not seen this issue but, can’t rule it out 100%.
If the indicator errored in some way I would expect error to be limited to the chart window where indicator added and would only expect it to affect that indicator and not other independant elements of the chart like the price candles, manual drawn objects and other added indicators or the PRT/OS. If a internal error was triggered, I would expect a possible an error message, but not that’s not 100% either
Just to clarify, the prior versions indicator only displayed the rectangles when added to the/a price window and used on the ‘Daily’ timeframe. However, this version tests for ‘Daily’ timeframe and displays error message if on other. Returning back to ‘daily’ removes message. Message displayed, can be disabled via settings if you needed change to other timeframe and remove message. Message won’t re-appear again until enabled again.
My current PRT version is 12.0 – 17.0.7 found under [main menu bar],[Help],[About].
Looking at the code, the use of ‘Array’ and the ‘Anchor’ commands came in on Version 11 maybe Version 11.1, if a remember right. If your version was not compatible I would expect some error message informing you of the situation.
Only thing I can suggest is, if it is the indicator, you would expect repeatedly getting the problem if continue to use.
Recently adding it, and now not using it, my appear to point to it having a problem if you never get it again, but, doesn’t rule out that it could have been a coincidence with some other issue. [prt,java,windows,OS,PC, mac,internet, power spike, too much coffee, working too hard] etc.
If I were having the problem I would try to identify and eliminate the variables of using it in the situation when error occures and correlate them to isolate down how to trigger error and which/what variable(s) were responsible.
I know it would be better to say it’s this!, but i don’t think were there at the moment , at this time I cannot see any thing in the indicator code, and something happened is a big gap to investigate without gathering more data/information.
Regarding your comments and oservations when error was occurring, chart freezing could related to a loss of data connection and/or the processor doing heavy duty number cruching on something else in the background and not updating.
Memory could have been a issue and a blank screen points possible to the video not being updated. All these could be signs of computer crashing, but why it crashed, we’ll there a good question.
Regards druby
1 user thanked author for this post.
03/13/2024 at 12:47 PM #229693Maybe observe the used memory of the Java instance (by means of TaskManager) and see whether it grows and grows automatically.
When it approaches 6GB – and by further default settings within Java – you may expect problems (at 8GB all will be dead).To me too it looks like your laptop just crashed. And when this never happened before, the Indicator should be suspect. But as druby said, all can be coincidence.
03/13/2024 at 2:23 PM #229700Hi Andre, been using this version since a wrote it several days ago , not seen a problem like what you describe and its been running in a chart for at least 12 hours a day over 2 desktop PC at different locations and internet.
Since I have been programming with PRT and ProBuilder I have not seen this issue but, can’t rule it out 100%.
If the indicator errored in some way I would expect error to be limited to the chart window where indicator added and would only expect it to affect that indicator and not other independant elements of the chart like the price candles, manual drawn objects and other added indicators or the PRT/OS. If a internal error was triggered, I would expect a possible an error message, but not that’s not 100% either
Just to clarify, the prior versions indicator only displayed the rectangles when added to the/a price window and used on the ‘Daily’ timeframe. However, this version tests for ‘Daily’ timeframe and displays error message if on other. Returning back to ‘daily’ removes message. Message displayed, can be disabled via settings if you needed change to other timeframe and remove message. Message won’t re-appear again until enabled again.
My current PRT version is 12.0 – 17.0.7 found under [main menu bar],[Help],[About].
Looking at the code, the use of ‘Array’ and the ‘Anchor’ commands came in on Version 11 maybe Version 11.1, if a remember right. If your version was not compatible I would expect some error message informing you of the situation.
Only thing I can suggest is, if it is the indicator, you would expect repeatedly getting the problem if continue to use.
Recently adding it, and now not using it, my appear to point to it having a problem if you never get it again, but, doesn’t rule out that it could have been a coincidence with some other issue. [prt,java,windows,OS,PC, mac,internet, power spike, too much coffee, working too hard] etc.
If I were having the problem I would try to identify and eliminate the variables of using it in the situation when error occures and correlate them to isolate down how to trigger error and which/what variable(s) were responsible.
I know it would be better to say it’s this!, but i don’t think were there at the moment , at this time I cannot see any thing in the indicator code, and something happened is a big gap to investigate without gathering more data/information.
Regarding your comments and oservations when error was occurring, chart freezing could related to a loss of data connection and/or the processor doing heavy duty number cruching on something else in the background and not updating.
Memory could have been a issue and a blank screen points possible to the video not being updated. All these could be signs of computer crashing, but why it crashed, we’ll there a good question.
Regards druby
Good Afternoon Druby! Thanks so much! The indicator is only used on a daily time frame so no other time frames are necessary. I checked my task manager at the time also, and it wasn’t showing anything unusual from what I saw either. My laptop is powerful enough to run a couple heavy programs but like you mentioned, these things could happen from time to time. What I have noticed with my laptop is that whenever there is significant update due it does act up and this morning I got a notice for an update. What I’ll do is setup automatic updates and see if that makes a difference in the future. My current PRT is also V12 17.07. Thank you very much for the updates.
03/13/2024 at 2:26 PM #229701Maybe observe the used memory of the Java instance (by means of TaskManager) and see whether it grows and grows automatically.
When it approaches 6GB – and by further default settings within Java – you may expect problems (at 8GB all will be dead).
To me too it looks like your laptop just crashed. And when this never happened before, the Indicator should be suspect. But as druby said, all can be coincidence.
I did have some updates to install, my laptop does have a tendency to act weird whenever an update is due for some reason. I’m going to update and see what happens and keep an eye on my task manager. Cheers!
03/13/2024 at 3:21 PM #229703 -
AuthorPosts