Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SAR using High/Low

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

    SAR using High/Low

    Hi,

    I'm trying to build a Strategy where a position will SAR when a prior high or low are taken out. For example if I am Short and the security crosses above the High from x periods ago then I want to Long.

    In this example I am using a simple RSI with 35 and 65 the signal levels. In the Strategy Wizard I am inputting 10 as the 'bars ago' parameter yet the code seems to be ignored when I view it:

    Here is my code:

    // Condition set 1
    if (CrossAbove(RSI(14, 3).Avg, 35, 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(Close, Low, 1))
    {
    EnterShort(DefaultQuantity, "");
    }

    // Condition set 3
    if (CrossBelow(RSI(14, 3).Avg, 65, 1))
    {
    EnterShort(DefaultQuantity, "");
    }

    // Condition set 4
    if (CrossAbove(Close, High, 1))
    {
    EnterLong(DefaultQuantity, "");


    Please advise,

    #2
    Hello Scarlett09,

    I believe you are referring to changing the RSI "Bars Ago" property. When comparing it to a numeric value (double) the strategy wizard will ignore this option because there is only two different overload methods for CrossAblove/CrossBelow and that is:

    CrossBelow(IDataSeries series1, double value, int lookBackPeriod)
    CrossBelow(IDataSeries series1, IDataSeries series2, int lookBackPeriod)

    You may use the "Look back period" under the CrossAbove/CrossBelow inside the Strategy Wizard.

    http://www.ninjatrader.com/support/h...crossbelow.htm

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      If I change Condition sets 2 and 4 to use a 10 "Look back period" I am still receiving the same result. Its as if Conditions 1 and 3 are being followed and Conditions 2 and 4 are being ignored. The revised code is below, please advise.



      // Condition set 1
      if (CrossAbove(RSI(14, 3).Avg, 35, 1))
      {
      EnterLong(DefaultQuantity, "");
      }

      // Condition set 2
      if (CrossBelow(Close, Low, 10))
      {
      EnterShort(DefaultQuantity, "");
      }

      // Condition set 3
      if (CrossBelow(RSI(14, 3).Avg, 65, 1))
      {
      EnterShort(DefaultQuantity, "");
      }

      // Condition set 4
      if (CrossAbove(Close, High, 10))
      {
      EnterLong(DefaultQuantity, "");

      Comment


        #4
        Hello Scarlett09,

        You may import the following strategy that was done in the Strategy Wizard that has the look back period set for Conditions 1 and 3 for the Look Back Period set to 10.

        To Import
        1. Download the attached file to your desktop
        2. From the Control Center window select the menu File > Utilities > Import NinjaScript
        3. Select the downloaded file

        Let us know if that helps out.
        Attached Files
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        639 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        572 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X