Contains two ATR trailing stop lines, fast and slow.
The slow ATR SL line is the same as the one in a normal ATR trailing stop loss indicator.
The fast one is created to generate buy/sell signals (plot arrows on the chart).
The system works well in high volatility market.
(translated from tradingview code, following a request in the Spanish forum).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
//PRC_ATR Trailng Stop v2.1 | indicator //10.04.2018 //Nicolas @ www.prorealcode.com //Sharing ProRealTime knowledge //converted from Tradingview code // --- settings // Fast Trail // AP1 = 5 //"fast ATR period",integer) // ATR Period AF1 = 0.5 //"fast ATR multiplier",float) // ATR Factor // Slow Trail // AP2 = 10 //"slow ATR perod",integer) // ATR Period AF2 = 2 // "slow ATR multiplier",float) // ATR Factor // --- end of settings SC = customclose SL1 = AF1*AverageTrueRange[AP1] // Stop Loss once trail1=sc-sl1 if sc>trail1[1] and sc[1]>trail1[1] then trail1 = max(trail1[1],sc-sl1) else if sc<trail1[1] and sc[1]<trail1[1] then trail1=min(trail1[1],sc+sl1) else if sc>trail1[1] then trail1=sc-sl1 else trail1=sc+sl1 endif endif endif SL2 = AF2*AverageTrueRange[AP2] // Stop Loss if sc>trail2[1] and sc[1]>trail2[1] then trail2 = max(trail2[1],sc-sl2) else if sc<trail2[1] and sc[1]<trail2[1] then trail2=min(trail2[1],sc+sl2) else if sc>trail2[1] then trail2=sc-sl2 else trail2=sc+sl2 endif endif endif ts1 = trail1 ts2 = trail2 if sc>trail2 then rtrail=0 gtrail=255 else rtrail=255 gtrail=0 endif drawcandle(trail1,trail2,trail1,trail2) coloured(rtrail,gtrail,0,50)bordercolor(0,0,0,0) Hst = Trail1-Trail2 Sig = average[9,1](Hst) // Bar color for trade signal // Green = Hst>0 and Hst>Sig Red = Hst<0 and Hst<Sig sBuy = green and not green[1] sSell = red and not red[1] if sBuy then drawarrowup(barindex,ts2)coloured(rtrail,gtrail,0) endif if sSell then drawarrowdown(barindex,ts2)coloured(rtrail,gtrail,0) endif return ts1 style(point,1) as "Fast Trail", ts2 coloured(rtrail,gtrail,0) style(line,2) as "Slow Trail" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
All works in High Volatility Market 😉 Thanks Nicolas and have a nice day
Ich hab mal eine Frage zu deinem Indikator:
Der Einstieg ist ja über die Pfeile geregelt.Ab wann steige ich aus? Bei Short am Ende der roten Linie?
Looking good nicolas, although, after i download it and have it as a indicator, what settings should i put in the wizard so it buys and sells as the indicator shows?
Doesn’t seem to figure out how to do that, thanks 🙂
Add sSell and sBuy in the RETURN instruction and you should be able to use the indicator in automatic trading.
I dont understand what you mean.. the code already has “ssell” and “sbuy”..?
change the RETURN instruction line with this one:
return ts1 style(point,1) as “Fast Trail”, ts2 coloured(rtrail,gtrail,0) style(line,2) as “Slow Trail”, ssell,sbuy
Then you’ll be able to use these last variables in any trading strategies, by looking for their values, 1 means a new signal, 0 means no signal.
Ok, i pressed modify in the indicator, and changed the last return line with that line you sent me. But it’s still an indicator? When i press the wizard to create bot i still have to put in the buy and sell signals, so it still doesn’t work mate
yes it is still an indicator obviously 🙂 But now you can get the signals (ones with arrows) with the “wizard”, mate. Learn to code and no need of wizard things anymore 😉
Start with the first course: https://www.prorealcode.com/courses/training-program-introduction-programming-prorealtime/
the advanced one should come this month.
Oh okay, and how do i tell the wizard to buy and sell accoring to the arrows, because i only see the option to buy and sell when the indicator is under or over the price, thats the problem :p
You can also test values of indicator. Equal or not to 1 for example.
Another question.. is it even needed to learn how to code, even if you seem to have found a good strategy with the wizard? Just because the wizard is simple, doesn’t mean it’s bad.. It’s usually the simple strategies that last good in the long run, just like trading manually, doing over complex shit will not do any good
No, but if you are able to code, you can use any of the codes around here and improve them for your own needs like this is the case for this indicator.
Thank you Nicolas. Nice one 😉
Bonjour Nicolas, je débute et suis intéressé par cet indicateur mais quand je copie/colle le code dans le mode “création d’indicateur” j’ai un message d’erreur : “erreur de syntaxe dans l’assignation” et la dernière ligne est grisée. Merci pour votre aide.
c’est bon çà marche ! j’ai supprimé toutes les lignes vides du dessus
Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Maison je me rappel plus a quel e-mail vous envoyer svp c’est pour un screemer pour les devises time frame 1H merci d’avance
Merci d’utiliser le forum pour les demandes de programmation personnalisée
Les devises unité