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 Balage0922, Today, 07:38 AM
    0 responses
    1 view
    0 likes
    Last Post Balage0922  
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    19 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Working...
    X