Bellored
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: January 12th, 2021
Contact: TradingView Profile

Need help with Stop loss

Hi my name is Michael and I am trying to backtest a new Forex Strategy.
I am currently stuck with my Strat on the hour chart on the GBP/JPY pair.
I have a fixed Stop loss at 1.5 Atr after entry.
When my first Take profit target at 1.5 Atr is hit, it should set my Stop loss to breakeven and activate my trailing Stop loss.
For my Trailing Stop loss it looks back 7 candles and stops when the highest/lowest (long/short) close is 2 atr apart from the current price.
My take profit target is detected by comparing my strategy.position_size with my entry position size.

I can show you my full script if needed.
I would aprreciate your help and if you want to contact me directly, you can send me an email to: tonkich.michael@gmail.com
Greetings Germany

User avatar
Matthew
Site Admin
Site Admin
Posts: 92
Joined: July 1st, 2020
Location: Australia
Contact: Website Facebook Twitter TradingView Profile

Re: Need help with Stop loss

Hi Bellored! Unfortunately I don't have time to help with your script but maybe someone else here will be able to.

Over on my website I have a new course coming soon that breaks down all of my existing scripts & indicators which includes a strategy script that uses break-even & trailing stops which you could reference.

Otherwise if you don't want to sign up for that then I wish you the best of luck with your script my friend! Let us know how you go :)

Return to “Pine Script Q&A”