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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        66 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X