Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling cumulativeDelta second instrument

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

    Calling cumulativeDelta second instrument

    I have read multiinstrument samples and also cumulativeDelta help. I have tried many combinations and no one works.

    I am trying to code an strategy that uses cumulativeDelta from NQ and also from a secondary serie as MNQ. The lines would be:

    public class NQ60ORMNQ : Strategy
    {
    private OrderFlowCumulativeDelta cumulativeDelta;
    private OrderFlowCumulativeDelta cumulativeDelta1;

    ......

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    DeltaLimit = 75;
    DeltaLimit2 = 115;
    ......

    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Tick, 1);
    AddDataSeries("MNQ 12-20", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    cumulativeDelta = OrderFlowCumulativeDelta(CumulativeDeltaType.BidAs k, CumulativeDeltaPeriod.Bar, 0);
    cumulativeDelta1 = OrderFlowCumulativeDelta(BarsArray[4], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0);
    }
    protected override void OnBarUpdate()

    if (BarsInProgress == 1 && BarsInProgress == 2)
    {
    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
    cumulativeDelta1.Update(cumulativeDelta1.BarsArray[2].Count - 1, 1);
    }

    // Set 1
    if (cumulativeDelta.DeltaHigh[1] > DeltaLimit || cumulativeDelta1.DeltaHigh[0] > DeltaLimit2)

    {
    if (BarsInProgress == 0)
    { "Several Conditions"

    Any idea what is wrong there? How can I call second instrument cumulativeDelta?

    #2
    Hello Impeesa,

    Thanks for your post.

    This section will never be true because only 1 bars object can call OnBarUpdate at a time:

    if (BarsInProgress == 1 && BarsInProgress == 2)
    {
    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
    cumulativeDelta1.Update(cumulativeDelta1.BarsArray[2].Count - 1, 1);
    }


    I would suggest something like:

    if (BarsInProgress == 1)
    {
    cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
    {
    else if (BarsInprogress == 2)
    {
    cumulativeDelta1.Update(cumulativeDelta1.BarsArray[2].Count - 1, 1);
    }


    Also, this statement: cumulativeDelta1 = OrderFlowCumulativeDelta(BarsArray[4], CumulativeDeltaType.BidAsk, CumulativeDeltaPeriod.Bar, 0); References BarsArray[4] which i don't see listed.
    BarsArray 0 will be the chart bars
    BasrArray 1 is AddDataSeries(Data.BarsPeriodType.Tick, 1);
    BarsArray 2 is AddDataSeries("MNQ 12-20", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last);

    Finally, this line, will be run every time OnBarUpdate() is called no matter which series called it.:

    if (cumulativeDelta.DeltaHigh[1] > DeltaLimit || cumulativeDelta1.DeltaHigh[0] > DeltaLimit2)

    I would recommend reading this section of the help guide to better understand Multi timeframe/instrument programming: https://ninjatrader.com/support/help...nstruments.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    42 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X