TheBramble
Legendary member
- Messages
- 8,394
- Likes
- 1,170
I’ve managed to cobble together something that does the job in a very primitive way. (Feel free to adopt, amend and utillise as you wish…).
But is there anyway I can get around having to either edit the swine each day or input the datetime values when I pull it onto the chart?
The extern datetime are the data I want to automate.
The times are always going to be the same: 23:00 ‘yesterday’ and 01:00 ‘today’. SO they can stay hard-coded. If there is a way to have it automatically use ‘yesterday’ and ‘today’ it would be really useful.
Come on, I've done the hard yards.
There has to be a metatrader coding Guru on this site with a better than basic grasp of this stuff who can come and insouciantly wave his coding wand and grab all the credit. Show us your stuff!!!
//---- input parameters
extern datetime xdt_from = D'2009.05.21 23:00';
extern datetime xdt_to = D'2009.05.22 01:00';
//+------------------------------------------------------------------+
//| 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);
ObjectSet("_hi",OBJPROP_COLOR,BlueViolet);
ObjectSet("_lo",OBJPROP_COLOR,BlueViolet);
ObjectSet("_hi",OBJPROP_WIDTH,2);
ObjectSet("_lo",OBJPROP_WIDTH,2);
//----
return(0);
}
//+------------------------------------------------------------------+
But is there anyway I can get around having to either edit the swine each day or input the datetime values when I pull it onto the chart?
The extern datetime are the data I want to automate.
The times are always going to be the same: 23:00 ‘yesterday’ and 01:00 ‘today’. SO they can stay hard-coded. If there is a way to have it automatically use ‘yesterday’ and ‘today’ it would be really useful.
Come on, I've done the hard yards.
There has to be a metatrader coding Guru on this site with a better than basic grasp of this stuff who can come and insouciantly wave his coding wand and grab all the credit. Show us your stuff!!!
//---- input parameters
extern datetime xdt_from = D'2009.05.21 23:00';
extern datetime xdt_to = D'2009.05.22 01:00';
//+------------------------------------------------------------------+
//| 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);
ObjectSet("_hi",OBJPROP_COLOR,BlueViolet);
ObjectSet("_lo",OBJPROP_COLOR,BlueViolet);
ObjectSet("_hi",OBJPROP_WIDTH,2);
ObjectSet("_lo",OBJPROP_WIDTH,2);
//----
return(0);
}
//+------------------------------------------------------------------+