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

Plotting arrows on indicator problems

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

    #16
    Thanks Jim,

    Will using < > allow an arrow to form the instant it is above or below a band? I am worried that using < > instead of CrossAbove/Below may cause a delay in the arrow being produced.

    Thank you,
    Chris

    Comment


      #17
      Hello chrisca,

      If the condition becomes true during an OnBarUpdate() iteration, that's when the arrow will be made. There would not be a delay in the conditions becoming true and the arrow drawing. It just comes down to if the conditions are true at during that OBU iteration.

      Adding debugging prints to watch these values and conditions as the code executes is the best way to confirm you have your logic written appropriately. I highly advise to set up your draw arrow using simple greater than/less than conditions, adding debugging prints, and then modifying the logic from there to get your desired result.

      Please let me know if you have any questions.
      JimNinjaTrader Customer Service

      Comment


        #18
        Thanks Jim,

        I'll give those a shot.

        Is there anyway you could guide me in the right direction for what i should include in the debugging prints and where they should go? I have zero experience debugging so any info will be helpful. I have tried following tutorials and watching videos on debugging, but it does seem to help my cause much.

        Also, one last problem I have is that arrows occasionally seem to disappear, or not appear at all if I switch charts. While watching a chart where an arrow should have formed, I will either have to switch to another chart and switch back, or reload ninjascript in order for the arrow to appear. Any solution ideas to this?

        Thanks Jim,
        Chris
        Last edited by chrisca; 01-26-2018, 10:29 AM.

        Comment


          #19
          Hello chrisca,

          We have mentioned that NinjaScripts running on Calculate.OnEachTick will only process for each tick when in realtime data. While in historical data, the NinjaScript will run off of Calculate.OnBarClose. Tick Replay can be enabled so NinjaScripts can process historical data with each tick.

          Because of this, if the strategy calculates realtime data with each tick and draws an arrow then, it would not mean the same arrow would appear when the strategy processes historical data on a reload or change of a chart.

          Example prints that may be useful to you:
          Code:
          protected override void OnBarUpdate()
          {
          	Print("");										// Create a new line in the output window
          	Print("State: " + State);						// Print if we are processing Historical or Realtime Data
          	Print("CurrentBar: " + CurrentBar);				// Print the CurrentBar index for the iterating bar. 
          	Print("IsFirstTickOfBar: " + IsFirstTickOfBar);	// Print if this is a tick of a new bar (Relevant for Calculate.OnEachTick) 
          	Print("Close: " + Close[0]); 					// Print the first value used in our condition
          	Print("Open: " + Open[0]);						// Print the second value used in our condition.
          	
          	if(Close[0] > Open[0])
          		Draw.Dot(this, "tag"+CurrentBar, true, 0, Close[0], Brushes.White);
          }
          These prints can be viewed in a NinjaScript Output Window. You may reference the help guide for more information on these items.

          Additional information on debugging can be found here: https://ninjatrader.com/support/foru...ead.php?t=3418

          Please make sure to take these steps when writing your code so you know exactly how to modify your logic and achieve your desired results.

          Information on developing for Tick Replay can be found here: https://ninjatrader.com/support/help...ick_replay.htm

          If you would like, we can also have a member of our Business Development team reach out with information on NinjaScript Consultants who would be happy to debug the code for you can write any code at your request. If that is the case, please let me know.
          JimNinjaTrader Customer Service

          Comment


            #20
            Jim,

            As for the < > logic to plot arrows, I have noticed that an arrow will be plotted if price forms a tail close to the Bollinger Band level, then pulls away from the band, causing the band to be pulled over the tail. This is causing a 'false' arrow as price didn't actually cross the band, ultimately, creating an arrow at the wrong time. I would like the arrow plotted the instant price moves to the other side of the band. Is there a way to prevent this 'false' arrow from forming?

            Thank you,
            Chris

            Comment


              #21
              Hello chrisca,

              What do the prints tell you about the occurrence that gave you your false arrow?

              If the conditions which made the arrow were true, and you feel the arrow should not have been plotted, you would then need to add further logic so your arrow draws only when you want it and any exceptions are made to not draw the arrow.
              JimNinjaTrader Customer Service

              Comment


                #22
                Jim,

                By price pulling the band over the tail (low), the condition became true, even though it technically wasn't. How would I add logic to make sure that the current price causes the arrow, and not the price pulling the band? I honestly wouldn't even know where to begin.

                Thanks,
                Chris

                Comment


                  #23
                  Hello Chris,

                  Indicators will build off of the data series they are applied to. If you are using Calculate.OnEachTick, the last bar will constantly update with incoming ticks. This is true for indicator plot values as well. It will change and the fact that it changes can create these "false positive" situations.

                  Because the value is developing with Calculate.OnEachTick and could be different when the bar closes, it would not be possible to clearly determine that a tick that changes the indicator plot and the developing bar would be still be true for the bar closes alone.

                  You may wish to look into removing these "false positives" once the bar has closed using RemoveDrawObject().

                  RemoveDrawObject() - https://ninjatrader.com/support/help...drawobject.htm

                  Please let me know if I can be of further help.
                  JimNinjaTrader Customer Service

                  Comment


                    #24
                    Thanks Jim,

                    I am trying to use the arrow plotted as an order entry point, so a delayed arrow like the 'false positive' gives me a poor entry position. Will using the RemoveDrawObject() only remove the arrow once a new bar has formed, or will it remove the arrow during currentbar?

                    Thanks,
                    Chris

                    Comment


                      #25
                      Hello Chris,

                      RemoveDrawObject() will remove the draw object as soon as it is called. However, the bar will have to close before the arrow can be verified to be underneath the indicator's closing plot value.

                      If it helps to make matters clears, please consider the following:
                      1. Indicator plot and Current Bar update with each tick
                      2. Current Bar moves above indicator plot and initiates CrossOver
                      3. Current Bar moves back beneath the Indicator Plot
                      4. Bar Closes
                      The scenario above describes a false positive where the condition became true, the plot moved and the arrow would look incorrect when it in fact did occur.

                      You will have to either correct false positives and take action after you detect them (after the bar closes,) or rely on bar closes to generate a signal that would not be a false positive.

                      Please let me know if I may be of further assistance.
                      JimNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by trilliantrader, 04-18-2024, 08:16 AM
                      5 responses
                      22 views
                      0 likes
                      Last Post trilliantrader  
                      Started by Davidtowleii, Today, 12:15 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post Davidtowleii  
                      Started by guillembm, Yesterday, 11:25 AM
                      2 responses
                      9 views
                      0 likes
                      Last Post guillembm  
                      Started by junkone, 04-21-2024, 07:17 AM
                      9 responses
                      69 views
                      0 likes
                      Last Post jeronymite  
                      Started by mgco4you, Yesterday, 09:46 PM
                      1 response
                      13 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Working...
                      X