PDA

View Full Version : Stop Loss issue


stefy
01-09-2009, 09:32 AM
Hi Josh

I'm having a small issue with SetStopLoss. I calculate dynamically my Stop Loss and I'm using the following code in OnBarUpdate():

// Stop Loss Long
if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss("Long", CalculationMode.Price, StopLossLong, false);
}
elseif (Position.MarketPosition == MarketPosition.Long
&& Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) > ATR(24)[0])

{
SetStopLoss("Long", CalculationMode.Price, Position.AvgPrice, false);
ExitL = false;
}

I'm copying here a small part of the output file, which is:
Print(Time[0] + " " + Close[0] + " " + StopLossLong + " " + StopLossShort + " " + Position.MarketPosition)

As you can see below, at 12.30 I go Long. At 13.00 the close is 0.8339, while the StopLossLong is 0.8343 (approximated). The Stop Loss doesn't kick in! Why?

Thank you

11/28/2008 12:00:00 PM Entered internal PlaceOrder() method at 11/28/2008 12:00:00 PM: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Long' FromEntrySignal=''
11/28/2008 12:00:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Long' Mode=Price Value=-0.00139086260765518 Currency=0 Simulated=False
11/28/2008 12:00:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Short' Mode=Price Value=0.84 Currency=0 Simulated=False
11/28/2008 12:00:00 PM 0.8356 -0.00139086260765518 0.84 Flat
11/28/2008 12:30:00 PM 0.8351 0.83427542333433 0.8384 Long
11/28/2008 1:00:00 PM 0.8339 0.8342722806954 0.8383 Long
11/28/2008 1:30:00 PM 0.8339 0.834206768999758 0.837193231000242 Long
11/28/2008 2:00:00 PM 0.8305 0.834043986958102 0.837356013041898 Long
11/28/2008 2:30:00 PM 0.8308 0.834042154168181 0.837357845831819 Long

NinjaTrader_Josh
01-09-2009, 09:56 AM
stefy,

You are in a long position. You cannot submit a stop loss order at a price above the market.

I suggest you track out at what price your entry order was filled and what the exact market price was the moment you submitted the stop loss modification.