Price difference between last tick and previous.

Posted By: JRA

Price difference between last tick and previous. - 02/22/18 10:47

I want to compute the price difference between two ticks (last and previous), but Tick series don´t work. How can I compute this difference in a fast way (latency purposes)?

Thanks and congrats for this fantastic community.
Posted By: jcl

Re: Price difference between last tick and previous. - 02/23/18 11:38

vars TickSeries;

void tick()
{
shift(TickSeries,priceClose(),30);
var difference = TickSeries[0] - TickSeries[1];
...
}

void run()
{
...
Tickseries = series(priceClose(),-30);
...
}
Posted By: JRA

Re: Price difference between last tick and previous. - 02/23/18 14:56

Every time I tried to get tick series I get the 111 error Crash Tick(). No matters how to:

vars Close = series(priceClose(0,10)); //Crash tick() error

vars Change = series(diff(priceClose())); //Crash tick() error

shift(TickSeries,priceClose(),30); //Crash tick() error

I think this is because I can get the last tick price (or close on 0 bar) and the last bar close (time based).

void tick()
{


var LastTick = priceClose();
var LastClose = priceClose(1);
var Difference = LastTick - LastClose;

printf("nPrice A: %f",Difference);

}


void run()
{

BarPeriod = 1./60; // Test
LookBack = 5;
set(TICKS);


}

This code can works if I´m able to run in HFT mode, but I have errors when When BarPeriod is under 1 sec. I´m getting the data from MT5 account with the bridge.
© 2024 lite-C Forums