Please Help – Tops and Bottoms
Forums › ProRealTime English forum › ProBuilder support › Please Help – Tops and Bottoms
- This topic has 5 replies, 2 voices, and was last updated 1 year ago by Khaled.
-
-
09/02/2023 at 11:15 AM #220208
Hello everyone,
I would like to have Lows and Highs of a Range detected and mark the breakout/down with a row. One of the issues is the Lookback period can be variable. Would there be a way to improve the following code (for example by having the lookback period as a “variable” with a loop)? examples highlighted on the attached graph.
Thank you
Detecting Tops and Bottoms123456789101112131415161718192021222324252627282930313233DEFPARAM CALCULATEONLASTBARS = 1000i = LookbackHipast = highest[i] (high[1])Lopast = lowest[i] (low[1])ATR = AverageTrueRange[14](close)if high[1] <=Hipast and high >=Hipast thenDRAWSEGMENT(barindex, Hipast, barindex[i], Hipast) coloured("red")elsif low[1] >=Lopast and low <=lopast thenDRAWSEGMENT(barindex, Lopast, barindex[i], Lopast) coloured("green")endifif time>=080000 and time<220000 thenif close crosses under lopast thenDRAWARROWDOWN(barindex, high[1]+atr) coloured("red")elsif close crosses over hipast thenDRAWARROWUP(barindex, low[1]-ATR) coloured("green")endifendifif time>=000000 and time<=080000 thenBACKGROUNDCOLOR (128,128,128,50)elsif time>=220000 and time<=240000 thenBACKGROUNDCOLOR (128,128,128,50)ENDIFRETURN09/02/2023 at 1:48 PM #22021409/02/2023 at 1:56 PM #22021609/02/2023 at 2:16 PM #220221Hi Khaled,
This works well for finding tops and bottoms…
If High[i] = Highest[i * 2 +1](High) then
If Low[i] = Lowest[i * 2 + 1](Low) then
You can make a profitable system out of this… (where i can be optimized)
Top & Bottom12345678910111213141516171819DefParam DrawOnLastBarOnly=FalseATR=AverageTrueRange[i](Close)If High[i]=Highest[i*2+1](High) thenxTop=High[i]DrawSegment(BarIndex[i],xTop, BarIndex[i-i/2],xTop)Coloured("Red")ElsIf Low[i]=Lowest[i*2+1](Low) thenxBottom=Low[i]DrawSegment(BarIndex[i],xBottom, BarIndex[i-i/2],xBottom)Coloured("Green")EndIfIf Close Crosses Under xBottom[1] thenDrawArrowDown(BarIndex,High+ATR)Coloured("Red")ElsIf Close Crosses Over xTop[1] thenDrawArrowUp(BarIndex,Low-ATR)Coloured("Green")EndIfReturn1 user thanked author for this post.
09/02/2023 at 2:32 PM #22022209/02/2023 at 2:46 PM #220223I don’t want to abuse of your kindness, but I’d be most grateful if you have the time to look at this too https://www.prorealcode.com/topic/please-help-take-only-the-first-cross/#post-220212
-
AuthorPosts
Find exclusive trading pro-tools on