Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling Pivot Points

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

    Calling Pivot Points

    Hello,

    I’d like to incorporate Pivot Points (R1,R2,R3,PP,S1,S2,S3) from the standard Ninja Pivot indicator into my strategy.
    For example, if a bar touches S1, do this
    What’s the right syntax to call S1?

    If (Low [0] <= “S1” && High [0] >=”S1”, do this)

    I put “S1” in quotation marks as I don’t know how to correctly call it.

    Any pointer would be much appreciated.
    Last edited by laocoon; 11-21-2021, 03:39 PM.

    #2
    Hello laocoon,

    Thanks for your post.

    In your strategy, you would add a private instance of the Pivots indicator. private Pivots Pivots1;

    In State.DataLoaded you would initialize the private instance.

    else if (State == State.DataLoaded)
    {
    Pivots1 = Pivots(Close, PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20); // using daily bars
    }


    In OnBarUpdate() you would create the condition using, in this example the S1 pivot.

    if (CrossAbove(Close, Pivots1.S1, 1))
    {
    // do something
    }



    NOTE: the above code examples were generated by using the Strategy Builder. That is a convenient way to find out how to code something, by creating the condition in the Strategy Builder and then clicking view code to see the code generated. You can then copy and paste the code into your script.

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello laocoon,

      Thanks for your post.

      In your strategy, you would add a private instance of the Pivots indicator. private Pivots Pivots1;

      In State.DataLoaded you would initialize the private instance.

      else if (State == State.DataLoaded)
      {
      Pivots1 = Pivots(Close, PivotRange.Daily, HLCCalculationMode.DailyBars, 0, 0, 0, 20); // using daily bars
      }


      In OnBarUpdate() you would create the condition using, in this example the S1 pivot.

      if (CrossAbove(Close, Pivots1.S1, 1))
      {
      // do something
      }



      NOTE: the above code examples were generated by using the Strategy Builder. That is a convenient way to find out how to code something, by creating the condition in the Strategy Builder and then clicking view code to see the code generated. You can then copy and paste the code into your script.
      Hello PaulH,

      Thank you very much for your reply.
      I just realised that I posted my question in the Ninja 8 section, but I'm still on Ninja 7.
      Does this make any difference in terms of the code you posted?
      Thanks again & apologies for the confusion.

      Comment


        #4
        Hello laocoon,

        Thanks for your reply.

        As I've already replied to the question from a NinjaTrader8 perspective we will leave this thread in the NinjaTrader8 forums.

        I've created a short video of how, in your ninjascript, you can use the strategy wizards "Condition Builder" to generate the code needed.



        (Note: I started with the Strategy Wizard just to generate a blank script. If you already have a script you can skip that step and in your existing script, right mouse click and select "add condition").

        If you have further questions, please start a new thread in the NinjaTrader7 forums.


        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        90 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        137 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        68 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        120 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        72 views
        0 likes
        Last Post PaulMohn  
        Working...
        X