OPEN-SOURCE SCRIPT
Help needed with strategy - Entry is off by 2 candles

Hi,
I'm new to TradingView, and would greatly appreciate some help with figuring out where I'm going wrong with this script.
This is a overly simplified version of what I'm actually trying to do, but hopefully it's easier to see the problem.
Here I'd like to create a Buy signal when the fast moving average crosses over the slow moving average, and Sell when the reverse happens.
If I draw arrows when the condition is met then they are one candle later than expected (probably because I'm using the closing values ??).
That not great, but workable.
My real problem comes when I try turning this into a strategy.
Now the signal only triggers 2 candles after the crossover.
What am I doing wrong here?
Thanks,
Gordon
I'm new to TradingView, and would greatly appreciate some help with figuring out where I'm going wrong with this script.
This is a overly simplified version of what I'm actually trying to do, but hopefully it's easier to see the problem.
Here I'd like to create a Buy signal when the fast moving average crosses over the slow moving average, and Sell when the reverse happens.
If I draw arrows when the condition is met then they are one candle later than expected (probably because I'm using the closing values ??).
That not great, but workable.
My real problem comes when I try turning this into a strategy.
Now the signal only triggers 2 candles after the crossover.
What am I doing wrong here?
Thanks,
Gordon
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.