Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error: There is no market data available to drive the simulation engine

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

    Error: There is no market data available to drive the simulation engine

    So I have the following code in my AddOn to check that there is market data subscription for the instrument before placing the OIF record with ATMStrategy.
    I see in many cases when OIF record is placed it works and in most cases its Filling the Buy Order but rejecting the Target and Stop.
    Attached is the log file extract.

    What can be the reason ?

    try{
    BarsRequest barsRequest = new BarsRequest(NinjaTrader.Cbi.Instrument.GetInstrume nt(instrument), 1);

    // Parametrize your request.
    barsRequest.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 };
    barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");

    // Request the bars
    barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
    {
    if (bars==null || bars.Bars==null || bars.Bars.Count==0)
    {
    // Handle any errors in requesting bars here
    NinjaTrader.NinjaScript.NinjaScript.Log(string.For mat("No Market data subscription hence Order Rejected: {0} Error Code, {1} Error Message, {2} Bars, {3}, {4}",
    errorCode!=null?errorCode.ToString():"Null", errorMessage!=null?errorMessage:"Null", bars!=null && bars.Bars!=null?bars.Bars.Count.ToString():"Null", account, instrument), LogLevel.Error);
    insertOrderForOltp(account, instrument, Action, Quantity, OrderType,0,0,TIF,"",OrderID, "Entry", "Rejected", 0, StrategyTemplate);
    return;
    }
    else
    {
    String fileName = ""+Guid.NewGuid();
    using (System.IO.StreamWriter file = new System.IO.StreamWriter(incomingDir+"\\oif_"+fileNa me+".txt"))
    file.WriteLine(string.Format("{0};{1};{2};{3};{4}; {5};{6};{7};{8};{9};{10};{11};{12}", Command, account,instrument,Action,Quantity,OrderType,"","" ,TIF,OcoID,OrderID,StrategyTemplate,StrategyID));
    return;
    }
    }));
    } catch(Exception ex) {NinjaTrader.NinjaScript.NinjaScript.Log("Error Verifying MarketData Subscription: "+account+" "+instrument+"\n"+ex.StackTrace, LogLevel.Error); }
    Attached Files

    #2
    Hi vivekniwas, thanks for your post.

    The error you are getting means there is no real time data to submit the stop and target orders to. Unfortunately, I can not spend time to debug this. The Addon example on this page requests real-time data and submits orders to a selected instrument, this seems to be what you are wanting to do.

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    173 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    90 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    129 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    208 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    186 views
    0 likes
    Last Post CarlTrading  
    Working...
    X