• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Spread between S&P cash and futures

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

    Spread between S&P cash and futures

    Hello, I am trying to have a plot calculate the spread value between the S&P 500 cash and futures markets. Though I am having problems getting it to plot as all I get on the indicator panel on my chart is a prompt saying "Calculating..."

    I believe the problem may be because the trading hour templates are different between the instruments. Is that correct? I've included the code below.

    AddPlot(Brushes.Orange, "T");
    }
    else if (State == State.Configure)
    {

    AddDataSeries("ES 12-19", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    AddDataSeries("^SP500", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    }
    }

    protected override void OnBarUpdate()
    {
    Values[0][0] = Closes[2][0] - Closes[1][0];
    }

    Attached Files

    #2
    Hello edmata1109,

    Thank you for the post.

    You may be having an error, can you check the control center log tab?

    For this type of plotting you generally need to do two things which would be:

    Code:
    protected override void OnBarUpdate()
    {
    if(CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1) return;
    if(BarsInProgress != 0) return; 
    Values[0][0] = Closes[2][0] - Closes[1][0];
    }
    This would ensure you have data for all series and that you are only plotting for the primary series.

    Can you check if this assists in getting the indicator plotting?

    As an alternative, try adding different time frames of the same instrument and add a Print instead of plotting. This would just help to confirm if one instrument is failing to load.


    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 10-21-2019, 07:25 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,

      Adding the CurrentBars and BarsInProgress objects allowed it to plot. Thank you for your help.

      Edgar

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CiprianV, Today, 03:11 AM
      0 responses
      2 views
      0 likes
      Last Post CiprianV  
      Started by learningnt, Yesterday, 10:21 PM
      0 responses
      3 views
      0 likes
      Last Post learningnt  
      Started by GMiller64, Yesterday, 01:13 PM
      3 responses
      10 views
      0 likes
      Last Post GMiller64  
      Started by itrader46, Yesterday, 12:51 PM
      5 responses
      43 views
      0 likes
      Last Post rithikanth  
      Started by hemlock, Yesterday, 11:45 AM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Working...
      X