Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cumulative Delta OnEachTick

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

    Cumulative Delta OnEachTick

    When you use the ninjatrader Order Flow Cumulative Delta indicator, you get a bar chart that shows the open, close, high, & low values of the cumulative data. See below pic

    Click image for larger version

Name:	image.png
Views:	71
Size:	17.4 KB
ID:	1320431

    If I want to access the current cumulative delta on each tick as part of my strategy, how would I go about doing that? I tried using barsType.Volumes[CurrentBar].CumulativeDelta and set my strategy to Calculate.OnEachTick but, when i print the Cumulative Delta, it only prints on close of the bar instead of on each Tick. I am looking to get the current cumulative delta value on each tick along with previous bar's cumulative delta (high, low, open, and close values)

    HTML Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public class CumulativeDeltaStrat : Strategy
        {
            private double CurrentCumDelta;
            
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Enter the description for your new custom Strategy here.";
                    Name                                        = "CumulativeDeltaStrat";
                    Calculate                                    = Calculate.OnEachTick;
                    EntriesPerDirection                            = 1;
                    EntryHandling                                = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy                = true;
                    ExitOnSessionCloseSeconds                    = 30;
                    IsFillLimitOnTouch                            = false;
                    MaximumBarsLookBack                            = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution                            = OrderFillResolution.Standard;
                    Slippage                                    = 0;
                    StartBehavior                                = StartBehavior.WaitUntilFlat;
                    TimeInForce                                    = TimeInForce.Gtc;
                    TraceOrders                                    = false;
                    RealtimeErrorHandling                        = RealtimeErrorHandling.StopCancelClose;
                    StopTargetHandling                            = StopTargetHandling.PerEntryExecution;
                    BarsRequiredToTrade                            = 20;
                    // Disable this property for performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration    = true;
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                if(CurrentBar < BarsRequiredToTrade)
                    return;
                
                NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType barsType = Bars.BarsSeries.BarsType as    
                   NinjaTrader.NinjaScript.BarsTypes.VolumetricBarsType;
                
                CurrentCumDelta = barsType.Volumes[CurrentBar].CumulativeDelta;
                Print(Time[0].ToString() + "Cum Delte: " + CurrentCumDelta);
                
                
            }
        }
    }
    
    ​

    #2
    Use Calculate on FirstTickOfBar for Bar Cumulative Delta.

    Comment


      #3
      Hello algospoke,

      The Order Flow Cumulative Delta requires adding a 1 tick series, and updating the indicator each time the 1 tick series updates.

      The help guide provides sample code of how to use this indicator.
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NasdaqAnalytica, Today, 03:33 PM
      0 responses
      1 view
      0 likes
      Last Post NasdaqAnalytica  
      Started by jamesbhardwaj, Today, 04:41 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by diorfo, Today, 12:48 PM
      5 responses
      23 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by cp202822, Today, 01:38 PM
      2 responses
      13 views
      0 likes
      Last Post cp202822  
      Started by birdog, Today, 06:25 AM
      2 responses
      16 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X