Hello,
Hello, I have 2 requests which I was hoping the community could help with…….
1. Please see the attached png. This shows the indicator called “ATR _ stop”. Please can you check the colours as the coloured point changes colour 1 bar late (I have inserted the code used below).
// Période
p = 10
// Average True Range X
ATRx = AverageTrueRange[p](close) * 3.0
// ATRts = ATR Trailing Stop
// Inversion de tendance
IF close crosses over ATRts THEN
ATRts = close - ATRx
ELSIF close crosses under ATRts THEN
ATRts = close + ATRx
ENDIF
// Cacul de l'ATRts lors de la même tendance
IF close > ATRts THEN
ATRnew = close - ATRx
IF ATRnew > ATRts THEN
ATRts = ATRnew
ENDIF
ELSIF close < ATRts THEN
ATRnew = close + ATRx
IF ATRnew < ATRts THEN
ATRts = ATRnew
ENDIF
ENDIF
return ATRts as "ATR Trailing Stop"
2. My second request is that we create code very similar to above, but what I want is:
a) Data points marked on the price chart 3.0 ATRs above and below the last price where the ATR is 10.
e.g. if current price is 533 and ATR (10) is 40.6, then data point below should be 411.2 [533 – (40.6×3)] and data point above should be 654.8 [533 + (40.6×3)].
Your help is much appreciated!!
:0)
1/ this is the 1st code to color correctly the ATR stoploss line according to up/down Close above/below it as requested:
// Période
p = 10
// Average True Range X
ATRx = AverageTrueRange[p](close) * 3.0
// ATRts = ATR Trailing Stop
// Inversion de tendance
IF close crosses over ATRts THEN
ATRts = close - ATRx
r=0
g=200
ELSIF close crosses under ATRts THEN
ATRts = close + ATRx
r=200
g=0
ENDIF
// Cacul de l'ATRts lors de la même tendance
IF close > ATRts THEN
ATRnew = close - ATRx
IF ATRnew > ATRts THEN
ATRts = ATRnew
ENDIF
ELSIF close < ATRts THEN
ATRnew = close + ATRx
IF ATRnew < ATRts THEN
ATRts = ATRnew
ENDIF
ENDIF
return ATRts coloured(r,g,0) as "ATR Trailing Stop"
For your second query, I understand that you want to draw a channel made of the upper and lower ATR band calculation?
Thanks Nicolas. That is perfect for request 1 :0)
On request 2, yes, an ATR band above and below the last price would be ideal.
I would set the ATR as 10 periods and the bands above and below the the last price to be a multiple of 3.0. Please see the attached chart pic.
Obviously a 3*10ATR band will be quite wide, but each user can adjust their ATR multiple accordingly. They can also adjust their ATR period.
Many thanks for your assistance!
So it would not be displayed like the ‘supertrend’ style? Because even if it uses ATR, it is not updating each candle with the current ATR value.
I think you are talking about ATR bands: https://www.prorealcode.com/prorealtime-indicators/multiple-atr-bands/
Yes different from supertrend but the ATR bands look like they will do the job. Thanks!