Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Double arrow @ CrossAbv/Blw problem

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

    Double arrow @ CrossAbv/Blw problem

    Hi,
    Sometimes for some reason I'm getting double arrows @ CrossAbv/Blw. It does not happen every time there is a cross blv/abv.Seems most of the time I get single arrow as expected but sometimes there are two arrows per single cross right next to each other. If I refresh the screen it removes the second arrow. Please see attached.
    Thank you very much.
    Regards, Art.
    Attached Files

    #2
    Hello Art,

    This is similar to the other thread you have going. Please continue working with us there.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Dbl arrow

      That happens if the condition you set for the arrow is true, false and then true again during the period for the completion of the bar. You need to use a RemoveDrawObject command.

      ex:

      if( line1 > line2);
      {
      draw arrow"upArrow"+CurrentBar...etc
      }
      else if( line1 < line2);
      {
      draw arrow"downArrow"+CurrentBar...etc
      }
      else
      {
      RemoveDrawObject("upArrow" + CurrentBar);
      RemoveDrawObject("downArrow" + CurrentBar);
      }

      Finn Jurbol

      Comment


        #4
        Thank you very much to finnbjurvoll and Ryan!

        Comment


          #5
          Hi,
          Will
          finnbjurvoll suggestion will fix this problem? Is this all that was missed in my code please.
          Thank you very much.

          Comment


            #6
            Hi Art09

            This is how I would programmed your code:

            if(CrossAbove(Stochastics(PeriodD, PeriodK, Smooth),21,1))
            {
            DrawArrowUp("UpArrow"+CurrentBar,true,1,(arrowPos) ,Color.Lime);
            }
            else if(CrossBelow(Stochastics(PeriodD, PeriodK, Smooth),21,1))
            {
            DrawArrowUp("DownArrowArrow"+CurrentBar,true,1,(ar rowPos),Color.Red);
            }
            else
            {
            RemoveDrawObject("UpArrow"+CurrentBar);
            RemoveDrawObject("DownArrow"+CurrentBar);
            }

            regards
            Finn

            Comment


              #7
              Thanks for sharing, finn.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Hi,
                I'm still getting dbl arrows.Calling RemoveDrawObject("upArrow" + CurrentBar); &
                RemoveDrawObject("downArrow" + CurrentBar); after DrawArrow...() remove all arrows. Calling these methods in else as suggested does not work as there is no else, it is only above or below...
                Thank you.
                Art.
                Last edited by Art09; 11-16-2010, 08:02 AM.

                Comment


                  #9
                  Have you simply tried running it with CalculateOnBarClose = true? Would it then work as you expect? The issue would only be seen realtime & in Market Replay, correct?
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hi,
                    I'm running Ninja-Sim mode. The CalculateOnBarClose = true is not what I want. Even if this will work with CalculateOnBarClose = true I will not be able to use it. I'm getting dbl arrow only sometimes and do not know why and refreshing the screen removes that double arrow.
                    Thank you very much.

                    Comment


                      #11
                      Art,

                      If you want to work with COBC = false, then you must custom code the behavior you want for arrow drawing and removal. Finn offered one approach for this, that should work historically as well as real time.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi,
                        What's the custom code can be with Cross Above/Below please? Could you please be specific? What else can I do please?
                        I do appreciate finn's help but it simply does not work. The RemoveDrawObject("upArrow" + CurrentBar); removes all arrows. Besides, I do not really understand how can this work - if (...) then DrawArrowUp... else if ...Down ... else Remove? Where else? There is only up or down. I tried to use finn's suggestion and put Remove in else part or after all arrows are drawn - does not work.
                        Thank you.

                        Comment


                          #13
                          You will have to custom code the removal logic. Since you're running with COBC = false, it's possible for the arrow to draw while the bar is forming, and without proper removal logic it remains. I tested finns snippet and it worked OK here for this purpose.

                          Simplify your code until everything works as you expect, and only add complexity once you've verified behavior.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            Art09
                            There must be something wrong with how you code that. I have been programming indicators for many years, both NT and eSignal. Sorry you can't get it to work.

                            Finn

                            Comment


                              #15
                              Let me explain. Let's say you are trading a 5 min chart, 2 minutes into the 5 minute period your line1 cross above line2 and your script plots an arrow on your chart. 1 minute later the the price gets lower and the line1 goes back below line2 again. The arrow that were plottet on your chart will still be there because the lines did cross. You need to add the code to remove the arrow again because now the condition is no longer true. You need to refresh your chart to remove the arrow, or you can tell NT to remove it if the condition change using RemoveDrawObject.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Skifree, Today, 03:41 AM
                              1 response
                              1 view
                              0 likes
                              Last Post Skifree
                              by Skifree
                               
                              Started by usazencort, Today, 01:16 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post usazencort  
                              Started by kaywai, 09-01-2023, 08:44 PM
                              5 responses
                              603 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              6 responses
                              23 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Pattontje, Yesterday, 02:10 PM
                              2 responses
                              22 views
                              0 likes
                              Last Post Pattontje  
                              Working...
                              X