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 cmoran13, Yesterday, 01:02 PM
          0 responses
          27 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          18 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          160 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          95 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          148 views
          2 likes
          Last Post CaptainJack  
          Working...
          X