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

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 rocketman7, Today, 09:41 AM
        4 responses
        15 views
        0 likes
        Last Post rocketman7  
        Started by selu72, Today, 02:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by WHICKED, Today, 02:02 PM
        2 responses
        12 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Started by Mikey_, 03-23-2024, 05:59 PM
        3 responses
        56 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Working...
        X