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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rdtdale, Today, 01:02 PM
    0 responses
    0 views
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by alifarahani, Today, 09:40 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    18 views
    0 likes
    Last Post RookieTrader  
    Started by PaulMohn, Today, 12:36 PM
    0 responses
    5 views
    0 likes
    Last Post PaulMohn  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    40 views
    0 likes
    Last Post love2code2trade  
    Working...
    X