real volume

 

hi guys , i want write a program for calculate deffrent of close price between last tick and one before it , but i dont know whats the problem

#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
double closes[];
double deffrent[];
//------------------------------------------------------------------
void OnTick()
  {
     int i=(int) Volume[0];
       closes[i]=Close[0];
       deffrent[i]=10000*(closes[i]-closes[i-1]);
       Comment("real valume = "+DoubleToStr(deffrent[i],2));
      
   
  }
//+------------------------------------------------------------------+
 
ejmin ejoni:

hi guys , i want write a program for calculate deffrent of close price between last tick and one before it , but i dont know whats the problem

Every tick needs to be stored in a different element and the array to be sized accordingly.

Its seems MQL5 has a function to get tick data. See if it helps 

Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
Documentation on MQL5: Timeseries and Indicators Access / CopyTicks
  • www.mql5.com
CopyTicks - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
  1. Do not post code that will not even compile. You have no variable i.

  2. You need only the previous and current tick; arrays are not required.

    double closeCur=0;
    
    ⋮    
    double closePre = closeCur; closeCur = Close[0]; // Or Bid   
    double dif = (closeCur - closePre);
  3. Code fails on JPY pairs and metals.
    deffrent[i]=10000*(closes[i]-closes[i-1]);
    Don't hard code constants
    deffrent[i]= (closes[i]-closes[i-1]) / _Point;