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 indicator calling plot is giving Close[0]

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

    #16
    Chelsea,
    Is this part of your code:
    Code:
     protected override void OnBarUpdate()
            {
    			if (secondarySeries == null)
    				secondarySeries = new DataSeries(MACD(BarsArray[1], 7, 14, 9));
    equivalent to:
    Code:
    protected override void OnStartUp()
    		{
    secondarySeries = new DataSeries(MACD(BarsArray[1], 7, 14, 9));
    OR
    Code:
    protected override void OnStartUp()
    		{
    secondarySeries = MACD(BarsArray[1], 7, 14, 9);
    ?

    ie in which case I'm assuming I don't need a null check in OnStartUp or a repeated null check in OnBarUpdate?
    Last edited by zeller4; 08-06-2015, 05:54 AM.

    Comment


      #17
      Hello zeller4,

      No it is not the same. There are items that are only readied when OnBarUpdate is first triggered.

      Just give it a try. Add the code to a script and watch the behavior.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Thanks Chelsea,
        I applied to a chart and see what you mean.
        Please answer the following:
        1. If I'm doing this right, I'd like to get the primarySeries also, please check the attached code.

        Code:
        protected override void OnStartUp()
        		{
        			primarySeries = new DataSeries(this, MaximumBarsLookBack.Infinite);
        			_macdavg0 = MACD_Avg_v01(BarsArray[0],7,14,9);
        			_macdavg1 = MACD_Avg_v01(BarsArray[1],7,14,9);
        		}
        AND - in OnBarUpdate BarsInProgress == 0 - (or should it be outside of BIP0?
        Code:
        primarySeries.Set(_macdavg0.Avg[0]);
        2. Is the null check in OnBarUpdate only required for the secondarySeries?

        3. Is there a way to Add() the secondary series to the chart similar to what I did with the primary? Otherwise, see version2 for my strategyplots.

        4. Since I'm trying to get _direction and _signal from the indicator file so I can use with
        Code:
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        		{..._signal.Get(RightmostAbsBar);...
        , I need them to be a DataSeries. Is this correct? Should I make them a plot in the indicator? Or just let them be called in the strategy?

        Code:
        OnBarUpdate:
        if (_direction1 == null)
        				_direction1 = new DataSeries(_macdavg1);
        			if (_signal1 == null)
        				_signal1 = new DataSeries(_macdavg1);
        ...
        _direction0.Set(_macdavg0.Direction[0]);
        				StrategyPlot(0).Value.Set(_direction0[0]);
        				_direction1.Set(_macdavg1.Direction[0]);
        				StrategyPlot(1).Value.Set(_direction1[0]);
        Thank you in advance for your help.
        Kirk
        zeller4
        Attached Files
        Last edited by zeller4; 08-06-2015, 04:08 PM.

        Comment


          #19
          Hello zeller4,

          The primary data series can be initiated the normal way as dataseries are synced with the primary data series by default. These extra steps only have to be taken when you are trying to sync a dataseries to something other than the primary bar series. This doesn't have to be done in OnBarUpdate. (Not OnStartUp for either)

          Below is a link to the help guide on the DataSeries class.
          http://ninjatrader.com/support/helpG...ries_class.htm


          The check for null is so that you only assign the series once in OnBarUpdate. As I've mentioned before this won't work in OnStartUp(). For anything that is already a working dataseries there isn't a need for a check for null because you aren't trying to assign the dataseries object.


          When you mention "Is there a way to Add() the secondary series to the chart similar to what I did with the primary? Otherwise, see version2 for my strategyplots."

          Are you talking about "_macdavg0 = MACD_Avg_v02(7,14,9); Add(_macdavg0);"?

          Is this the code you are referring to?

          Are you trying to add an indicator to a chart using a different dataseries other than the primary?

          That I know of this will not be possible. This is something you should be using a chart template for.

          To have a chart even contain the points to plot on, the secondary data series has to already be added to the chart (and hidden if desired).
          https://www.youtube.com/watch?v=x_6B...140D7&index=29
          Otherwise it will not be possible to even plot for those dataseries even if they exist within the script. (They exist in the script but not on the chart)

          So really, this is something that should be done with a chart template. Plots can only be drawn on a chart for price points that are already on the chart.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by pechtri, 06-22-2023, 02:31 AM
          10 responses
          124 views
          0 likes
          Last Post Leeroy_Jenkins  
          Started by judysamnt7, 03-13-2023, 09:11 AM
          4 responses
          59 views
          0 likes
          Last Post DynamicTest  
          Started by ScottWalsh, Yesterday, 06:52 PM
          4 responses
          36 views
          0 likes
          Last Post ScottWalsh  
          Started by olisav57, Yesterday, 07:39 PM
          0 responses
          7 views
          0 likes
          Last Post olisav57  
          Started by trilliantrader, Yesterday, 03:01 PM
          2 responses
          22 views
          0 likes
          Last Post helpwanted  
          Working...
          X