Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop lost and profit target statement will not execute

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

    Stop lost and profit target statement will not execute

    I am a Ninjascript nubie. Will some tell me why this will not work??

    if (Position.MarketPosition != MarketPosition.Long && Slope == 1)
    {
    EnterLong();
    //execute
    BgtAt = GetCurrentAsk();
    BgtSoldAt = BgtAt;
    ProfitTarget = BgtAt + (tprofit * TickSize);
    //tprofit = 10
    StopLost = BgtAt - (slost * TickSize);//slost = 20
    ExitLongStopLimit(BgtAt,StopLost);//will not execute
    ExitLongLimit(ProfitTarget);//will not execute
    tTradeCount = tTradeCount + 1;
    tTickCount =
    0;
    }
    I get no error message

    #2
    Hello Buttermilk,

    Thank you for your note.

    You will want to run Trace Orders in your script to see why these orders are not getting submitted.

    In your initialize() add TraceOrders = true;

    This will print out to the OutputWindow which can be found by going to Tools -> Output Window

    What may be occurring is that the Long position hasn't happened after the EnterLong() is placed thus the ExitLong's are not seeing the long position and getting ignored.
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    144 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    71 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    125 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    79 views
    0 likes
    Last Post PaulMohn  
    Working...
    X