0
Views
0
Downloads
0
Favorites
HiLo Lines1
//+------------------------------------------------------------------+
//| Lines_HiLo.mq4 |
//|
//|
//+------------------------------------------------------------------+
#property copyright "TradeForex"
#property link ""
#property indicator_chart_window
extern int Lookback_Period = 15;
extern int Buy_At_Low_Plus = 20;
extern int Sell_At_High_Minus = 20;
extern bool ViewComment = true;
double period_Low=0;
double period_High=0;
double Period_Low_Line;
double Period_High_Line;
double Buy_Line=0;
double Sell_Line=0;
double BuyAt = 0;
double SellAt =0;
double HighAt = 0;
double LowAt =0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("BuyAt Label");
ObjectDelete("BuyAt Line");
ObjectDelete("SellAt Label");
ObjectDelete("SellAt Line");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
period_High =High[Highest(NULL,0,MODE_HIGH,Lookback_Period,1)];
period_Low =Low[Lowest(NULL,0,MODE_LOW,Lookback_Period,1)];
Period_Low_Line = (period_Low );
Period_High_Line = (period_High );
Buy_Line = (period_Low + Buy_At_Low_Plus * Point );
Sell_Line = (period_High - Sell_At_High_Minus * Point );
if (ViewComment==true){
Comment("Buy at break of = ",Buy_Line, " Sell at break of = ",Sell_Line);
}
{
SetLevel("High Line", Period_High_Line, Blue); //Blue
SetLevel("Low Line", Period_Low_Line, Blue); //Blue
SetLevel("LOW Plus Buy line", Buy_Line, Green); //Green
SetLevel("HIGH Minus Sell line", Sell_Line, Green); //Red
}
return(0);
}
//+------------------------------------------------------------------+
//| Helper |
//+------------------------------------------------------------------+
void SetLevel(string text, double level, color col1)
{
string labelname= text + " Label";
string linename= text + " Line";
if (ObjectFind(labelname) != 0) {
ObjectCreate(labelname, OBJ_TEXT, 0, Time[20], level);
ObjectSetText(labelname, " " + text, 8, "Arial", White);
}
else {
ObjectMove(labelname, 0, Time[20], level);
}
if (ObjectFind(linename) != 0) {
ObjectCreate(linename, OBJ_HLINE, 0, Time[40], level);
ObjectSet(linename, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(linename,OBJPROP_LEVELWIDTH, 5);
ObjectSet(linename, OBJPROP_COLOR, col1);
}
else {
ObjectMove(linename, 0, Time[40], level);
}
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---