Simple script to snap lines to high or low of candles

123Reverse
Trader
Posts: 49
Joined: Sun May 05, 2013 2:54 am
Location: Australia

Re: Simple script to snap lines to high or low of candles

Post by 123Reverse »

hannele,

//+------------------------------------------------------------------+
//| HLOC Line.mq4 |
//| DP |
//| Draws High ,Low, Mid, Open and Close lines on selected candle. |
//+------------------------------------------------------------------+
#property copyright "DP"
#property link "With thanks to gaheitman on stevenhopwoodforex.com"

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//delete the old lines
ObjectDelete("MyCloseLine");
ObjectDelete("MyLowLine");
ObjectDelete("MyOpenLine");
ObjectDelete("MyHighLine");
ObjectDelete("MyMidLine");


//set colours
double opencolor = Tomato;
double closecolor = Tomato;
double highcolor = OrangeRed;
double lowcolor = OrangeRed;
double midcolor = Goldenrod;


//get the Close, High, Open, Low prices of the dropped on bar
double Cl = Close[iBarShift(Symbol(),0,WindowTimeOnDropped())];
double Hi = High[iBarShift(Symbol(),0,WindowTimeOnDropped())];
double Op = Open[iBarShift(Symbol(),0,WindowTimeOnDropped())];
double Lo = Low[iBarShift(Symbol(),0,WindowTimeOnDropped())];
double Mi = (Cl+Op)/2;


//create the lines
ObjectCreate("MyCloseLine", OBJ_HLINE, 0,WindowTimeOnDropped(),Cl);
ObjectSet("MyCloseLine", OBJPROP_COLOR, closecolor);

ObjectCreate("MyHighLine", OBJ_HLINE, 0,WindowTimeOnDropped(),Hi);
ObjectSet("MyHighLine", OBJPROP_COLOR, highcolor);

ObjectCreate("MyOpenLine", OBJ_HLINE, 0,WindowTimeOnDropped(),Op);
ObjectSet("MyOpenLine", OBJPROP_COLOR, opencolor);

ObjectCreate("MyLowLine", OBJ_HLINE, 0,WindowTimeOnDropped(),Lo);
ObjectSet("MyLowLine", OBJPROP_COLOR, lowcolor);

ObjectCreate("MyMidLine", OBJ_HLINE, 0,WindowTimeOnDropped(),Mi);
ObjectSet("MyMidLine", OBJPROP_COLOR, midcolor);


return(0);
}
//+------------------------------------------------------------------+


HTH
Cheers
hannele
Trader
Posts: 137
Joined: Wed Sep 19, 2012 2:31 am

Re: Simple script to snap lines to high or low of candles

Post by hannele »

Thank you :D
cheers hannele
ecodesign
Posts: 4
Joined: Tue Dec 13, 2011 10:28 pm

Simple script to snap lines to high or low of candles

Post by ecodesign »

A belated addition to this discussion:

For those still interested... a script that snaps a line to a high or a low of any candle, for as many candles as you want. Colour of the line is different on a high or a low. A text value of the high/low is shown above/below the candle. The script is called PSR (previous support-resistance)

Just drag the script near to the high and/or low and release.
Drag the PSR_Remove file to remove all lines and texts.

Hope this helps.

Wayne
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Scripts”