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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        54 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        131 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X