Draw support line until it is broken by subsequent price action
Forums › ProRealTime English forum › ProBuilder support › Draw support line until it is broken by subsequent price action
- This topic has 7 replies, 4 voices, and was last updated 1 year ago by Bel.
Tagged: array
-
-
10/17/2022 at 12:13 PM #202677
Dear Members of the Forum,
I want to draw a support line on the lowest low of an umbrella line (significant candle in hammer and hanging man patterns).
My code so far is:1234567891011121314151617REM Measure the length of real body, lower shadow, and upper shadow for white and black candlesIF OPEN < CLOSE THEN REM white candlerealbody = CLOSE - OPENlowershadow = OPEN - LOWuppershadow = HIGH - CLOSEELSIF OPEN > CLOSE THEN REM black candlerealbody = OPEN - CLOSElowershadow = CLOSE - LOWuppershadow = HIGH - OPENENDIFREM Draw supportIF ((lowershadow / realbody) >= 2 AND (realbody/uppershadow) >= 2) AND NOT(OPEN = CLOSE) THENDRAWSEGMENT(BARINDEX, LOW, BARINDEX+10,LOW) COLOURED(0,255,0)ENDIFRETURNIn the code above I have hardcoded the length of the support line as being 10 bars long, ideally I would like the length of the line to be determined by subsequent price action breaking it.
That is, if a subsequent candle’s low is below the line, then, and only then, the line should end.Does andybody know how this can be done? If the solution involves arrays, I would be happy if you could also provide some code showing how this would work in this case, since I have tried it but couldn’t wrap my head around it.
I thank you in advance!
Greetings,
Nils10/17/2022 at 12:54 PM #20268610/17/2022 at 1:10 PM #202688Please find below a rough solution that work ok to me. Please confirm 😉
12345678910111213141516171819202122232425262728293031323334353637383940defparam drawonlastbaronly=trueREM Measure the length of real body, lower shadow, and upper shadow for white and black candlesIF OPEN < CLOSE THEN REM white candlerealbody = CLOSE - OPENlowershadow = OPEN - LOWuppershadow = HIGH - CLOSEELSIF OPEN > CLOSE THEN REM black candlerealbody = OPEN - CLOSElowershadow = CLOSE - LOWuppershadow = HIGH - OPENENDIFREM Store supportIF ((lowershadow / realbody) >= 2 AND (realbody/uppershadow) >= 2) AND NOT(OPEN = CLOSE) THEN$support[i]=low$bar[i]=barindexi=i+1ENDIFREM check support lineif islastbarupdate and i>1 thenfor j = 0 to i-1checklow = $support[j]bars = max(1,barindex-$bar[j])check=0for z = 1 to barsif low[z]<checklow thencheck=1breakendifnextif check=0 thendrawray($bar[j],$support[j],barindex,$support[j]) coloured(0,255,0)endifnextendifRETURN1 user thanked author for this post.
10/17/2022 at 1:31 PM #202693Dear Nicolas,
Thank you so much for your fast response.
The code does draw support lines if the price action has not been broken (as rays starting from the umbrella line’s lows). What it does not, is draw the support lines that have been broken (until they are broken; likely via DRAWSEGMENT).
I attached two screenshots. All umbrella lines are highlighted with a grey background. The first screenshot shows the result of your code, the second one shows where support lines should be drawn as well (I just put them in by hand).I hope there is a solution for this. Thank you again for helping me with this!
Greetings,
Nils10/17/2022 at 2:34 PM #202702Ok, that new version should be what you required:
1234567891011121314151617181920212223242526272829303132333435363738394041defparam drawonlastbaronly=trueREM Measure the length of real body, lower shadow, and upper shadow for white and black candlesIF OPEN < CLOSE THEN REM white candlerealbody = CLOSE - OPENlowershadow = OPEN - LOWuppershadow = HIGH - CLOSEELSIF OPEN > CLOSE THEN REM black candlerealbody = OPEN - CLOSElowershadow = CLOSE - LOWuppershadow = HIGH - OPENENDIFREM Store supportIF ((lowershadow / realbody) >= 2 AND (realbody/uppershadow) >= 2) AND NOT(OPEN = CLOSE) THEN$support[i]=low$bar[i]=barindexi=i+1ENDIFREM check support lineif islastbarupdate and i>1 thenfor j = 0 to i-1checklow = $support[j]bars = max(1,barindex-$bar[j])endbar=barindexfor z = 1 to barsif low[z]<checklow thenendbar=barindex[z]endifnextif endbar<barindex thendrawsegment($bar[j],$support[j],endbar,$support[j]) coloured(0,255,0)elsedrawray($bar[j],$support[j],barindex+1,$support[j]) coloured(0,255,0)endifnextendifRETURN10/17/2022 at 2:38 PM #20270502/04/2023 at 11:07 AM #209096Hello, thank you for this interesting topic. I have an error see PJ. Cordially.
02/20/2023 at 6:42 PM #209992won’t create new topic as it seems quite similar but would like to ask if creating something like you did here only to draw line from particular closing time, which we have an option to select, towards in time till it meets the session, which open and close time we also have an option to select, would involve arrays as well, or is there an easier way to go around it?
Thank you.
-
AuthorPosts
Find exclusive trading pro-tools on