Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Stop Loss issue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Stop Loss issue

    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

    #2
    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.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Torontobluejays, Yesterday, 08:43 AM
    6 responses
    31 views
    0 likes
    Last Post rc5781
    by rc5781
     
    Started by rbeckmann05, Today, 02:33 PM
    1 response
    1 view
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by set2win, 08-04-2021, 09:23 AM
    38 responses
    992 views
    0 likes
    Last Post diglemar  
    Started by ETFVoyageur, Yesterday, 06:05 PM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rbeckmann05, Today, 02:35 PM
    0 responses
    2 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X