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 StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,966 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    4 views
    0 likes
    Last Post rbeckmann05  
    Started by rhyminkevin, Today, 04:58 PM
    4 responses
    54 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by iceman2018, Today, 05:07 PM
    0 responses
    5 views
    0 likes
    Last Post iceman2018  
    Started by lightsun47, Today, 03:51 PM
    0 responses
    8 views
    0 likes
    Last Post lightsun47  
    Working...
    X