Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Address multiple timeframes in one script

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

    Address multiple timeframes in one script

    When addressing multiple timeframes, do all those timeframes need to be loaded into a single chart before running the strategy?
    I currently have a script that addresses these instruments
    else if (State == State.Configure)
    {
    AddDataSeries("NQ 03-24", Data.BarsPeriodType.Tick, 300, Data.MarketDataType.Last);
    AddDataSeries("NQ 03-24", Data.BarsPeriodType.Tick, 1000, Data.MarketDataType.Last);
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Tick, 300, Data.MarketDataType.Last);
    AddDataSeries("ES 03-24", Data.BarsPeriodType.Tick, 1000, Data.MarketDataType.Last);
    }


    So NQ 03-24 300 tick is index 0.
    NQ 03-24 1000 tick is index 1, etc...

    Further down I define a MACD for the first two intruments
    MACD1 = MACD(Closes[0], 12, 26, 9); <--- this is the MACD for NQ 300 tick
    MACD2 = MACD(Closes[1], 12, 26, 9); <--- this is the MACD for NQ 1000 tick

    ​Then I use these MACD's in my code in an attempt to paint the background light green when the NQ1000 MACD is Positive and rising.
    if ((MACD2.Avg[0] >= 0)
    &&(MACD2.Diff[0] > 0))
    {
    BackBrush = Brushes.Honeydew;
    }

    So If I open an NQ 300 tick chart and enable this strategy (which has other sections that do things depending upon what the 300 tick is doing),
    I get this odd result.
    The background screen is painted according to what the 300 tick MACD is doing, instead of what the 1000 tick MACD is doing as specified.
    No error is thrown.

    What is the best way to proceed?
    Thanks,

    #2
    I added the 1000 tick NQ to my 300 tick NQ chart. The problem is still the same.

    Comment


      #3
      Hello Berry Trader,

      You have the wrong indexes in your sample, the nq 300 tick or first AddDataSeries would be index 1 and then each after would increment by 1. 0 is your chart series. Do you still see a problem if you change the indexes that you are using?

      Comment


        #4
        NinjaTrader_Jesse wrote:
        "0 is your chart series. "
        Ah. Thank you, Jesse.
        So If I have usually have 3 data series on my chart when I load the strategy, Shall I define my strategy data series starting with index [3] ?

        Comment


          #5
          Hello Berry Trader,

          No the script only sees the series you apply it to so that is always series 0, AddDataSeries would start at index 1 always. The additionals series on your chart are completely unrelated to the script.

          Comment


            #6
            Thanks, Jesse. This makes sense to me. I'm looking forward to adjusting my script to see what happens.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            56 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            132 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X