Here is yesterday's highest High and lowest Low sample.
double high = iHigh(NULL, PERIOD_D1, 1); double low = iLow(NULL, PERIOD_D1, 1);
Thanks for your help.
Here is yesterday's highest High and lowest Low sample.
double high = iHigh(NULL, PERIOD_D1, 1); double low = iLow(NULL, PERIOD_D1, 1);
hey in2blues,
i've read your post and decided to do a 5 minutes generic "hi low" script that you can run on any chart on any period, using a "from" and "to" dates. here it is, enjoy:
//+------------------------------------------------------------------+
//| FromToHiLo.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "ProjectFX"
#property link ""
#property show_inputs
//---- input parameters
extern datetime xdt_from = D'1970.01.01 09:00';
extern datetime xdt_to = D'2031.01.17 07:05';
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//int counted_bars=IndicatorCounted();
//----
int vi_bar;
int vi_startBar;
int vi_endBar;
double vd_hi = 0;
double vd_lo = 99999999.0;
//delete the lines from the last time :)
ObjectDelete("_start");
ObjectDelete("_end");
ObjectDelete("_hi");
ObjectDelete("_lo");
//find starting and ending bars and mark them with a vline
vi_startBar = ArrayBsearch(Time, xdt_from);
ObjectCreate("_start", OBJ_VLINE, 0, Time[vi_startBar], 0);
vi_endBar = ArrayBsearch(Time, xdt_to);
ObjectCreate("_end", OBJ_VLINE, 0, Time[vi_endBar], 0);
//go on all bars...
for(vi_bar = vi_startBar; vi_bar >= vi_endBar; vi_bar--)
{
//update min/max
vd_hi = MathMax(vd_hi, High[vi_bar]);
vd_lo = MathMin(vd_lo, Low[vi_bar]);
}
//mark the highest and lowest with an hline
ObjectCreate("_hi", OBJ_HLINE, 0, 0, vd_hi);
ObjectCreate("_lo", OBJ_HLINE, 0, 0, vd_lo);
//----
return(0);
}
//+------------------------------------------------------------------+
i've read your post and decided to do a 5 minutes generic "hi low" script that you can run on any chart on any period, using a "from" and "to" dates. here it is, enjoy:
//+------------------------------------------------------------------+
//| FromToHiLo.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "ProjectFX"
#property link ""
#property show_inputs
//---- input parameters
extern datetime xdt_from = D'1970.01.01 09:00';
extern datetime xdt_to = D'2031.01.17 07:05';
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//int counted_bars=IndicatorCounted();
//----
int vi_bar;
int vi_startBar;
int vi_endBar;
double vd_hi = 0;
double vd_lo = 99999999.0;
//delete the lines from the last time :)
ObjectDelete("_start");
ObjectDelete("_end");
ObjectDelete("_hi");
ObjectDelete("_lo");
//find starting and ending bars and mark them with a vline
vi_startBar = ArrayBsearch(Time, xdt_from);
ObjectCreate("_start", OBJ_VLINE, 0, Time[vi_startBar], 0);
vi_endBar = ArrayBsearch(Time, xdt_to);
ObjectCreate("_end", OBJ_VLINE, 0, Time[vi_endBar], 0);
//go on all bars...
for(vi_bar = vi_startBar; vi_bar >= vi_endBar; vi_bar--)
{
//update min/max
vd_hi = MathMax(vd_hi, High[vi_bar]);
vd_lo = MathMin(vd_lo, Low[vi_bar]);
}
//mark the highest and lowest with an hline
ObjectCreate("_hi", OBJ_HLINE, 0, 0, vd_hi);
ObjectCreate("_lo", OBJ_HLINE, 0, 0, vd_lo);
//----
return(0);
}
//+------------------------------------------------------------------+
Thanks so much. I appreciate your help.
In2Blues
hey in2blues,
i've read your post and decided to do a 5 minutes generic "hi low" script that you can run on any chart on any period, using a "from" and "to" dates. here it is, enjoy:
//+------------------------------------------------------------------+
//| FromToHiLo.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "ProjectFX"
#property link ""
#property show_inputs
//---- input parameters
extern datetime xdt_from = D'1970.01.01 09:00';
extern datetime xdt_to = D'2031.01.17 07:05';
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//int counted_bars=IndicatorCounted();
//----
int vi_bar;
int vi_startBar;
int vi_endBar;
double vd_hi = 0;
double vd_lo = 99999999.0;
//delete the lines from the last time :)
ObjectDelete("_start");
ObjectDelete("_end");
ObjectDelete("_hi");
ObjectDelete("_lo");
//find starting and ending bars and mark them with a vline
vi_startBar = ArrayBsearch(Time, xdt_from);
ObjectCreate("_start", OBJ_VLINE, 0, Time[vi_startBar], 0);
vi_endBar = ArrayBsearch(Time, xdt_to);
ObjectCreate("_end", OBJ_VLINE, 0, Time[vi_endBar], 0);
//go on all bars...
for(vi_bar = vi_startBar; vi_bar >= vi_endBar; vi_bar--)
{
//update min/max
vd_hi = MathMax(vd_hi, High[vi_bar]);
vd_lo = MathMin(vd_lo, Low[vi_bar]);
}
//mark the highest and lowest with an hline
ObjectCreate("_hi", OBJ_HLINE, 0, 0, vd_hi);
ObjectCreate("_lo", OBJ_HLINE, 0, 0, vd_lo);
//----
return(0);
}
//+------------------------------------------------------------------+
In2Blues
hey in2blues,
i've read your post and decided to do a 5 minutes generic "hi low" script that you can run on any chart on any period, using a "from" and "to" dates. here it is, enjoy:
//+------------------------------------------------------------------+
//| FromToHiLo.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "ProjectFX"
#property link ""
#property show_inputs
//---- input parameters
extern datetime xdt_from = D'1970.01.01 09:00';
extern datetime xdt_to = D'2031.01.17 07:05';
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//int counted_bars=IndicatorCounted();
//----
int vi_bar;
int vi_startBar;
int vi_endBar;
double vd_hi = 0;
double vd_lo = 99999999.0;
//delete the lines from the last time :)
ObjectDelete("_start");
ObjectDelete("_end");
ObjectDelete("_hi");
ObjectDelete("_lo");
//find starting and ending bars and mark them with a vline
vi_startBar = ArrayBsearch(Time, xdt_from);
ObjectCreate("_start", OBJ_VLINE, 0, Time[vi_startBar], 0);
vi_endBar = ArrayBsearch(Time, xdt_to);
ObjectCreate("_end", OBJ_VLINE, 0, Time[vi_endBar], 0);
//go on all bars...
for(vi_bar = vi_startBar; vi_bar >= vi_endBar; vi_bar--)
{
//update min/max
vd_hi = MathMax(vd_hi, High[vi_bar]);
vd_lo = MathMin(vd_lo, Low[vi_bar]);
}
//mark the highest and lowest with an hline
ObjectCreate("_hi", OBJ_HLINE, 0, 0, vd_hi);
ObjectCreate("_lo", OBJ_HLINE, 0, 0, vd_lo);
//----
return(0);
}
//+------------------------------------------------------------------+

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
I have displayed on my charts the following lines:
Yesterday's highest High and lowest Low.
This week's and last week's highest High and lowest Low.
This month's and last month's highest High and lowest Low.
What I can't figure out is how to display lines showing this year's and last year's highest High and lowest Low.
I don't mean the previous 12 months, I mean the whole year from January to December (for last year) and January to the current month (for the current year).
I'm sure it's something simple, but I can't seem to do it.
Does anyone have an indicator to display this, or can show me the code so I can write it myself?
TIA for your help.