Miscellaneous
0
Views
0
Downloads
0
Favorites
weekly_high_low-
//+------------------------------------------------------------------+
//| Daily_High_Low.mq4 |
//| Copyright © Terry Nicholls |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|Updated code to reflect Weekly high/low - Steve Fleming |
//|Free e-course teaching you how to write your own EA. No previous |
//|programming skills needed. |
//|http://www.automatedtradingsoftware.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © Terry Nicholls"
// Parameters
#property indicator_chart_window
extern int TimeZoneOfData = 0; // GMT
double lastweek_high=0;
double lastweek_low=0;
double rates_d1[2][6];
double wklyh;
double wklyl;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Indicators
wklyh=0; wklyl=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("wklyh Label");
ObjectDelete("wklyh Line");
ObjectDelete("wklyl Label");
ObjectDelete("wklyl Line");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// Get new Daily prices
ArrayCopyRates(rates_d1, Symbol(), PERIOD_W1);
lastweek_high = rates_d1[1][3];
lastweek_low = rates_d1[1][2];
// Calculate Daily High/Low lines
wklyh = lastweek_high;
wklyl = lastweek_low;
// Uncomment the line below to display the data at the top of your chart
// Comment ("Yesterday's High = ",lastweek_high," Yesterday's Low = ",lastweek_low);
// Set Daily High/Low line labels on chart window
if(ObjectFind("wklyh label") != 0)
{
ObjectCreate("wklyh label", OBJ_TEXT, 0, Time[20], wklyh);
ObjectSetText("wklyh label", "Last Wks High", 10, "Arial", Yellow);
}
else
{
ObjectMove("wklyh label", 0, Time[20], wklyh);
}
if(ObjectFind("wklyl label") != 0)
{
ObjectCreate("wklyl label", OBJ_TEXT, 0, Time[20], wklyl);
ObjectSetText("wklyl label", "Last Wks Low", 10, "Arial", Yellow);
}
else
{
ObjectMove("wklyl label", 0, Time[20], wklyl);
}
// Draw Yesterday's High/Low lines on chart
if(ObjectFind("wklyh line") != 0)
{
ObjectCreate("wklyh line", OBJ_HLINE, 0, Time[40], wklyh);
ObjectSet("wklyh line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("wklyh line", OBJPROP_WIDTH,0 );
ObjectSet("wklyh line", OBJPROP_COLOR, Yellow);
//Alert("Daily Low" ,Symbol()," ",Period()," @ ",Bid);PlaySound("sound7.wav");
}
else
{
ObjectMove("wklyh line", 0, Time[40], wklyh);
}
if(ObjectFind("wklyl line") != 0)
{
ObjectCreate("wklyl line", OBJ_HLINE, 0, Time[40], wklyl);
ObjectSet("wklyl line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("wklyl line", OBJPROP_WIDTH, 0);
ObjectSet("wklyl line", OBJPROP_COLOR, Yellow);
//Alert("Daily High" ,Symbol()," ",Period()," @ ",Bid);PlaySound("sound7.wav");
}
else
{
ObjectMove("wklyl line", 0, Time[40], wklyl);
}
return(0); // End program
}
//+------------------------------------------------------------------+
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
---