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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        55 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        72 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        38 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        99 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        60 views
        0 likes
        Last Post PaulMohn  
        Working...
        X