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 Jonafare, 12-06-2012, 03:48 PM
        5 responses
        3,986 views
        0 likes
        Last Post rene69851  
        Started by Fitspressorest, Today, 01:38 PM
        0 responses
        2 views
        0 likes
        Last Post Fitspressorest  
        Started by Jonker, Today, 01:19 PM
        0 responses
        2 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        8 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,792 views
        0 likes
        Last Post aligator  
        Working...
        X