I am new on NT and trying to learn how to code strategy on it using C#. I am using the wizard to generate the code so I can than change it and learning doing it.
I tried to develop a strategy (file attached) for a very simple system to use as a learning procedure. What I want it to do is:
1. Enter a long position when you have a green candle after a red candle. The position should be open on the close of the green candle and I think my problem in the code has to do with this.
2. Close the position on next candle close (the day after the entry candle) or close it on a stop loss placed on the previous red candle low.
3. Enter a short position when you have a red candle after a green candle. The position should be open on the close of the red candle.
4. Close the position on next candle close or close it on a stop loss placed on the previous green candle high.
My 1st thought was that this would be an easy exercise but I couldn't do it correctly because when I backtest it I get trades on places I wouldn't expect it. Problems of a beginner...
Can you please show me where I made the mistakes on the strategy development?
I am testing the strategy on $EURUSD using weekly bars from 01-01-2009 until today.
Here's the backtest menu with the parameters I'm using (image attached)
Here are the trades I get using the code I sent you (image(1) attached)
And here are the trades I expected from the strategy for the same period (image (2) attached)
Just to remember the rules so it will be easy for you to understand the previous chart:
1. Long when you have a green candle after a red candle
2. Short when you have a red candle after a green candle
3. Stop loss long is the low of the red candle
4. Stop loss short is the high of the green candle
5. Time stop is the next candle close
Hope someone can give me some help on my learning journey.
Regards,
ACP

Comment