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

Creating my own uptick/downtick counter

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

    Creating my own uptick/downtick counter

    I'd like to create my own uptick/downtick counter due to some needs for other custom indicators I am developping .
    Here is the idea :

    "from the open to the close of each Bar ":
    Up=0;
    Dn=0; //reset upticks/downticks
    Value1 = Close[0];
    if (Value1>Close[1])
    Up=Up+
    1;//count upticks
    if (Value1<Close[1])
    Dn=Dn+1;//count downticks

    The thing is I don't know how to translate this idea "from the open to the close of each Bar ". My guess is that I should use the OnMarketData() method but I'm not sure.

    Can anyone help ?



    #2
    Try:
    Code:
    if (FirstTickOfBar)
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      It does not work. Here's what I get :



      and the script :

      protectedoverridevoid OnBarUpdate()
      {
      if (CurrentBar<1)
      return;

      if (FirstTickOfBar)
      {
      Up=
      0;
      }
      Value1 = Close[
      0];
      if (Value1>Close[1])
      Up=Up+
      1;

      Plot0.Set(Up);
      }

      Comment


        #4
        You need to be running with CalculateOnBarClose = false and this will only work in real-time.

        Depending on how you are trying to justify what is an uptick and what is a downtick your logic will not work either. Close[1] refers to the previous bar's close. If you want to compare every tick against the previous bar's close then your logic will work. If you wanted to compare every tick against the previous tick to determine if it is up or down you will need different logic.

        Code that has not been tested.
        Code:
        if (FirstTickOfBar)
        {
             Up = 0;
             Down = 0;
        }
        prevTick = currTick;
        currTick = Close[0];
        if (currTick > prevTick)
             Up++;
        else if (currTick < prevTick)
             Down++;
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I want to compare the previous tick with the incoming tick.
          What logic should I use ?

          Comment


            #6
            The logic I posted in my previous post is for that case.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Sorry but it does not work.
              The only value I get for each bar is 1 .
              My CalculateOnBarClose is set to false. I don't understand...

              Comment


                #8
                This will only work in realtime. There is no way for you to count ticks historically. You don't know what the ticks are doing intrabar on a historical bar.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Will NT7 handle upticks/downticks & Bid/Ask?

                  Not being able to create custom indicator using upticks/downticks or Bid/Ask is really annoying...
                  It's like playing guitar with a missing chord.

                  By the way, when will NT7 be launched ?

                  Comment


                    #10
                    Not sure I follow kuroro13. I just showed you how to do it NT6.5. You need to run it on real-time data.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Quick Question on this....

                      I have the code in and its runs without error. How to I get it to either plot on the chart or print the values on the chart?

                      Thanks

                      Comment


                        #12
                        If you want to plot on the chart you would need to create indicator plots and set those values to the plots. Please see the tutorials in the Help Guide for how to create plots.

                        If you want to print on the chart you can use either DrawText() or DrawTextFixed(). There are examples for these on the Help Guide too.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Without the ability to backtest a tick based strategy, you would have to forward test it for months or years and if you made a change to it, you would have to start forward testing over. There is also no way to optimize it.

                          NeoTicker has a function called "Tick Replay." As long as you have all of the tick data during the backtesting period for an instrument, you can replay the ticks and backtest the strategy. Would it be possible for Ninja to have a Tick Replay function in the future, so tick based strategies can be backtested?

                          Comment


                            #14
                            Hi shane,

                            NinjaTrader has a Market Replay feature. If you have recorded an instrument beforehand you can replay that instrument exactly how it happened live.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Josh,

                              Doesn't IQfeed provide the upTicks and downTicks of a bar directly? Is there anyway to access it,without recalculating them using ninjascript?

                              Does zenfire also provide this information directly? In upcoming Ninja7 release,will this be accessible directly with IQfeed or zenfire?

                              Thanks
                              Commodity_trader

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Karado58, 11-26-2012, 02:57 PM
                              8 responses
                              14,828 views
                              0 likes
                              Last Post Option Whisperer  
                              Started by Option Whisperer, Today, 09:05 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Option Whisperer  
                              Started by cre8able, Yesterday, 01:16 PM
                              3 responses
                              11 views
                              0 likes
                              Last Post cre8able  
                              Started by Harry, 05-02-2018, 01:54 PM
                              10 responses
                              3,204 views
                              0 likes
                              Last Post tharton3  
                              Started by ChartTourist, Today, 08:22 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post ChartTourist  
                              Working...
                              X