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

EMA of Cumulative Delta

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

    EMA of Cumulative Delta

    Hello,

    Any examples for ema of cumulative delta indicator. This is not working. Any help appreciated.

    public class
    private OrderFlowCumulativeDelta OrderFlowCumulativeDelta1;
    private EMA OFEMA;

    DataLoaded
    OrderFlowCumulativeDelta1= OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Type.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDelta Period.Session, 0);
    OFEMA = EMA(OrderFlowCumulativeDelta1.DeltaClose, 9);

    BarUpdate
    if (OFEMA[0] <= OrderFlowCumulativeDelta1.DeltaClose[0])
    Draw.TriangleUp(this, @"Up"+CurrentBar, false, 0, (Low [0] - (9 * TickSize)) , Brushes.Lime);

    #2
    Hello rcmcd,

    Thank you for the post.

    I wanted to check, is this the complete syntax you have used currently? If so, you are missing some elements that would be needed.

    I created a quick sample that has two plots to visualize the indicators. You are currently missing the AddDataSeries from what you provided so you are likely seeing an error in the log:
    A hosted indicator tried to load additional data. All data must first be loaded by the hosting NinjaScript in its configure state.
    Or possibly some other error as I don't have a complete sample to compare here. You may also be getting a data error if you try to access the series before both load or try to plot as I have:
    You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.


    The following does plot and shows a difference in the plotted values, one being the cumulative delta and one the EMA delta.

    Code:
    private OrderFlowCumulativeDelta OrderFlowCumulativeDelta1;
    private EMA OFEMA;
    protected override void OnStateChange()
    {
    	if (State == State.SetDefaults)
    	{
    		AddPlot(Brushes.Red, "normal");
    		AddPlot(Brushes.Red, "ema");
    	}
    	else if (State == State.Configure){
    		AddDataSeries(BarsPeriodType.Tick, 1);	
    	}
    	else if (State == State.DataLoaded)
    	{
    		OrderFlowCumulativeDelta1= OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaType.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaPeriod.Session, 0);
    		OFEMA	= EMA(OrderFlowCumulativeDelta1.DeltaClose, 9);
    	}
    }
    
    protected override void OnBarUpdate()
    {
    	if(CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
    	Values[0][0] = OrderFlowCumulativeDelta1.DeltaClose[0];
    	Values[1][0] = OFEMA[0];
    }
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      First- than you so much!

      Second-I would like to plot on price chart on ema9.

      Would values be
      Values[0][0]= EMA(9)
      ?

      Comment


        #4
        Hello rcmcd,

        In this case, you almost have it, you are just missing the BarsAgo at the end of the EMA(9).

        Code:
        EMA(9)[B][0][/B]
        You can find all of the system indicators syntax in the help guide at the following link:


        The EMA: https://ninjatrader.com/support/help...onential_e.htm

        You are setting the first added plot using Values[0][0] if that is what you are intending.





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

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello rcmcd,

          Thank you for the post.

          I wanted to check, is this the complete syntax you have used currently? If so, you are missing some elements that would be needed.

          I created a quick sample that has two plots to visualize the indicators. You are currently missing the AddDataSeries from what you provided so you are likely seeing an error in the log:

          Or possibly some other error as I don't have a complete sample to compare here. You may also be getting a data error if you try to access the series before both load or try to plot as I have:




          The following does plot and shows a difference in the plotted values, one being the cumulative delta and one the EMA delta.

          Code:
          private OrderFlowCumulativeDelta OrderFlowCumulativeDelta1;
          private EMA OFEMA;
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          AddPlot(Brushes.Red, "normal");
          AddPlot(Brushes.Red, "ema");
          }
          else if (State == State.Configure){
          AddDataSeries(BarsPeriodType.Tick, 1);
          }
          else if (State == State.DataLoaded)
          {
          OrderFlowCumulativeDelta1= OrderFlowCumulativeDelta(Close, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaType.BidAsk, NinjaTrader.NinjaScript.Indicators.CumulativeDeltaPeriod.Session, 0);
          OFEMA = EMA(OrderFlowCumulativeDelta1.DeltaClose, 9);
          }
          }
          
          protected override void OnBarUpdate()
          {
          if(CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
          Values[0][0] = OrderFlowCumulativeDelta1.DeltaClose[0];
          Values[1][0] = OFEMA[0];
          }
          I look forward to being of further assistance.


          Thanks Jesse, very helpful example.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by gravdigaz6, Today, 11:40 PM
          0 responses
          4 views
          0 likes
          Last Post gravdigaz6  
          Started by MarianApalaghiei, Today, 10:49 PM
          3 responses
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by XXtrader, Today, 11:30 PM
          0 responses
          4 views
          0 likes
          Last Post XXtrader  
          Started by love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          9 views
          0 likes
          Last Post funk10101  
          Working...
          X