Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why my newly created indictor can not be plotted

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

    #16
    Hello plant,

    Thanks for your notes.

    Since kst0 is defined as a regular double variable it will only hold a single value that is assigned to it.

    Simple Moving Average (SMA) is calculated by summing the prices of the series for a period of time and then dividing this total by the number of time periods.

    For example, SMA(KSTline, siglen) would be the simple moving average calculated by summing the KSTline series for a period of time (siglen) and then dividing this by the total number of time periods.

    I have attached a simple example script demonstrating assigning a value to a plot, and then using that plot Series for calculating SMA() and assigning that value to a second plot.

    The script assigns the Close price to the first plot called 'ClosePlot'. Then we assign SMA(ClosePlot, 3)[0] to the second plot called 'SMAClosePlot'. The script also calculates and prints out the values being calculated for SMA(ClosePlot, 3)[0] which is (ClosePlot[0] + ClosePlot[1] + ClosePlot[2])/3.

    When we run this script, we can see the print values match the plot value on the chart (Seen in blue). I attached an image demonstrating this.​
    Attached Files
    <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


      #17
      Got it. Thank you Brandon! With your help I was able to create my first indicator, now I started my Ninja script Journey.

      Comment


        #18
        Hello harryd,

        Thanks for your notes.

        In the code you shared I do not see the public properties that you are referring to.

        So I may accurately assist, could you please provide the full code of the script so I may take a look.

        To export a script to share, go to Tools > Export > NinjaScript AddOn.

        Note that if you are referring to the public properties for the plots, these would need to remain as public properties since they are using for the AddPlot() methods in the script.

        To assign a value to the first plot, you would need to do something like Values[0][0] = X, where X is the value you want to assign to the first plot.

        To assign a value to the second plot, you would need to do something like Values[1][0] = X. To assign a value to the third plot, you would need to do something like Values[2][0] = X.

        See the AddPlot() help guide page here for more information on AddPlot() and sample code: https://ninjatrader.com/support/help...t8/addplot.htm

        And, see this help guide page about Values: https://ninjatrader.com/support/help...nt8/values.htm

        "I also don't understand what the 1 does in SMA(ATR(Period),1)[0]."

        The 1 in this code would be the period parameter of the SMA system indicator method.

        See this help guide page about SMA(): https://ninjatrader.com/support/help...simple_sma.htm
        <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


          #19
          [QUOTE=NinjaTrader_BrandonH;n1283843]Hello harryd,

          In the code you shared I do not see the public properties that you are referring to.


          I am all set now. I received an email from Jesse today and mentioned what I mentioned in my previous post here, that the bands were working fine but were working with public, whereas I wanted to use private. Jesse informed me I do not have that choice. I am back to public. Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          62 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X