Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing a Renko Chart in a Multi-Time Frame Strategy

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

    Referencing a Renko Chart in a Multi-Time Frame Strategy

    I’m currently working on a strategy where I use a 50 Renko chart as a filter within another time frame strategy. One of the filters I’m trying to implement is checking if EMA 20 > EMA 50 on the 50 Renko chart as a condition for buy signals.

    Here’s the approach I’ve taken using AddDataSeries():
    • In the OnStateChange() method, under (State == State.Configure), I added:

      AddDataSeries(Instrument.FullName, new BarsPeriod { BarsPeriodType = BarsPeriodType.Renko, Value = 50 });
    • To initialize the EMA indicators for the 50 Renko chart, I added this under (State == State.DataLoaded) of OnStateChange():

      ema20_50Renko = EMA(BarsArray[1].Close, 20);
      ema50_50Renko = EMA(BarsArray[1].Close, 50);
    ​However, I encountered the following error message:

    'Bars' does not contain a definition for 'Closes' and no accessible extension method 'Closes' accepting a first argument of type 'Bars' could be found (are you missing a using directive or an assembly reference?)

    I believe the issue lies in how I’m referencing the data from the Renko chart, but I’m not sure how to proceed.

    Could anyone guide me on how to properly reference the Renko chart and retrieve the correct data to make this filter work?

    Thanks in advance for your help!
    ​​

    #2
    Hello faccipieri,

    Was this strategy created with the NinjaScript Editor?

    May I confirm you have not removed any default using statements?

    May I have a screenshot of the NinjaScript Editor showing the error and the code line specified in the error?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by faccipieri View Post
      ema20_50Renko = EMA(BarsArray[1].Close, 20);
      ema50_50Renko = EMA(BarsArray[1].Close, 50);
      Try this,
      ema20_50Renko = EMA(BarsArray[1], 20);
      ema50_50Renko = EMA(BarsArray[1], 50);​


      See file,
      bin/Custom/Strategies/@SampleMultiTimeFrame.cs

      Comment


        #4
        Btw, if you're dealing specifically with AddDataSeries and Renko bars,
        why are you not using the AddRenko method instead?

        Comment


          #5
          Originally posted by bltdavid View Post

          Try this,
          ema20_50Renko = EMA(BarsArray[1], 20);
          ema50_50Renko = EMA(BarsArray[1], 50);​


          See file,
          bin/Custom/Strategies/@SampleMultiTimeFrame.cs

          It worked! Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by raysinred, Today, 10:32 AM
          1 response
          15 views
          0 likes
          Last Post rockmanx00  
          Started by cbadr, Today, 08:19 PM
          0 responses
          4 views
          0 likes
          Last Post cbadr
          by cbadr
           
          Started by DayTradingDEMON, Today, 07:23 PM
          0 responses
          7 views
          0 likes
          Last Post DayTradingDEMON  
          Started by XXfea, Today, 07:01 PM
          0 responses
          9 views
          0 likes
          Last Post XXfea
          by XXfea
           
          Started by RedPothos, Today, 05:07 PM
          0 responses
          12 views
          0 likes
          Last Post RedPothos  
          Working...
          X