Announcement

Collapse
No announcement yet.

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 max1ci6, Today, 02:02 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by junkone, Yesterday, 08:06 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by fscabrera03, Yesterday, 07:27 PM
      1 response
      5 views
      0 likes
      Last Post tradecombine  
      Started by Rad4633, Yesterday, 05:31 PM
      0 responses
      2 views
      0 likes
      Last Post Rad4633
      by Rad4633
       
      Started by litamm89, Yesterday, 03:51 PM
      0 responses
      6 views
      0 likes
      Last Post litamm89  
      Working...
      X