![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
In addition to the news, large bank transactions cause spikes in currencys. It is my uderstanding that many of these banks ( according to a friend at B of A ) make weekly transfers at a regulary scheduled time. What I am trying to do is identify these times before they happen and adjust my EA accordingally.
I figured that consistant spikes in price and volume would be a good way to identify these transactions ( or anything else that happens on a weekly basis and causes currencies to spike ). Here is my attempt to identify these times. Volume works but I cant seem to populate the Average_Hourly_Range variable.
Please take a look and tell me what I did wrong.
//=========================================================================================
void HistoricVolitility(){
int WeekInSeconds = 604800;
int HalfhourInSeconds = 1800;
// Same Hour, Last Week
datetime One_Week_Start = TimeCurrent() - WeekInSeconds - HalfhourInSeconds;//current time -1 week - Half hour
datetime One_Week_Curr = TimeCurrent() - WeekInSeconds;//current time -1 week
datetime One_Week_End = TimeCurrent() - WeekInSeconds + HalfhourInSeconds;//current time 1 week + Half hour
int One_Week_Start_Per = iBarShift(Symbol(),0,One_Week_Start);
int One_Week_Curr_Per = iBarShift(Symbol(),0,One_Week_Curr);
int One_Week_End_Per = iBarShift(Symbol(),0,One_Week_End);
double OneW_High = High;
double OneW_Low = Low;
double OneW_Range = OneW_High - OneW_Low;
double One_Week_Volume = iVolume(Symbol(),30,One_Week_Curr_Per+1);
// Same Hour, 2 Weeks Ago
datetime Two_Week_Start = TimeCurrent() - WeekInSeconds*2 - HalfhourInSeconds;//current time -1 week - Half hour
datetime Two_Week_Curr = TimeCurrent() - WeekInSeconds*2;//current time -1 week
datetime Two_Week_End = TimeCurrent() - WeekInSeconds*2 + HalfhourInSeconds;//current time 1 week + Half hour
int Two_Week_Start_Per = iBarShift(Symbol(),0,Two_Week_Start);
int Two_Week_Curr_Per = iBarShift(Symbol(),0,Two_Week_Curr);
int Two_Week_End_Per = iBarShift(Symbol(),0,Two_Week_End);
double TwoW_High = High;
double TwoW_Low = Low;
double TwoW_Range = TwoW_High - TwoW_Low;
double Two_Week_Volume = iVolume(Symbol(),30,Two_Week_Curr_Per+1);
// Same Hour, 3 Weeks Ago
datetime Three_Week_Start = TimeCurrent() - WeekInSeconds*3 - HalfhourInSeconds;//current time -1 week - Half hour
datetime Three_Week_Curr = TimeCurrent() - WeekInSeconds*3;//current time -1 week
datetime Three_Week_End = TimeCurrent() - WeekInSeconds*3 + HalfhourInSeconds;//current time 1 week + Half hour
int Three_Week_Start_Per = iBarShift(Symbol(),0,Three_Week_Start);
int Three_Week_Curr_Per = iBarShift(Symbol(),0,Three_Week_Curr);
int Three_Week_End_Per = iBarShift(Symbol(),0,Three_Week_End);
double ThreeW_High = High;
double ThreeW_Low = Low;
double ThreeW_Range = ThreeW_High - ThreeW_Low;
double Three_Week_Volume = iVolume(Symbol(),30,Three_Week_Curr_Per+1);
// Same Hour, 4 Weeks Ago
datetime Four_Week_Start = TimeCurrent() - WeekInSeconds*4 - HalfhourInSeconds;//current time -1 week - Half hour
datetime Four_Week_Curr = TimeCurrent() - WeekInSeconds*4;//current time -1 week
datetime Four_Week_End = TimeCurrent() - WeekInSeconds*4 + HalfhourInSeconds;//current time 1 week + Half hour
int Four_Week_Start_Per = iBarShift(Symbol(),0,Four_Week_Start);
int Four_Week_Curr_Per = iBarShift(Symbol(),0,Four_Week_Curr);
int Four_Week_End_Per = iBarShift(Symbol(),0,Four_Week_End);
double FourW_High = High;
double FourW_Low = Low;
double FourW_Range = FourW_High - FourW_Low;
double Four_Week_Volume = iVolume(Symbol(),30,Four_Week_Curr_Per+1);
double Ave_Hourly_Range = (OneW_Range + TwoW_Range + ThreeW_Range + FourW_Range);
double Ave_Volume = (One_Week_Volume + Two_Week_Volume + Three_Week_Volume + Four_Week_Volume)/4;
HistoricRange = Ave_Hourly_Range;
HistoricVolume = Ave_Volume;
}