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

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]);
    }
    Paul H.NinjaTrader Customer Service

    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].
        Paul H.NinjaTrader Customer Service

        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
            }
            Paul H.NinjaTrader Customer Service

            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.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,611 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                22 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X