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

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 rbeckmann05, Yesterday, 06:48 PM
    1 response
    12 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
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    15 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Working...
    X