Counting Ticks per hour

Posted By: danatrader

Counting Ticks per hour - 10/10/20 21:03

Figured seems not that easy to count upTicks vs. downTicks per Bar and reset counter on every new bar.

Surely, continuesly counting is somewhat easy....

function tick()
{
shift(closeTick, priceClose(), 2); // shift the series

if(closeTick[0] > closeTick[1]){
upTick += 1;
return upTick;
}

if(closeTick[0] < closeTick[1]){
downTick += 1;
return downTick;
}
}


Somebody has an idea to approach that?
Posted By: kalmar

Re: Counting Ticks per hour - 10/11/20 12:08

I'm not sure if it will be useful for you, but marketVol() for FXCM delivers Tick frequency: https://www.zorro-trader.com/manual/en/fxcm.htm
Posted By: danatrader

Re: Counting Ticks per hour - 10/11/20 15:28

Also MT4 seems to deliver that, problem here, only in live, so I have no option to use it in backtesting or development.
Posted By: Grat

Re: Counting Ticks per hour - 10/12/20 06:28

i thinking ( from head )

Code

// global var


int tmpCount=0;
int lastHour=0;
int dnTick = upTick = 0;
var lastPrice;

void tick(){
   tmpCount++;     // increment every ticks
  if (lastPrice > priceClose())
    dnTick++;
  else
    upTick++;
...
}

void run(){
    BarPeriod=60;

   if(is(INITRUN)){
      tmpCount=0;
      lastHour=0;
   }

  if(!is(LOOKBACK)){
    // .... this code run every new H1 candle
    // in the dnTick & upTick is tick info from last hour
    ....
    ....
    // -- now reset for newcandle
    lastHour=tmpCount;
    tmpCount=0;
    upTick=0;
    dnTick=0;
    lastPrice=priceClose();
  }
}


in manual:
Quote
In a TMF or tick function, priceClose() returns the last price quote, updated every tick when new price data becomes available. price() returns the price averaged over all received ticks of the current bar so far; therefore it is more 'jaggy' at the begin of the bar when few ticks were received yet, and more smooth towards the end of the bar period. priceHigh() and priceLow() return the highest and lowest price of the current bar so far, so their distance is small at the begin of the bar and wide towards the end.
Posted By: kalmar

Re: Counting Ticks per hour - 10/12/20 07:52

Maybe this PYthon snip will be inspirational: https://github.com/FEC-UIUC/Ticks-To-Second-Bars/blob/master/src/ticks_to_bars.py
Posted By: Grat

Re: Counting Ticks per hour - 10/12/20 08:09

This python script make candles from ticks CSV file. But this is old way, now is better use the Pandas ( ohlc fce ).

I thinking first question not howto convert tick to candles but how many times tick go up/dn during H1 candle
© 2024 lite-C Forums