Hello there!
I'm trying to get ticks for some calc with CopyTicksRange function in EA (please,see code below). It works fine in real account, give the proper results. But when backtesting, it doesn't work. I'm currently working in Brazilian market with asset WING19. As I could understand so far, the issue may be on dates, as it reflects the total sec between desired date and D'01.01.1970 00:00:00'.
Trying to eliminate possible problems with CopyTicksRange, I also implemented CopyTicks function, both are working fine in real account, not in backtesting.
Also, I couldn't understand the reason why in real account it gives me the true asset historical begin, while in backtesting it gives a year back as asset historical begin.
What that means "doesn't work" ? What are the results ?
I'm facing same problem, also trading US dolar and stock index in Brazilian market. I use the structure below, and it works perfectly during the day (besides it's an ugly solution), but I can't backtest (it simply gives me incorrect numbers). I'm sure it's something related to CopyTicks. Anyone can help?
void OnTick()
{
CopyTicks ( ref_Symbol, tick_array, COPY_TICKS_TRADE, 0, 10);
for(int i=0;i<10;i++)
{
tick = tick_array [i];
neg_time = tick.time_msc;
if(tick.flags == 56 && tick.volume_real >= VolumeTriggerInput && TrendingTimeCheck && neg_time > temp_neg_time) //BUY CASE
{Multiplier = tick.volume_real / VolumeTriggerInput; temp_neg_time = tick.time_msc; MarketBuy();}
if(tick.flags == 88 && tick.volume_real >= VolumeTriggerInput && TrendingTimeCheck && neg_time > temp_neg_time) //SELL CASE
{Multiplier = tick.volume_real / VolumeTriggerInput; temp_neg_time = tick.time_msc; MarketSell();}
}
ZeroMemory(tick_array);
}
Please edit your post and
use the code button (Alt+S) when pasting code
I'm facing same problem, also trading US dolar and stock index in Brazilian market. I use the structure below, and it works perfectly during the day (besides it's an ugly solution), but I can't backtest (it simply gives me incorrect numbers). I'm sure it's something related to CopyTicks. Anyone can help?
void OnTick()
{
CopyTicks ( ref_Symbol, tick_array, COPY_TICKS_TRADE, 0, 10);
for(int i=0;i<10;i++)
{
tick = tick_array [i];
neg_time = tick.time_msc;
if(tick.flags == 56 && tick.volume_real >= VolumeTriggerInput && TrendingTimeCheck && neg_time > temp_neg_time) //BUY CASE
{Multiplier = tick.volume_real / VolumeTriggerInput; temp_neg_time = tick.time_msc; MarketBuy();}
if(tick.flags == 88 && tick.volume_real >= VolumeTriggerInput && TrendingTimeCheck && neg_time > temp_neg_time) //SELL CASE
{Multiplier = tick.volume_real / VolumeTriggerInput; temp_neg_time = tick.time_msc; MarketSell();}
}
ZeroMemory(tick_array);
}
Always remember to compare tick flags using bitwise operator..
bool buy; bool sell; int a = CopyTicks(....); if(a > 1){ for(....){ buy = (tick_array[i].flags & TICK_FLAG_BUY) == TICK_FLAG_BUY; //<--- IMPORTANT sell = (tick_array[i].flags & TICK_FLAG_SELL) == TICK_FLAG_SELL; //<--- IMPORTANT if(buy){/*...do something...*/} else if(sell){/*...do something else...*/} } }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello there!
I'm trying to get ticks for some calc with CopyTicksRange function in EA (please,see code below). It works fine in real account, give the proper results. But when backtesting, it doesn't work. I'm currently working in Brazilian market with asset WING19. As I could understand so far, the issue may be on dates, as it reflects the total sec between desired date and D'01.01.1970 00:00:00'.
Trying to eliminate possible problems with CopyTicksRange, I also implemented CopyTicks function, both are working fine in real account, not in backtesting.
Also, I couldn't understand the reason why in real account it gives me the true asset historical begin, while in backtesting it gives a year back as asset historical begin.