Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting bar mid points

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

    Plotting bar mid points

    Hello,

    I am just starting to learn to program in order to be able to program in NinjaScript.

    I would like to create a simple indicator that plots three bar mid points
    (High + Low)/2
    (Open + Close)/2
    (High + Low + Open + Close)/4

    I managed to do so in TOS (it took three lines)

    I followed the tutorials in the NT7 help file. However, there it looks like there are some syntax changes. The example given in NT7, is "Plot0.Set( .....)". this doesn't seem to work in NT8.

    I believe my problem is with the syntax within OnBarUpdates()
    protected override void OnBarUpdate()
    {
    //Add your custom indicator logic here.
    HLmid = (High[0] + Low[0])/2;
    OCmid = (Open[0] + Close[0])/2;
    ALLmid = (High[0] + Low[0] + Open[0] + Close[0])/4;
    }

    The complete NinjaScript file is attached.

    Thanks in advance!
    Attached Files

    #2
    ayalc,

    Use "[0] =" instead ".Set( .....)"
    for example: HLmid[0] = (High[0] + Low[0])/2;
    instead: HLmid.Set (High[0] + Low[0])/2;
    Bobby Y.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by ayalc View Post
      Hello,

      I am just starting to learn to program in order to be able to program in NinjaScript.

      I would like to create a simple indicator that plots three bar mid points
      (High + Low)/2
      (Open + Close)/2
      (High + Low + Open + Close)/4

      I managed to do so in TOS (it took three lines)

      I followed the tutorials in the NT7 help file. However, there it looks like there are some syntax changes. The example given in NT7, is "Plot0.Set( .....)". this doesn't seem to work in NT8.

      I believe my problem is with the syntax within OnBarUpdates()
      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.
      HLmid = (High[0] + Low[0])/2;
      OCmid = (Open[0] + Close[0])/2;
      ALLmid = (High[0] + Low[0] + Open[0] + Close[0])/4;
      }

      The complete NinjaScript file is attached.

      Thanks in advance!
      In your file, your syntax is wrong even for NT7.

      However in NT8, you assign to DataSeries/Plots directly. "Set" is not just deprecated; it is invalid.
      Code:
      			HLmid[0]	= (High[0] + Low[0])/2;
      			OCmid[0]	= (Open[0] + Close[0])/2;
      			ALLmid[0]	= (High[0] + Low[0] + Open[0] + Close[0])/4;

      Comment


        #4
        Hi,

        Thanks for your support!
        Yes. i realized that the code I posted was wrong even for NT7. I tried many things and finally just posted a stripped down version.

        Your solution worked. I now have my first working indicator!

        I found the help file in NT7 very helpful as examples were given for coding basic indicators and strategies. Those tutorials have not been translated to the NT8 help guide. I highly recommend that you do so as they provide a practical guide rather than just a reference.

        Thanks again!

        Ayal

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        581 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        338 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X