Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting Hi/Lo in BarsArray

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

    Plotting Hi/Lo in BarsArray

    This is for NT7.

    Neutral.Set(EMA(BarsArray[5],30)[0]); This will plot an EMA 30 based on whatever BarsArray 5 represents.

    Now, how can I access the High (or Low) of that EMA?

    I tried

    Neutral.Set (EMA(BarsArray[5], (Low,30) [0] ));
    and also
    Neutral.Set (EMA(BarsArray[5] (Low,30) [0] ));
    and also
    Neutral.Set (EMA(BarsArray[5] (Low,30) ) [0] );

    - but all of them keep giving me an error message when compiling.

    Am I doing something wrong in the placement of the brackets? Or .....? Would appreciate if you could show me how to do it correctly.

    sandman



    #2
    Hello sandman,

    Thanks for your question.

    You would need to calculate the highest high and the lowest low of the EMA by supplying the EMA as the input series the to MAX and MIN indicators. If you are having trouble writing the correct syntax, you can use the Strategy Wizard to generate code that supplying EMA to the MAX and MIN indicators, and click View Code to see the resulting syntax. You can then modify the code so EMA is calculated from BarsArray[5].

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Jim,

      Have never used the strategy wizard. MAX and MIN indicators are also not known to me. So looking up the code that would then be created isn't as simple for me as you might think especially as I am not a programmer.

      I have successfully used:
      Neutral.Set(EMA(Low, 30)[0]);
      Neutral.Set(EMA(BarsArray[5],30)[0]);

      Now I am simply asking if someone can tell me how these two are combined. If you cannot, perhaps another reader here can jump in and help me out.

      sandman


      Comment


        #4
        Hello sandman,

        The Strategy Wizard would be the tool used for non-programmers to create strategies and NinjaScript logic. It also would be the recommended way to get more familiar with C# and NinjaScript so you can perform your own code edits.

        As you are editing code on your own, it will be important to understand the syntax you are writing and the Strategy Wizard can be a very helpful learning tool.

        You may find the resources below helpful for using the Strategy Wizard, working with NinjaScript code, and writing C# syntax. Publicly available resources on C# can also be help to write proper syntax.

        Strategy Wizard 301 - https://www.youtube.com/watch?v=FmBiNYsf1e8

        NinjaScript Editor 401 - https://www.youtube.com/watch?v=sKW1YwXF6IQ

        Basic Programming Concepts - https://ninjatrader.com/support/help...g_concepts.htm

        I am confident if you use the Strategy Wizard to generate syntax, you will see how to combine indicators, and then changing the code generated to use BarsArray[5] will be straight forward.
        JimNinjaTrader Customer Service

        Comment


          #5
          Originally posted by sandman View Post
          This is for NT7.

          Neutral.Set(EMA(BarsArray[5],30)[0]); This will plot an EMA 30 based on whatever BarsArray 5 represents.

          Now, how can I access the High (or Low) of that EMA?

          I tried

          Neutral.Set (EMA(BarsArray[5], (Low,30) [0] ));
          and also
          Neutral.Set (EMA(BarsArray[5] (Low,30) [0] ));
          and also
          Neutral.Set (EMA(BarsArray[5] (Low,30) ) [0] );

          - but all of them keep giving me an error message when compiling.

          Am I doing something wrong in the placement of the brackets? Or .....? Would appreciate if you could show me how to do it correctly.
          Both MIN and MAX calculate their values on a "moving" basis.
          That is, just like a moving average, such as EMA(30), these indicators
          provides their min/max values on "moving" window basis.

          Thus, just like EMA, both MIN and MAX accept a "period" argument.

          For ex, the syntax MAX(High, 50)[0] returns the maximum value of the
          High data series over the last 50 bars. Of course, the period "50" could
          be any number you choose.

          The syntax you're looking for is thus,

          Code:
          Neutral.Set(MAX(EMA(BarsArray[5], 30), 50)[0]);
          Let's break it down a bit,

          First,
          The EMA() can be called with 1 or 2 arguments, but we need to use 2 arguments.
          Similar, MIN and MAX need to be called with two arguments, as well.

          EMA(BarsArray[5], 30) is a DataSeries of a 30 period EMA of the Close values on BIP=5.
          EMA(Closes[5], 30) is the same thing.

          MAX(EMA(BarsArray[5], 30), 50) is a DataSeries of a 50 period moving window of
          maximum values of the above EMA.

          MAX(EMA(BarsArray[5], 30), 50)[0] is the most recent value of the last 50 maximum values.

          Neutral.Set(MAX(EMA(BarsArray[5], 30), 50)[0]) stores the most recent maximum value in
          the DataSeries called Neutral.

          Note how the EMA period of "30" does not need to be the same as the period provided to MAX.
          They can be the same, or not -- it just depends on your needs.

          Make sense?
          Last edited by bltdavid; 02-25-2021, 07:37 PM. Reason: fix typos

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ttodua, Today, 03:05 PM
          0 responses
          2 views
          0 likes
          Last Post ttodua
          by ttodua
           
          Started by TigerKiger, Today, 01:12 PM
          0 responses
          11 views
          0 likes
          Last Post TigerKiger  
          Started by tonynt, Today, 12:46 PM
          0 responses
          5 views
          0 likes
          Last Post tonynt
          by tonynt
           
          Started by ntdev, Today, 12:19 PM
          0 responses
          3 views
          0 likes
          Last Post ntdev
          by ntdev
           
          Started by RubenCazorla, Today, 12:02 PM
          0 responses
          4 views
          0 likes
          Last Post RubenCazorla  
          Working...
          X