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

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.

    Paul H.NinjaTrader Customer Service

    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.


        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by geotrades1, Today, 08:33 AM
        4 responses
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Entwaze, 02-19-2024, 07:13 PM
        2 responses
        66 views
        0 likes
        Last Post MalachiHatfield  
        Started by tkaboris, Today, 08:32 AM
        5 responses
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by f.saeidi, Today, 07:07 AM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Philippe56140, 04-27-2024, 02:35 PM
        9 responses
        72 views
        0 likes
        Last Post backtester831  
        Working...
        X