maximum angle in lookback period.
Forums › ProRealTime English forum › ProBuilder support › maximum angle in lookback period.
- This topic has 5 replies, 3 voices, and was last updated 6 years ago by robertogozzi.
-
-
07/14/2018 at 4:31 AM #75942
Hiya,
I’d like to compare today’s high to each of the highs in a lookback range of 20 bars. Then divide that number by the bars since that high occured, in order to find the highest angle possible between today’s high and a single high in the lookback period. Could I have some clues where to start please?
07/14/2018 at 10:03 AM #75954Angles/Slopes are impossible to be measured, this has been extensively discussed here and elsewhere. Some useful links:
https://www.prorealcode.com/topic/ema-45-degres-uptrend/
https://www.prorealcode.com/topic/indicator-for-inclination-of-moving-average/
https://www.prorealcode.com/topic/calculating-the-angle-linear-regression-of-a-line/
Anyway, to retrieve the BarIndex ID of a bar you can only use loops, since there’s no function returning that info, as of this version of PRT:
123456FOR i = 0 TO 19 //20 bars lookbackIF high[i] > high[i+1] THEN //put here anything you like to check..ENDIFNEXT1 user thanked author for this post.
07/14/2018 at 10:16 AM #75956in order to find the highest angle possible between today’s high and a single high in the lookback period
I guess if you had said … to get a measure of the rate of change between today’s high and a single high in the lookback period ... may be less confusing and might get you the code you need? 🙂
1 user thanked author for this post.
07/19/2018 at 3:52 AM #76274Thanks for the help Robert and Grahal.
Grahal, that’s an excellent idea. Am I geting closer with the following?
angle estimate123456FOR i = 0 TO 20 //20 bars lookbackIF high[i] > high[i+1] THEN //put here anything you like to checka = high[i+1] /barindexaa = highest[20](a)ENDIFNEXT07/19/2018 at 4:14 AM #76275ok that attempt was no good.
I’m trying to create a substitute for a downsloping trendline which can be auto-traded by finding (in psuedocode):
highest angle in lookback = (high[lookback] – today’s high ) / barindex
then for each bar after today, subtracting that angle to create a trigger price, until the close >trigger.
Suggestions very welcome!
07/19/2018 at 5:03 AM #76276Barindex can be 10000 or more, maybe highest angle in lookback = (high[lookback] – today’s high ) / i would be better, but I did not test it.
1 user thanked author for this post.
-
AuthorPosts