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

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 geddyisodin, Today, 05:20 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by bmartz, Today, 09:30 AM
    2 responses
    12 views
    0 likes
    Last Post bltdavid  
    Started by f.saeidi, Today, 11:02 AM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by geotrades1, Today, 10:02 AM
    4 responses
    12 views
    0 likes
    Last Post geotrades1  
    Started by rajendrasubedi2023, Today, 09:50 AM
    3 responses
    16 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X