Text Above Candles for Swing High and Swing Low
09/12/2022 at 3:15 PM #20062709/12/2022 at 3:36 PM #20062809/12/2022 at 3:42 PM #20063009/12/2022 at 4:25 PM #20063809/12/2022 at 4:39 PM #20063909/12/2022 at 5:08 PM #20064209/12/2022 at 5:21 PM #20064509/12/2022 at 5:28 PM #20064609/12/2022 at 5:28 PM #20064709/12/2022 at 7:15 PM #200655Swing High Swing Low123456789101112131415xPeriod = 20If High = Highest[xPeriod](High) and High < High and High < High thenSwingHigh = HighDrawArrowUP(BarIndex-1,High+10) Coloured(0,255,0)DrawText("#SwingHigh#", BarIndex-1, High+30,Dialog,Bold,15) Coloured(0,255,0)EndIfIf Low = Lowest[xPeriod](Low) and Low > Low and Low > Low thenSwingLow = LowDrawArrowDown(BarIndex-1,Low-10) Coloured(255,0,0)DrawText("#SwingLow#", BarIndex-1, Low-30,Dialog,Bold,15) Coloured(255,0,0)EndIfReturn
- Find the Highest High over the past 20 periods (the period is adjustable).
- Check if the previous candle makes a lower High than the Highest High.
- Check if the next candle makes a lower High than the Highest High
In principle, they are simple conditions that can possibly be extended with additional conditions for more adjacent candles. There are now three candles involved in a swing and you could expand this to, for example, 5 candles.
Swing Low is the mirror image of Swing High09/12/2022 at 9:05 PM #20066009/13/2022 at 5:30 PM #200725
hi every one hi @JS
I do some modification, but it’s just for learning and helping, what do you think about my code about : ù
– Drawing button, do you think it’s a goods idea, do have some tips ?
– about IF condition, I aded tomuch condition, do you think it’s more helper for prt CPU or more complicated this way ?1234567891011121314151617181920212223242526272829// Atributs :OffsetArrow = nOffsetA * pipsizeOffsetText = nOffsetT * pipsizePipi = pipsize// SwingHigh ConditionC1 = High = Highest[xPeriod](High) and High < High and High < High// SwingLow ConditionC2 = Low = Lowest[xPeriod](Low) and Low > Low and Low > LowIF C1 ThenIF DrawingText ThenDrawText("#SwingHigh#", BarIndex-1, High+OffsetText,Dialog,Bold,15) Coloured(0,255,0)ENDIFIF DrawingArrow ThenDrawArrowUP(BarIndex-1,High+OffsetArrow) Coloured(0,255,0)ENDIFENDIFIF C2 ThenIF DrawingText ThenDrawText("#SwingLow#", BarIndex-1, Low-OffsetText,Dialog,Bold,15) Coloured(255,0,0)ENDIFIF DrawingArrow ThenDrawArrowDown(BarIndex-1,Low-OffsetArrow) Coloured(255,0,0)ENDIFENDIFReturn09/13/2022 at 5:41 PM #200727
other question, I just trayed to use this code on a Daily chat but with Weekly time frame, and I got all the text and the arrow only in the bigining of the chat, how to solve this problem ? I think we have to get the position of weekly candle for draw ?
1 user thanked author for this post.09/13/2022 at 6:33 PM #200733
At first glance I can’t find anything wrong.Try increasing the units up to 5K, or even more.
You should post the ITF file, as some variables are missing, so I can test it thoroughly.
1 user thanked author for this post.09/13/2022 at 7:25 PM #200736
so this the ITF file “Temps – Swing High”, it’s working correctly like on the Photo 01
but this ITF file “Temps – Swing High Weekly” with the instruction in line one with TimeFrame (Weekly) on the Daily chart I have the Photo 02 :1TimeFrame (Weekly)
the Idea it’s just to use the idea of SwingHigh and SwingLow on a daily chart with weekly value