Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

error handling with strategy NON ATM

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

    error handling with strategy NON ATM

    I used a Try and Catch to keep the strategy going but I still get this error in the picture below. This is my logic. Is it the Slippage giving me this error?




    try
    {
    if(Close[0] > Open[0] + 5*TickSize)
    {
    EnterShortStopMarket(nNumberOfSetContracts, nEntryPrice, "Short1");
    SetStopLoss("Short1", CalculationMode.Ticks, 11, false);
    SetProfitTarget("Short1", CalculationMode.Ticks, 10);

    EnterShortStopMarket(nNumberOfContractsRunner,nEnt ryPrice,"Short2");
    SetTrailStop("Short2", CalculationMode.Ticks, 18, false);


    nCount = 0;
    }
    }
    catch
    {

    EnterShort(nNumberOfSetContracts, "Short1");
    SetStopLoss("Short1", CalculationMode.Ticks, 11, false);
    SetProfitTarget("Short1", CalculationMode.Ticks, 10);

    EnterShort(nNumberOfContractsRunner,"Short2");
    SetTrailStop("Short2", CalculationMode.Ticks, 18, false);
    nCount = 0;



    }
    Attached Files

    #2
    Hello ballboy11,

    Thank you for your note.

    I would not expect this to be related to slippage but rather the price at which you first submit your entershortstopmarkets. These orders should be placed below the market. It could be that you are submitting the order at a price so close to the best bid best ask that its being rejected.

    I would suggest adding a print to the script above your EnterShortStopMarket calls,

    Print("nEntryPrice="+nEntryPrice.ToString());
    Print("The Current Bid price is: " + GetCurrentBid());

    If you add those prints and run the script in real time, does it become clear why the orders are being rejected?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X