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

accessing OHLC price data from an indicator

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

    accessing OHLC price data from an indicator

    I would like to access OHLC price data from my indicator when the indicator takes an input series other than price data. For instance, if i'm developing an indicator and use OBV() as the input series, then when I call Open[0], High[0], Close[0] etc... from within my indicator, I will receive data from the OBV() input series. In this situation what can I use to access the OHLC of the actual price data?

    I tried using Indicators[0].High[0] from within my indicator and that seemed to work but I don't think that is a stable solution. Is there a better way to do this? Thanks in advance!

    #2
    Hi Tcon111,

    Thank you for you post.

    This is not possible as Open, High, Close and Low are all directly mapped to the Price Data of the instrument.

    What are you using in the script that you feel is giving you OBV values instead of Price?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by tcon1111 View Post
      I would like to access OHLC price data from my indicator when the indicator takes an input series other than price data. For instance, if i'm developing an indicator and use OBV() as the input series, then when I call Open[0], High[0], Close[0] etc... from within my indicator, I will receive data from the OBV() input series. In this situation what can I use to access the OHLC of the actual price data?

      I tried using Indicators[0].High[0] from within my indicator and that seemed to work but I don't think that is a stable solution. Is there a better way to do this? Thanks in advance!
      That would be correct. Those Array structures are always internally created by NT, and so are accessible. However, know that you are probably in unsupported territory.

      Comment


        #4
        Example

        Hello Cal,

        Thanks for the quick reply. For instance, if you create a new indicator with this line of code in the OnBarUpdate():

        Print("High[0]: " + String.Format("{0:0.00}", High[0]) + "; Indicators[0].High[0]: " + String.Format("{0:0.00}", Indicators[0].High[0]));

        Then choose said indicator to be displayed on a chart with OBV() selected for the Data / Input Series option in the parameter dialog, you will see something like this in the output window:

        High[0]: -143.00; Indicators[0].High[0]: 1112.40

        The key is to choose OBV() as the input series to the indicator you created. In this situation the "High[0]: -143.00" on the left is the OBV data which was obtained using High[0] and the "Indicators[0].High[0]: 1112.40" is the price data obtained using Indicators[0].High[0].

        More specifically, I'm trying to create an indicator that can take any dataseries as input and be able to make comparisons with price data in the underlying chart. I need a good way to always be able to access price data no matter the chosen input series. As I'm aware of now, outside of the Indicators[0] trick, price data can only be accessed if it is also the indicator's input.

        Comment


          #5
          Originally posted by koganam View Post
          That would be correct. Those Array structures are always internally created by NT, and so are accessible. However, know that you are probably in unsupported territory.
          Yes, I've had a few crashes using this technique, so I was hoping there was a more stable way to do it.

          Comment


            #6
            Tcon111,

            Thank you for the information.

            Yes, this is because you are passing the OBV() through the input series which is now being used as the data series and the values that the OBV is creating.

            The method you outlined to get the price series will work.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by tcon1111 View Post
              Yes, I've had a few crashes using this technique, so I was hoping there was a more stable way to do it.
              Use try-catch blocks and simply handle the specific exception, but throw others.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              435 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              3 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              18 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by frslvr, 04-11-2024, 07:26 AM
              9 responses
              127 views
              1 like
              Last Post caryc123  
              Started by selu72, Today, 02:01 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Working...
              X