Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninja Script Issue

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

    Ninja Script Issue

    Hello

    I've developed a very simple strategy that plots

    -a dot below a green candle (n) if the previous candle (n-1) was red
    -a dot above a red candle (n) if the previous candle (n-1) was green

    The dot is automatically removed if the next candle (n+1) doesn't make a tick higher than the high of (n) (for longs) or a tick lower than the low of (n) (for shorts).

    The code is attached below and it works on many candles that meet the criteria but not on all. I'm at a loss on why it is behaving like that.

    Any suggestions on how to fix this issue are very welcome.

    Thanks
    Attached Files

    #2
    laocoon, it might be due to your 'if then else if' structuring used - I would suggest to simplify it by commenting out the 'removal' parts and then first checking if your draw dot conditions are triggering as you would expect.

    Comment


      #3
      Bertrand,

      Thanks for your reply. It seems to be working if I comment out the "removal part" as you suggested. Can I ask you how to structure the "if then else" loop to be able to keep the "removal part" ?

      The thing that got me wondering was the fact that the original code works on many occasions but not on all.

      Thanks a lot.

      Comment


        #4
        I would suggest you don't start the Short condition in the lower part of the code with an 'else if', just use regular 'if' here.

        Comment


          #5
          perfect, thanks a lot Bertrand.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X