I am working on a strategy (with a lot of help from this board, thank you again), where the entry is a market order, and the exit is thru either a SetStopLoss or SetProfitTarget order. I have a structure that now does basically exactly what I want, and has backtested great.
The problem is while running on a Sim account with a live feed. Every once in awhile I will get an error where it will try to submit a sell stop order ABOVE the market, or a buy stop order BELOW the market, and it will terminate the script and close position. I never get any such error or problem in backtesting.
Now, I have tons of print statements in my code. There is only ONE function which calls SetStopLoss. In it:
stopPx = Math.Round((tradedPx + myVar),5);
SetStopLoss(input, CalculationMode.Price, stopPx, false);
Print(Time[0] + " Setting " + (longOrShort ? "Long stop loss = " : "Short stop loss = ")+ stopPx);
So I compute the stopPx, call SetStopLoss, and print stopPx.
Yet, in my last example, it submitted a EURUSD sell stop order @ 1.1627, which was above the market (had just bot 1.1614), while the print output was:
1/15/2015 8:01:00 PM Setting Long stop loss = 1.16056
1/15/2015 8:01:00 PM Setting Long takeProfit = 1.16351
I'm completely confused here. I'm hoping it's a quirk with the Sim account since nothing like this shows up in backtesting.

Comment