Before I proceed to say that I think something is wrong with the SetStopLoss(), does anyone else run into some difficulties if they try to change your SetStopLoss based on conditions that take place. My conditions are not that difficult and when I try to do anything dynamic with stop-losses, crazy things start to happen:
Here is something very simple that I tried and things started acting up:
I had my original stop-loss set to 15 pips. Once 3 bars have passed and I haven't hit my target, I then proceeded to move my stop-loss to breakeven if I'm already ahead, but didn't hit my profit target yet.
One thing I discovered is that you must have a SetProfitTarget set if you would like to open an order. Sometimes, I don't need to use the profit target function because I just use my dynamic SetStopLoss function instead. I'm assuming that it is something else that is under-the-hood that I don't know about.
When I said some strange is happening, I mean that the code can be acting just right and then I add another condition to it with a SetStopLoss, the strategy stops entering trades.
NOTE: Okay I realized that I can combined two of those if-statements and I will fix that when I clean up my code.
Comment