Announcement

Collapse
No announcement yet.

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
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      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.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

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