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 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 Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,789 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X