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-timeframe aggregation help

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

    Multi-timeframe aggregation help

    hi guys,

    I have a 4500 tick chart (main data series....BarsInProgress = 0) and added a 1 minute data series to my strategy script (BarsInProgress = 1).

    I simply want to capture and count how many bars from the 1m exceeded volume by a certain level while my 4500 tick data series was still open. Any thoughts and guidance would be greatly appreciated.

    My strategy is set to CalculateOnBarClose = true, so I'm fine with waiting until after the main data series closes.

    -Mike

    #2
    Hello successfulmike,

    Thank you for the post.

    This type of logic could be achieved by using an int, you can see this visually and store its value using a Plot.

    Here is an example of accumulating a value and then plotting it, after being plotted the value is reset. You don't need to use a Plot specifically this is just for demonstration purpose.

    Code:
    int barCount;	
    protected override void Initialize()
    {
        Add(PeriodType.Minute, 1);
        Add(new Plot(Color.Red, PlotStyle.Bar, "Plot0"));
    }
           
    protected override void OnBarUpdate()
    {
    	if(CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
    	if(BarsInProgress == 0)
    	{
    		Value.Set(barCount);			
    		barCount=0;
    	} 
    	else if (BarsInProgress == 1)
    	{
                    //do some volume check in here and increment barCount if criteria matched
    		barCount++;
    	}
    }
    I look forward to being of further assistance.
    Last edited by NinjaTrader_Jesse; 03-25-2017, 10:45 AM.
    JesseNinjaTrader Customer Service

    Comment


      #3
      thanks Jesse, this works perfectly! The only issue that I'm having now is that I'm receiving error when compiling the code where it's not detecting "Value" from that plot line you added. Error says:

      -------------
      Argument '1': cannot convert from 'NinjaTrader.GUI.Chart.Plot' to 'NinjaTrader.Indicator.IndicatorBase'
      The name 'Value' does not exist in the current context
      -------------

      I tested the code by removing the Plot line you added, but I would like to get it working since it does give me a quick visual without relying on the Output Window.

      Thanks for your help. As a reminder, this is a Strategy script not an indicator so I'm not sure if there are other classes that are required but I do have the NinjaTrader.Indicator and NinjaTrader.GUI.CHart class already added.

      Comment


        #4
        Hello successfulmike,

        Thank you for the reply.

        Value is an inherited property of an indicator, the reason for this error is that strategies in NT7 cannot plot. This is a feature that was added in NT8, but you can still accomplish plotting in NT7. A dummy indicator is required. Please see the following example that passes a value from a strategy to a dummy indicator which plots the value: http://ninjatrader.com/support/forum...ead.php?t=6651

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        28 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        20 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        4 views
        0 likes
        Last Post funk10101  
        Started by gravdigaz6, Yesterday, 11:40 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Yesterday, 10:49 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X