Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi instrument buysellpressure

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

    Multi instrument buysellpressure

    Hi I am attempting to use the buysellpressure indicator as part of a multi instrument strategy.

    How would one reference this indicator to look for buy pressure on another instrument?

    I have added the instruments in the initialize section but cannot correctly apply barsarray to the indicator inside of a condition statement.

    Thanks

    #2
    Hello brucelevy,

    Thanks for your post.

    The referencing is done much the same as any indicator added to your strategy and the only difference being that you need to reference the added dataseries so that the indicator uses the correct BarsArray as its input.

    Here is an example using GC as the input series:

    At the class level, declare: private BuySellPressure BuySellPressure1;

    In OnStateChange():

    else if (State == State.Configure)
    {
    AddDataSeries("GC 06-18", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    BuySellPressure1 = BuySellPressure(BarsArray[1]);
    }


    In the OnBarUpdate():

    if (BarsInProgress == 1 && BuySellPressure1.BuyPressure[0] > 0)
    {
    Print ("BSP: "+BuySellPressure1.BuyPressure[0]);
    }

    Comment


      #3
      Can a double be used on multi instrument.

      For instance I’ve used onmarketdata to identify buys and sells.

      On my main strategy the double buys or sells is used as an entry condition.

      I’d like to check if the buys > sells on another instrument.

      Can this double variable be used with barsarray?

      Comment


        #4
        Hello brucelevy,

        Thanks for your reply.

        Yes, a double can be used with a barsarray.

        double test = Closes[1][0]; //save the current close of the first added data series, where 1 = BarsArray[1].

        Comment


          #5
          It won’t let me use

          buy[1][0] > sell[1][0]

          I understand how to use Closes[1][0] but this is my own variable and not an indicator or open high low close.

          The buy and sell simply contain accumulated buys or sells of the current bar that I need to apply to another instrument.

          Thanks.

          Comment


            #6
            Hello brucelevy,

            Thanks for your reply.

            In your example: buy[1][0] implies that this is a data series. If buy and sell are only doubles then you would not be able to use indexing.

            I'm not certain what you have coded but if these are indeed just doubles then you would use them like:

            if (BarsInProgress ==1 && Buy > Sell)
            {
            // do something
            }

            Comment


              #7
              Thank you, what exactly does this mean?

              If (BarsInProgress == 1)

              BarsInProgress is equal to true ?
              How does that apply the buys and sells to the other instrument, thank you.

              Comment


                #8
                Hello brucelevy,

                Thanks for your reply.

                In a multi time frame or multi instrument strategy, each time frame or instrument will call the OnBarUpdate(). If you want to restrict an evaluation or sequence of code to run only when called by a particular bars array you can do this with the check of which Bar is in the process of calling the OnBarUpdate(). In the case of the example i provided, if the BarsInProgress is equal to 1, then the code enclosed in the "{}" would be executed. This is an elemental part of a multi time frame or series script coding and you can gain a better understanding by reviewing this section of the helpguide:https://ninjatrader.com/support/help...nstruments.htm BarsInProgress is shown on the first page of that link.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                649 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                574 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                576 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X