MetaTrader High/Low Horizontal Lines Indicator

TheBramble

Legendary member
Messages
8,394
Likes
1,170
Does anyone have code for an indicator (for MetaTrader) that will draw a horizontal lines for the High and the Low of a given start-to-finish period?

E.G. A horizontal line for the High of the 09:00 to 11:00 GMT period and a horizontal line for the Low of that same period.

I have code that will do it for ‘a specified number of bars back’, but can’t don’t currently have the skills to bend it into use for this purpose.
 
hi Tony,

Does it matter what time-frame it should work on?
I have the DIBS (inside-bar breakout) that works on 1-hr time-frame.

I am sure you could tweak the code.
It has the essence of marking a specific hourly bar with highs/lows. Dont know why it doesnt work for other time-frames.

Alternatively, I have the i-Sessions, which mark out user-defined time-frames into boxes.
Could you use this as a basis and add the horizontal lines onto it.
Here again, the essence of what you want is there, you just tweak it into what you want.

Let me know if you want me to upload DIBS and/or i-Sessions indicators.
 
Does anyone have code for an indicator (for MetaTrader) that will draw a horizontal lines for the High and the Low of a given start-to-finish period?

E.G. A horizontal line for the High of the 09:00 to 11:00 GMT period and a horizontal line for the Low of that same period.

I have code that will do it for ‘a specified number of bars back’, but can’t don’t currently have the skills to bend it into use for this purpose.

I suggest doing a search for an indicator called ACD.MQL, it should do what you want. Id post it but this lulzy sites stopped accepting attatchments !

Forex factory definately has a copy

Help in editing the ACD indicator? - Forex Factory
 
hi Tony,

Does it matter what time-frame it should work on?
I have the DIBS (inside-bar breakout) that works on 1-hr time-frame.

I am sure you could tweak the code.
It has the essence of marking a specific hourly bar with highs/lows. Dont know why it doesnt work for other time-frames.

Alternatively, I have the i-Sessions, which mark out user-defined time-frames into boxes.
Could you use this as a basis and add the horizontal lines onto it.
Here again, the essence of what you want is there, you just tweak it into what you want.

Let me know if you want me to upload DIBS and/or i-Sessions indicators.
I found the session thingy while researching this one today and it looks nice, but can't see why anyone would want to use it - LOL.

The DIBS ind sounds more like it. I'm sure if it currently points to a specific HOUR I can tweak it to loop through the time period or something like that. I hope. Yeah, could you post it (or email it).

Cheers.

Gratuitous and wanton rep on the way....
 
actually Tony, the ACD doesnt look too bad either.

I have attached both for your perusal.
If the DIBS doesnt point to the correct time-bar, the time-bar is user-configureable.
 

Attachments

  • ACD.mq4
    5.7 KB · Views: 1,516
  • DIBS_TriggerLines1.1.mq4
    8.3 KB · Views: 1,474
I just palyed with the ACDPivot but I'm using a time period that spans midnight (23:00-01:00), and it all goes rather strange....

I'll have a look at DIBS.

Thanks.
 
Right. But, not that useful just in the hourly.

I'm sure a MT guru could hack it, but I wouldn't know where to start.
 
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);
}
//+------------------------------------------------------------------+
 
Last edited:
Top