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

reference RTH

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

    reference RTH

    I want to reference RTH for the code below instead of the 60 minute candle.

    IsInstantiatedOnEachOptimizationIteration = true;
    LongGradient = 5;
    StopLoss = 28;
    TakeProfit = 100;
    Quantity = 1;
    minutes = 60;
    allowbe = true;
    profitbe = 24;
    offsetbe = 8;
    be_flag = false;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, minutes);
    AddDataSeries(Data.BarsPeriodType.Tick, 1);

    How do I do that?

    #2
    Hello Shiner452,
    Thank you for the post.

    To use different trading hours for an added series you would need to use the AddDataSeries overload that has trading hours:
    Code:
    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)
    If you use that overload keep in mind of the following note:
    If your NinjaScript object is using AddDataSeries() allowing to specify a tradingHoursName, please keep in mind that: An indicator / strategy with multiple DataSeries of the same instrument will only process realtime OnBarUpdate() calls when a tick occurs in session of the trading hour template of all added series. Any ticks not processed will be queued and processed as a tick comes in for all subsequent DataSeries
    .

    https://ninjatrader.com/support/help...ghtsub=adddata

    To reference secondary data you could use Closes[1][0]

    One other item to keep in mind is that you are using a Variable for minutes for AddDataSeries, this is documented to avoid as that can fail in some use cases. It would be suggested to remove the minutes variable and just type in 60 in the AddDataSeries statement.
    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you Jesse! Is there a way to do this on the Strategy Builder?

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      6 responses
      3,290 views
      1 like
      Last Post jgualdronc  
      Started by Touch-Ups, Today, 10:36 AM
      0 responses
      8 views
      0 likes
      Last Post Touch-Ups  
      Started by geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      8 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      24 views
      0 likes
      Last Post halgo_boulder  
      Working...
      X