Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time Frames-Simple Script Correction

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

    Multi Time Frames-Simple Script Correction

    Can not seem to run any simple strategy involving 2 Time Frames and do not know why.

    Here is my Strategy. I am putting this on a 1 m Chart assuming Primary Bar Object.

    protected override void Initialize()
    {
    Add(PeriodType.Minute,3);
    CalculateOnBarClose = true;
    Enabled=true;
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] <= BarsRequired ||CurrentBars[1] <= BarsRequired)
    return;

    if (BarsInProgress==0)
    {

    if (Closes[0][0] > Opens[0][0])
    {
    if ( Closes[0][0] > Opens[1][0] )
    Print(" Both CandleSticks on my 2 TimeFrames are Green");
    }
    }
    }


    Compiles fine, but can not get anything to print. Played around with BarInProgress many times, even CalculateOnClose too! Maybe did not cover every permutation.

    Just need the language to take data on 2 TimeFrames and put them into conditional statments and get a so called action from them.

    Do I have to wait for 1m Tick and try process that in one statement, keep the answer in a boolean variable, then wait for another 3m Tick, then process that in a conditional statement. Then process both the answers from the 1m & 3m conditional statement into another conditional statement, to have desired action based on both Time Frames?

    #2
    adlane, your code worked fine for me here. Are there any errors in the logs (right-most tab of Control Center)?

    Please take a look at the sample multi-timeframe strategy from Tools -> Edit NinjaScript -> Strategy -> SampleMultiTimeFrame to get a feel for how these MTF strategies/indicators function.

    There is also some more information in the help guide on this topic - http://www.ninjatrader.com/support/h...lightsub=multi.
    Attached Files
    AustinNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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