hi all, i am a complete beginner in EA. I would like to write a program that reads the Highest High of the last 3 30 mins bar on my chart, and return the highest value on my chart in a dialog box. Can anyone tell me how to do that? Thank you.
Hi, I have added the program into a EA skeleton program. Someone, it turn into a script. Also, when I compile the program, there is a warning and I am not able to see the messages. Can anyone help?
//+------------------------------------------------------------------+
//| find the highest bar since market is open.mq5 |
//| Copyright 26 Jan 2013, phi.nuts |
//| https://www.mql5.com/en/forum/10193#comment_414969 |
//+------------------------------------------------------------------+
#property copyright "Copyright 26 Jan 2013, phi.nuts "
#property link "https://www.mql5.com/en/forum/10193#comment_414969"
#property version "1.00"
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
return(0);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy timer
EventKillTimer();
}
void OnStart()
{
// the highest bar since market open
double high_price [];
datetime time_period_d1 [];
int highest_bar, copied_high;
//--- what time market is open
if (CopyTime (_Symbol, PERIOD_D1, 0, 1, time_period_d1) > 0) //--- when the market open
{
Print("1. market open at ", TimeToString (time_period_d1[0],TIME_DATE|TIME_SECONDS));
copied_high = CopyHigh(_Symbol, _Period, TimeCurrent(), time_period_d1[0], high_price);//--- copying high price
if (copied_high > 0)
{
Print ("2. number of data of high price is ", copied_high);
highest_bar = ArrayMaximum(high_price, 0, WHOLE_ARRAY); //--- find the highest
if (highest_bar != -1)
{
Print("3. the highest price is ",high_price [highest_bar] ," at bar ",copied_high - highest_bar - 1);
}
}
}
return;
}
//+------------------------------------------------------------------+
1. Next time, use SRC button to post the code
2. Copy all the code inside OnStart and paste them inside OnTick, you can do that over and over until you get no error or read Program Running .

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi all, i am a complete beginner in EA. I would like to write a program that reads the Highest High of the last 3 30 mins bar on my chart, and return the highest value on my chart in a dialog box. Can anyone tell me how to do that? Thank you.