MetaTrader Trading Platform Screenshots
Hello,
Please EDIT your post and use the SRC button when you post code.
Thank you.
Friends,
I'm having trouble trying to save times & trades data to a text file.
I am trying to save this data in real time, but always the last trades executed in the market are appearing repeated.
I'm writing the code as a custom indicator in the OnCalculate () function block.
Because you are running your code in OnCalculate() which is triggered for ALL ticks, while your code only show TRADE tick, the last one. Check the tick time to filter.
Or use SymblInfoTick() eventually, depends of your goal.
Porque você está executando o seu código em OnCalculate (), que é acionado para TODOS os tiques, enquanto o seu código mostra apenas TRADE tick, o último. Verifique o tempo de seleção para filtrar.
Ou use SymblInfoTick () eventualmente, depende do seu objetivo.
Alain Verleyen thank you for your answer,
My goal is to study &Quot;TRADE tick" in real time. Example: A sequence of trades of purchase with volume &Quot;x" that call my attention on tape reading. But the trades tick appear repeated in many cases exactly as commented. Guided Me to use CopyTickRange() and get 1 minute intervals, which would agree would receive without repetitions and in real time. SymblInfoTick () would solve this problem?
Thank you for your help.
Alain Verleyen thank you for your answer,
My goal is to study &Quot;TRADE tick" in real time. Example: A sequence of trades of purchase with volume &Quot;x" that call my attention on tape reading. But the trades tick appear repeated in many cases exactly as commented. Guided Me to use CopyTickRange() and get 1 minute intervals, which would agree would receive without repetitions and in real time. SymblInfoTick () would solve this problem?
Thank you for your help.
There is a repetition only because your code do it.
int OnCalculate(...) { //--- MqlTick tick_array[]; //Ticks indexados em uma matriz de estruturas. CopyTicks(Symbol(),tick_array,COPY_TICKS_TRADE,0,1); //Requisitando tick e indexando na matriz de estruturas.
OnCalculate is run on ALL ticks, trade ticks AND all other ticks.
CopyTicks get the trade ticks, so you can have several "no trade" ticks between trade ticks. Until there is a new trade tick, the last trade tick will be repeated.
// NOT TESTED static ulong msec=-1; MqlTick tick_array[]; //Ticks indexados em uma matriz de estruturas. if(CopyTicks(Symbol(),tick_array,COPY_TICKS_TRADE,msec+1,1)!=-1) //Requisitando tick e indexando na matriz de estruturas. { // check for error, always ! } else { msec=tick_array[0].time_msc; if(tick_array[0].volume>=10) { // Filtando volume a ser exibido Print(tick_array[0].volume); //plotando volume no console } } //+------------------------------------------------------------------+
There is a repetition only because your code do it.
OnCalculate is run on ALL ticks, trade ticks AND all other ticks.
CopyTicks get the trade ticks, so you can have several "no trade" ticks between trade ticks. Until there is a new trade tick, the last trade tick will be repeated.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Friends,
I'm having trouble trying to save times & trades data to a text file.
I am trying to save this data in real time, but always the last trades executed in the market are appearing repeated.
I'm writing the code as a custom indicator in the OnCalculate () function block.