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 NullPointStrategies, Today, 05:17 AM
    0 responses
    41 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    64 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X