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 geddyisodin, Today, 05:20 AM
        6 responses
        34 views
        0 likes
        Last Post geddyisodin  
        Started by trilliantrader, Today, 03:01 PM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by pechtri, 06-22-2023, 02:31 AM
        9 responses
        122 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by frankthearm, 04-18-2024, 09:08 AM
        16 responses
        67 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by habeebft, Today, 01:18 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X