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

Using a Manual indicator in a strategy

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

    Using a Manual indicator in a strategy

    Is there a way to use an indicator value that is manually plugged, in a strategy?

    For eg: I want to start tracking VWAP from a point in time (AVWAP). I have the indicator and this will be manually plugged in on the chart.


    If we cant do this, an alternate approach would be start the indicator programmatically, from a point in time. But i have no idea if it can be done, because all indicators have to go in the
    (State.DataLoaded) only.

    Any suggestions would help.

    #2
    You could interact with drawings on the chart e.g. you can have the strategy add the thing, then let you drag it around, and the strategy could read what you did before it takes trades. Or, you could use toolbar buttons to control when ti's active/inactive so you can position the thing then click the button to "activate" the strategy which starts it trading relative to where you dragged the thing.

    Or, you could make the starting point an input parameter, and pass it from the strategy to the indicator when tthe indicator is instantiated.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello GauthamK,

      Thanks for your post.

      To use an indicator within a custom NinjaScript you would need to call the indicator from OnBarUpdate() when you need to access it.

      Using the SMA indicator as an example, you could set up an SMA object in State.DataLoaded and then access the object in OnBarUpdate(). Or, you could just call something like double x = SMA(20)[0]; from OnBarUpdate().

      Below is a link to a forum post with helpful information about getting started with NinjaScript.
      https://ninjatrader.com/support/foru...040#post786040
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        Brandon,

        Thank you but my question is different. I do know how to read the indicator value, if its added in the State.DataLoaded.

        What if i manually add an indicator on the chart, can my strategy get that indicator's value?

        Comment


          #5
          Thank you Bruce.

          Yes, i am looking to interact it that way. Do you have any code samples on how to achieve that?

          Comment


            #6
            Hello GauthamK,

            Thanks for your notes.

            There are no documented/supported methods for accessing indicator information in a NinjaScript strategy for an indicator manually added onto the chart.

            You would have to call the indicator within the NinjaScript strategy as noted in post # 3 to get information from that indicator.

            This forum thread will be open for other community members to share their insights on the topic and possible undocumented code you could use.
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            2 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Started by alifarahani, Today, 09:40 AM
            6 responses
            40 views
            0 likes
            Last Post alifarahani  
            Started by Waxavi, Today, 02:10 AM
            1 response
            18 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by Kaledus, Today, 01:29 PM
            5 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X