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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    71 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    43 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    25 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    28 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    56 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X