It had a parameter box to put in my own stop loss in Dollar value such as 50 = $50 stop loss. Also a time limit to sell the stock which ever hits first.
On demo and simulation is works just fine, but in live trading connected to tdameritrade the stop loss order seems to be generated on ninja and not being sent to ameritrade.
The stop is generated as an oco order.
There is no pending or open order on the ameritrade side.
Attached are screen shots showing the order initialized on ninja but not really sent. So stop losses are going right past the number I put in. Entering orders are working and time limit sell is working so there's no problem with the connection to ameritrade.
here is some of the code for the stop loss.
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
trailstop=false;
TimeInForce = TimeInForce.Day;
IsInstantiatedOnEachOptimizationIteration = true;
Offset = 10;
stoploss=true;
}
else if (State == State.Configure)
{
SetStopLoss("",CalculationMode.Currency, StopLoss,false);
if ( trailstop==false && stoploss ==false &&BarsSinceEntryExecution() >= MinutestoClose )
{ExitShort(quantity);}
// Set 4
if (trailstop==false && stoploss ==false && BarsSinceEntryExecution() >=MinutestoClose )
{ExitLong(quantity);}
Comment