Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SRLine Failed Level

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

    SRLine Failed Level

    Hi,

    I've an indicator where SRLine is the plot. Let's say the SRLine[0] level fails, I would like the SRLine[1] to be the current SRLine[0] and if SRLine[1] fails I would like to use SRLine[2] to be the current SRLine until a new level forms. Is there a way to do that and is there an example out there?

    Thanks

    #2
    Hello AgriTrdr,

    Can you specify how the 'SRLine[0] level fails'?

    For example do you mean the Close[0] is less than the SRLine[0]?

    if (CurrentBar < 3)
    return;

    if (Close[0] < SRLine[1])
    {
    Print(string.Format("{0} | SRLine[2]: {1}", Time[0], SRLine[2])); // print the SRLine of 2 bars ago
    }​

    else if (Close[0] < SRLine[0])
    {
    Print(string.Format("{0} | SRLine[1]: {1}", Time[0], SRLine[1])); // print the SRLine of 1 bar ago
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes it would be the Close[0] is less than the SRLine[0].

      I see that you've:

      Code:
      if (Close[0] < SRLine[1])
      {
      Print(string.Format("{0} | SRLine[1]: {1}", Time[0], SRLine[2])); // print the SRLine of 2 bars ago
      }​
      
      else if (Close[0] < SRLine[0])
      {
      Print(string.Format("{0} | SRLine[1]: {1}", Time[0], SRLine[1])); // print the SRLine of 1 bar ago
      }
      Would it make sense to print [1] first and then else if [2]? Also, would the plot work as in the example below?

      Code:
      if (Close[0] < SRLine[0])
      {
      SRLine[0] = SRLine[1];
      Print(string.Format("{0} | SRLine[1]: {1}", Time[0], SRLine[1])); // print the SRLine of 1 bar ago
      
      }​
      
      else if (Close[0] < SRLine[1])
      {
      SRLine[0] = SRLine[2];
      Print(string.Format("{0} | SRLine[1]: {1}", Time[0], SRLine[2])); // print the SRLine of 2 bars ago
      }
      
      ​​​​​​​
      Thanks

      ​​

      Comment


        #4
        Hello AgriTrdr,

        The logic first checks Close[0] < SRLine[1] as if this is true, then both conditions are true and if the order was reversed the second condition would never be reached as the first condition was already reached.

        I highly recommend you give both a try to fully understand.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X