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

Indicator calculating every tick

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

    Indicator calculating every tick

    Hi everyone, I'm new to ninja, so this a may be easy. How to have an indicator to continue update its code. So for example the indicator "CandleStickPattern" that comes with ninja, have two options for calculating the data:
    Calculate on bar close true or false.
    1 - If its set to true it only plots, say a hammer, when the bar closes ;
    2 - If its set to false it plots as soon as a candle have a hammer "shape" .

    Let's assume I have a 5 min chart. The problem with the option 2 is that if a bar at sencond 10 have the shape of a hammer, it will stay as a hammer until the close of that bar and forever, even if the bar closes as an engolfing.
    How is it possible to have that indicator, or any other, updating every tick, so that at second 10 when the bar is a hammer it shows "hammer" and then at second 11 if the bar changes to something that is not a hammer anymore, it does not show, and if next tick it goes back to the hammer shape it shows again?
    If a moving average does that why other indicators that have text or shapes don't?
    Do I have to change the code?

    I'm comming from another platform and trying to rewrite my custom indicators in ninja.
    Thanks for your help.

    #2
    Originally posted by marreta View Post
    Do I have to change the code?
    Yes. If no more hammer, turn the signal off.

    Comment


      #3
      marreta, welcome to our forums - you're correct, this would unfortunately require code changes to adapt handling for a CalculateOnBarClose false environment. I've noted this as potential enhancement for our updated version for this study for the next generation of the platform.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Thanks for the fast reply guys, so how would this be possible through code in version 7? I have no idea where to begin. is it only for shapes and texts? Why this doesn't happen with an EMA, for example?
        This possible enhancement would be available in ninja trader 8?

        Maybe I should change my Nick to "too many questions"!
        Obrigado!

        Comment


          #5
          marreta, no worries. What you see here is a specialty of the drawing object used to indicate the signal, if the condition is nullified > it would not be automatically removed but would need an explicit call to RemoveDrawObject - https://www.ninjatrader.com/support/...drawobject.htm

          Correct, we are considering enhancing this study for NinjaTrader 8, our next major platform update.
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thanks for the link of removing draw object, What I am trying to achieve is having my entry, stoploss and targets ploted automatically in the chart, while the candle is forming. Thats because I'm a visual trader, and will enter or not in a position acording to other facts after my siganls are displayed, so for example if the trade is a long and target is above a resistance, I would not take it.
            In the attached picture is what I have in my other platform. The lines plotted below/above the prices are the exact price that the numbers represent. Note that the lines doesn't cross the hole chart.
            Is it possible to have that in Ninja Trader?
            Any example of similar code for the drawings part?
            Thank you again.


            [IMG][/IMG]
            Last edited by marreta; 09-09-2014, 01:53 PM.

            Comment


              #7
              Originally posted by marreta View Post
              Thanks for the link of removing draw object, What I am trying to achieve is having my entry, stoploss and targets ploted automatically in the chart, while the candle is forming. Thats because I'm a visual trader, and will enter or not in a position acording to other facts after my siganls are displayed, so for example if the trade is a long and target is above a resistance, I would not take it.
              In the attached picture is what I have in my other platform. The lines plotted below/above the prices are the exact price that the numbers represent. Note that the lines doesn't cross the hole chart.
              Is it possible to have that in Ninja Trader?
              Any example of similar code for the drawings part?
              Thank you again.


              [IMG][/IMG]
              You can draw and plot pretty much anything that you want. It is just a matter of specifying what, and then either coding it, or paying someone to code it. After all, it is all just another C# framework.

              Comment


                #8
                That is correct, you code put in your code to draw objects and text at the desired values.
                BrandonNinjaTrader Customer Service

                Comment


                  #9
                  Ok, so I called RemoveDrawObjects, and the result is:

                  If I use "Calculate on bar close - FALSE, it shows only the present one working the way I want, but it removes all the past signals.

                  Now I have a different problem. How to make it work having all the past signals ploted and the present one together?
                  The only solution I came up with was to have two indicators,
                  1 - One with RemoveDrawObjects and "Calculate on bar close - FALSE, that will generate the present signal "blinking", and
                  2 - Another indicator without RemoveDrawObjects but setting "Calculate on bar close - TRUE and having +CurentBar when I assign the object name, that will generate only the past signals.

                  So my question now is: Is there a simple and easy way to accomplish this using just one code (indicator), instead of having two indicator like I did?

                  Thank you again.
                  Last edited by marreta; 09-27-2014, 03:55 PM.

                  Comment


                    #10
                    Hello marreta,

                    Thank you for your response.

                    You can have two indicators running and this would be the simplest method. Or you can essentially have two indicator in one and separate the logic between them using FirstTickOfBar and CalculateOnBarClose = False. Please take a look at the reference sample at the following link for separating the logic in your code: http://www.ninjatrader.com/support/f...ad.php?t=19387

                    Comment


                      #11
                      Cool Patrick.
                      Do you know wich way would consume less resources ( in NT and Pc RAM)? Having two separate indicators, or like you said, blend them together and separate the logic between them using FirstTickOfBar and CalculateOnBarClose = False?

                      Thank you, nice support you guys provide us.

                      Comment


                        #12
                        Hi marreta,

                        The resource usage would be less when running 1 script as there is other resources that are taken by each instance of a script. However, it really isn't going to be much of a difference.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Almost Finished the translation of my indicator, there is only one problem that I'm facing now with RemoveDrawObject. The Dot is removed, but the Text isn't. Is it something wrong with my code?

                          Thank you very much.


                          if (MyConditions)
                          {
                          DrawDot("Dot",false,0,High[0]+(DotOffset * TickSize),Color.Magenta);

                          DrawText("Texto", false, "Texto", 0, High[0]+10 * TickSize, 7, Color.Magenta, textFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
                          }
                          else
                          {
                          RemoveDrawObject("Dot");
                          RemoveDrawObject("Texto");
                          }
                          }

                          Comment


                            #14
                            Hello marreta,

                            I've made a sample to test this but it seems to be working correctly.

                            Attached is the sample.


                            Can you reduce your code down to just enough to reproduce this as I have done?
                            Attached Files
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by marreta View Post
                              Almost Finished the translation of my indicator, there is only one problem that I'm facing now with RemoveDrawObject. The Dot is removed, but the Text isn't. Is it something wrong with my code?

                              Thank you very much.


                              if (MyConditions)
                              {
                              DrawDot("Dot",false,0,High[0]+(DotOffset * TickSize),Color.Magenta);

                              DrawText("Texto", false, "Texto", 0, High[0]+10 * TickSize, 7, Color.Magenta, textFont, StringAlignment.Near, Color.Transparent, Color.Transparent, 0);
                              }
                              else
                              {
                              RemoveDrawObject("Dot");
                              RemoveDrawObject("Texto");
                              }
                              }
                              I would surmise that you must have a typo. That is why many of us avoid using certain letters in identifying strings. Zero and the letter "o", etc

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Started by alifarahani, Today, 09:40 AM
                              6 responses
                              41 views
                              0 likes
                              Last Post alifarahani  
                              Working...
                              X