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

MTF - Consistent way to update primary based on secondary data

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

    MTF - Consistent way to update primary based on secondary data

    Hello - Can any one help me with the following issue that I am running into in NinjaScript.

    - Primary chart - tick based chart - say 1000 tick chart
    - secondary series - 5 minute gets added as part of the code.

    Flow:
    - Calculate whether current time > 09:00 ( based on 5 minute chart ) and mark the bar(on primary) for which first tick is > 09:00. However the following code - doesn't work as expected due to the limitation of Ninja - where it always process primary series FIRST irrespective of the way the code is written.

    Code:
    Code:
            #region Variables
    		private bool common=false;
    		private int endTime=090000;
            #endregion
    
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
                Overlay = true;
    			Add(PeriodType.Minute, 5);
            }
    
            protected override void OnBarUpdate()
            {
    			if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
    
                if (BarsInProgress == 1 && FirstTickOfBar && !common && ToTime(Time[1]) <= endTime && ToTime(Time[0]) > endTime) 
                {
    				common=true;
    				Print(Bars.Period + ":" + ToTime(Time[0]));
                }
    
    
    	
                // Now is the condition is met - mark the color of the candle as blue 
                //- for this to work - the would expect the secondary series(5 minute) data to be  
               //processed first and then the primary as per this order 
               //- however - it doesn't work like that in Ninja ( irrespective of the code 
               //- it would always process primary first and then secondary series next 
    
                if (BarsInProgress == 0 && FirstTickOfBar && common) 
                {
                                    common=false;
    				BarColorSeries[0] = Color.Blue;
    				Print(Bars.Period + ":" + ToTime(Time[0]));
                }
            }
    At present - I don't get any blue candles for primary. Any solution to this problem at hand?
    Last edited by vking; 08-20-2012, 09:07 AM.

    #2
    Maybe this is a dumb question, but why not just get the time from the primary data series?

    Comment


      #3
      Radical - Thanks for the reply. This code is a very simplified version of what I am trying to do in Ninja.

      - as a slightly expanded framework - I would like to have the High/Low for specific time period using 5 minute timeframe (exactly to the tick) and would like these values to be available to any type of primary chart that I pick. If I base the calculations on the primary chart - these values are NOT going to be accurate - say High/Low for the time range - 09:00 to 10:00 - I can't calculate this if I use 2 hour chart as primary. If I use 5 minute chart to calculate these values - I can use these values for the next 2 hour candle without any issues. I can use any type of chart for primary in that case.

      Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      19 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X