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

"Bars Ago" on different timeframes

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

    "Bars Ago" on different timeframes

    I have more than one data series in my strategy and sometimes they are the same instrument, but different timeframes.
    [0] is the first data series on my chart (ES 1000 tick)
    [1] is the first data series added in my strategy under the section
    else if (State == State.Configure)
    {
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Tick, 300, Data.MarketDataType.Last);
    AddDataSeries("NQ 03-24", Data.BarsPeriodType.Tick, 1000, Data.MarketDataType.Last);
    }
    I have a variable MACD1 that is the MACD of the [0] series and
    a variable MACD2 that is the MACD of the [1] series.

    If I write
    (Slope(MACD2.Default, 5, 1)> SomeNumericVariable)
    is that slope calculated using the MACD of the 300 tick series during 4, 300-tick-bars
    or
    is that slope calculated using the MACD of the 300 tick series during 4, 1000-tick-bars of my default series.

    I've been coding assuming the underlined statement is true, - that the # of bars, bars ago, and the indicator of a series go together in concordance.
    Please confirm or set me straight. Many thanks.

    #2
    Hello Berry Trader,

    Thank you for your post.

    The slope is based on the following formula:
    (series[endBarsAgo] - series[startBarsAgo]) / (startBarsAgo - endBarsAgo)


    This means what you have underlined is the case, the slope is calculated using the MACD of the 300 tick series during 4 300-tick bars. You can test this out by adding prints of the Slope value when BarsInProgress is 0 (the primary series) as well as when BarsInProgress is 1 (the 300 tick series) and see that the values are the same:
    Code:
    if (BarsInProgress == 0)
    Print(Time[0] + " BarsInProgress is 0. Slope: " + (Slope(MACD2.Default, 5, 1));
    if (BarsInProgress == 1)
    Print(Time[0] + " BarsInProgress is 1. Slope: " + (Slope(MACD2.Default, 5, 1));
    You could always use Prints as a debugging tool to understand what data points are being calculated if you are unsure. For more information on using prints for debugging:


    Please let us know if we may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thank you.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pibrew, Today, 06:37 AM
      0 responses
      1 view
      0 likes
      Last Post pibrew
      by pibrew
       
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      14 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      11 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Working...
      X