Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy with Multiple Time Frames

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

    Strategy with Multiple Time Frames

    I have a 3000 tick strategy that has a 10 min and 2 min bars objects added. One of my methods draws triangle up and down when one indicator swings low and high. The swing is defined like this:

    //Low swing
    if(DmREIplusRSISmoothSlow(BarsArray[0],2,7,2)[0] > DmREIplusRSISmoothSlow(BarsArray[0],2,7,2)[1]
    && DmREIplusRSISmoothSlow(BarsArray[0],2,7,2)[1] < DmREIplusRSISmoothSlow(BarsArray[0],2,7,2)[2])
    {
    DrawTriangleUp("rplusrsmooth low swing" + CurrentBar, true, 1, Low[1] + -8 * TickSize, Color.Yellow);
    Print(Time[0].ToString());
    Print(DmREIplusRSISmoothSlow(BarsArray[0],2,7,2)[1]);
    }

    Typical code depicting the present bar higher then previous bar and previous bar lower then 2 bars ago.

    I was getting incorrect results in the way of swings indicated when there was no swing, ie, the oscillator did not conform to the code. After much painstaking work I have proved that if you have multiple bars objects in a strategy where the base object [0] is the 3000 tick and you add a 10 minute bars object [1], you have to stipulate BarsArray[0] for any method or condition that uses the base bars object.

    If I don't stipulate BarsArray[0], the software whacks out and prints signals in error.

    This is contrary to the help for Multi-Time frame examples where it shows using the base bars object and another BarsArray in a statement. The help does not show using BarsArray[0] in the formula when referencing the base bars object.

    Anyhow, finally figured this out and I don't know if NT developers think this is a bug or not but wanted to put this out there.

    The above example code is what fixes it, remove BarsArray[0] and false signals occur. You can reproduce this probably with any oscillator on a tick chart and adding just one BarsArray. You don't even have to use the second BarsArray in a condition or formula, it's mere presence causes the problem.

    NT7 64-bit 7.0.1000.27 version
    Last edited by gdavis74; 05-09-2015, 10:10 PM.

    #2
    Hello gdavis74,

    Thank you for your post.

    You can also use BarsInProgress to check which bars object is being ran, but yes you are correct - when calling an indicator's method in a multiple time frame or instrument script it is best to pass BarsArray as the Input for the primary or any other added series.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    45 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    22 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    14 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    22 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X