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

Multi-Time-Frame Strategy

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

    Multi-Time-Frame Strategy

    Hello, I am wondering if I could do this in NinjaTrader:

    Basically I want to add different time frame in my automated trading strategy along with some indicators for those time frames ( SMAs in this case)

    I did a backtesting on this strategy, it seems to give some crazy results.

    Code:
    protected override void Initialize()
            {
    			 // Trading frame
                Add(PeriodType.Tick, 144);  // BarsArray[1]
    
                // Add a 5 minute Bars object to the strategy
                Add(PeriodType.Minute, 3);  // BarsArray[2]
    
                // Add a 15 minute Bars object to the strategy
                Add(PeriodType.Minute, 10); // BarsArray[3]
    
                // Add a 30 minute bar object to the strategy
                Add(PeriodType.Minute, 30); // BarsArray[4]
    
                // Note: Bars are added to the BarsArray and can be accessed via an index value
                // E.G. BarsArray[1] ---> Accesses the 5 minute Bars object added above
    
                // Add simple moving averages to the chart for display
                // This only displays the SMA's for the primary Bars object on the chart
                Add(SMA(BarsArray[1], 15));
                Add(SMA(BarsArray[1], 89));
    
                Add(SMA(BarsArray[2], 20));
                Add(Stochastics(BarsArray[2],7,14,3));
    
                Add(SMA(BarsArray[3], 20));
                Add(Stochastics(BarsArray[3],7,14,3));
    			
                CalculateOnBarClose = false;
            }

    #2
    negativezero, that can be done with NinjaScript, however you would need to be mindful about the OnBarUpdate() then be called for each bars object added if you don't take care to filter them through BarsInProgress -



    BarsArray will only let you define what bars object data to use, but not when to do this call, so the event timing.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Taddypole, 04-26-2024, 02:47 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Eduardo  
    Started by futtrader, 04-21-2024, 01:50 AM
    6 responses
    58 views
    0 likes
    Last Post futtrader  
    Started by sgordet, Today, 11:48 AM
    0 responses
    4 views
    0 likes
    Last Post sgordet
    by sgordet
     
    Started by Trader146, Today, 11:41 AM
    0 responses
    5 views
    0 likes
    Last Post Trader146  
    Started by jpapa, 04-23-2024, 07:22 AM
    2 responses
    19 views
    0 likes
    Last Post rene69851  
    Working...
    X