Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF - Referencing non primary MAX value

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

    MTF - Referencing non primary MAX value

    Hey guys,

    I am trying to reference a MAX() Value on a second time frame, what I have is below but I am getting compile errors. I was wondering if anyone had ideas how to get this working?

    My code is:

    (In Initialize):

    Add(PeriodType.Day, 1);

    Then called on bar update:

    gapSize = MAX(BarsArray[1],High,barsSinceLastHigh + lookBackPeriod)[0] - MIN(BarsArray[1],Low,barsSinceLastHigh + lookBackPeriod)[0];

    The error that I am getting is:
    "No overload method for 'MAX' takes 3 arguments."

    It seems to not like me adding the BarsArray[1], but there is not MAXs so am a bit stuck...

    Thanks!!
    Shane

    #2
    Hi Shane, the bars array would be fine, there's an overload to allow using an IDataSeries as parameter as well. The issue is your other paramters, the MAX would really only take a period input over which to lookback for the highest value in the series. Were you instead perhaps looking to use the Math.Max method from C# where you pass in two parameters and get the higher one returned?

    Comment


      #3
      Hi Bertrand,

      Thanks for your quick reply.

      What I am trying to achieve, is to find the highest high over X periods, and subtract from it the lowest low over Y periods, and store that result as a variable.

      This was working correctly until I added another data series - what I mean is I originally had the strategy working as an daily strategy, but I am now trying to adapt it to be a 1 minute timeframe to get a greater control over entry/exit (with 1 min being the primary and daily being the secondary series).

      Also I had another question, if under OnBarUpdate I use BarsInProgress = 1 to call a method, will that method know the dataseries which it was called within, or do I still have to reference it using BarsArray? Like could I use Close[0] to get the secondary data value or would I have to use Closes[1][0]?

      Thanks again & cheers,
      Shane

      Comment


        #4
        Thanks Shane, I see the issue now. Can you try that snippet below?

        gapSize = MAX(Highs[1], ,barsSinceLastHigh + lookBackPeriod)[0] - MIN(Lows[1], barsSinceLastHigh + lookBackPeriod)[0];

        The methods are sensitive to called context, so Close[0] in BarsInProgress == 1 is the second series close.

        Comment


          #5
          That got it, thanks heaps Bertrand!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          627 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          359 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          562 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          567 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X