Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

lost in multi-time-frame ....

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

    lost in multi-time-frame ....

    i'm trying to change the Keltner channel to an indicator that uses 2min data on my volume charts.... i've already done this successfully with an HMA and SMA both having bollinger bands but for some reason i can't understand how to come up with or diff[0] properly ?

    here's what i've tried so far and either get "can't apply indexing to a double" or "High doesn't exist in this context"

    else if (State == State.Configure)
    { AddDataSeries(BarsPeriodType.Minute, 2); }

    else if (State == State.DataLoaded)
    {
    diff = new Series<double>(this);
    emaDiff = EMA(diff, Period);
    emaClose = EMA(BarsArray[1],Period);
    }
    }
    protected override void OnBarUpdate()
    {

    /// diff[0] = High[0] - Low[0]; /// ORIGINAL;

    /// diff[0] = High[1][0] - Low[1][0]; ///// nope indexing
    /// diff[0] = BarsArray[1]High[0] - BarsArray[1]Low[0]; //// not working either indexing

    diff = High (BarsArray[1])[0] - Low (BarsArray[1])[0]; //// High doesn't exist in this context

    double middle = emaClose[0];
    double offsetOne = emaDiff[0] * OffsetOne;
    double offsetTwo = emaDiff[0] * OffsetTwo;

    double upper = middle + offsetOne;
    double lower = middle - offsetOne;
    double upper2 = middle + offsetTwo;
    double lower2 = middle - offsetTwo;

    Midline[0] = middle;

    if ( PlotBands1 )
    { Upper[0] = upper;
    Lower[0] = lower; }

    if ( PlotBands2 )
    { Upper2[0] = upper2;
    Lower2[0] = lower2; }

    it seems to me that there shouldn't be any difference between the original argument and the one with [1][0] in it. What am i missing ?
    i also tried the argument in the State.DataLoaded section with the same results...
    thanks,
    w

    #2
    Hello stafe ,

    I believe you are just missing the spelling here, the multi series Series<T> objects are all plural such as Highs or Lows.

    If you wanted to do the equivalent of the original diff it would look like this:


    Code:
    /// diff[0] = High[0] - Low[0]; /// ORIGINAL;
    
    
    /// diff[0] = Highs[0][0] - Lows[0][0]; /// Multi-ORIGINAL;
    
    
    /// diff[0] = Highs[1][0] - Lows[1][0]; /// Secondary

    As a side note it looks like you are currently allowing this logic to calculate for the Primary and Secondary. If you meant to isolate this to a specific serires and its frequency be sure to use a BarsInProgress condition. if(BarsInProgress == 0) { }




    I look forward to being of further assistance.

    Comment


      #3
      ok, whew, , , thought i was losing it more than i was... it's just like Plot vs Plots calls... 'doh

      and i'm understanding that if i want the logic to apply only to the secondary bar series (2min) i would wrap the logic in - - if(BarsInProgress == 1) { indicator logic }

      Comment


        #4
        Hello stafe,

        Yes that is correct, if you want to isolate logic that would be the BarsInProgress property. All the indexes are 0 based so 0 would be the primary and 1 the secondary.


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        41 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X