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

indicator values multi vs single timeframe

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

    indicator values multi vs single timeframe

    Hello,

    I was changing my singletime frame to a multitimeframe strategy and I encountered some problems I could note explain. So I wrote the most simple script printing the value of the EMA(34).
    The first script is a single time frame running on a 5 min timeframe.
    Value1=EMA(34)[0];
    Print("Script1"+" "+Value1.ToString()):

    The second script is a multitime frame. The primary timeframe is a 1 min and the secondary timeframe is a 5 min time frame on the same instrument
    if(BarsInProgress==1)
    {
    Value1=EMA(34)[0];
    Print("script2"+" "+Value1.ToString());
    }

    Then I had both scripts running simultaneously on live charts of the dax this morning.

    The outcome of this test is that the values of the EMA's are different.
    To my understanding both ema's should be the same.
    Is there an explanation?
    Last edited by ceesvh; 09-19-2007, 04:53 AM.

    #2
    They should be the same provided that the range settings are the same on the chart. We will run some tests today and report back our findings.
    RayNinjaTrader Customer Service

    Comment


      #3
      Ray,

      Thanks for your quick reply.
      I would like to go a little further
      I have extended the multitimeframe script further. My goal is (I know it will be implemented in the next release) to issue orders from the two timeframes.
      My thought was that the barclose of bar 5 of the 1 min bars should coincide with barclose of the 5min bar. So it is a matter of barcounting of the 1 min bar.

      if(BarsInProgress==0)
      {
      Barcount=Barcount+
      1;
      if( Barcount==5)
      {
      SMA1=EMA(
      34)[0];
      Print(
      "test2a"+" "+"ËMA"+" "+SMA1.ToString());
      }
      }
      if(BarsInProgress==1)
      {
      SMA1=EMA(
      34)[0];
      Print(
      "test2b"+" "+"ËMA"+" "+SMA1.ToString());
      Barcount=
      0;
      }

      My original idea was that these ema's are also the same but they are not the same and differ from the ema in the single timeframe strategy.

      Is it possible to workaround in such a away that it is possible to trade from both timeframes? Apparently the above approach is not the correct one.

      Comment


        #4
        Hi ceesvh,

        I ran tests on your original post, but could not reproduce the problem. Script 1 and Script 2 were printing the same EMA values on my end. Please try my attached strategies and see if they work. I used the simulator on 1sec (primary) and 5sec (secondary) charts. Run Test1 on a 5second chart and run Test2 simultaneously on a 1second chart.

        About your second issue, I believe the EMAs are actually suppose to be different the way your code is setup. Adding the barcounter only tells it to print the EMA(34) of the 1min bars period every fifth 1min bar. It does not tell it to calculate the EMA(34) on a 5min bar spacing. When you call the EMA(34)[0] it is still on the 1min bars and it does its calculations based on 1min. If you wanted to get the 5min EMA while in the 1min BarsInProgress you will need to do something like
        Code:
        EMA(BarsArray[1], 34)[0]
        Attached Files
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by prdecast, Today, 06:07 AM
        0 responses
        3 views
        0 likes
        Last Post prdecast  
        Started by i019945nj, 12-14-2023, 06:41 AM
        3 responses
        60 views
        0 likes
        Last Post i019945nj  
        Started by TraderBCL, Today, 04:38 AM
        2 responses
        17 views
        0 likes
        Last Post TraderBCL  
        Started by martin70, 03-24-2023, 04:58 AM
        14 responses
        106 views
        0 likes
        Last Post martin70  
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        610 views
        0 likes
        Last Post Radano
        by Radano
         
        Working...
        X