Hello all,
I need help with a custom indicator I have developed. I have 3 lines being drawn at the start of every day, one for daily open price, one for weekly open price, and one for monthly open price. My problem is that I am moving to a broker who doesn't give the new daily candle at 00:00 GMT. They give it at 22:00 GMT. So basically, my Daily Open price line needs to now be based on the broker's 02:00 hourly candle open price. Can you look at my script below and let me know how I can accomplish this? I've exhausted all that I know how to do. Thanks.
extern color DailyOpen_Color = Lime;
extern string DailyOpen_Style = "DOT";
extern int DailyOpen_Width = 1;
//
extern color WeeklyOpen_Color = Yellow;
extern string WeeklyOpen_Style = "DOT";
extern int WeeklyOpen_Width = 1;
//
extern color MonthlyOpen_Color = Red;
extern string MonthlyOpen_Style = "DOT";
extern int MonthlyOpen_Width = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Only the style SOLID width can be greater than 1
if (DailyOpen_Style != "SOLID" && DailyOpen_Width > 1)
DailyOpen_Width = 1;
if (WeeklyOpen_Style != "SOLID" && WeeklyOpen_Width > 1)
WeeklyOpen_Width = 1;
if (MonthlyOpen_Style != "SOLID" && MonthlyOpen_Width > 1)
MonthlyOpen_Width = 1;
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
// Delete lines
ObjectDelete("Daily_Open_Line");
ObjectDelete("Weekly_Open_Line");
ObjectDelete("Monthly_Open_Line");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// Current Daily bar open price
double do = iOpen(NULL, PERIOD_D1, 0);
double wo = iOpen(NULL, PERIOD_W1, 0);
double mo = iOpen(NULL, PERIOD_MN1, 0);
// Daily open line
ObjectCreate("Daily_Open_Line", OBJ_HLINE, 0, Time[0], do);
ObjectSet("Daily_Open_Line", OBJPROP_COLOR, DailyOpen_Color);
ObjectSet("Daily_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Daily_Open_Line", OBJPROP_WIDTH, DailyOpen_Width);
// Weekly open line
ObjectCreate("Weekly_Open_Line", OBJ_HLINE, 0, Time[0], wo);
ObjectSet("Weekly_Open_Line", OBJPROP_COLOR, WeeklyOpen_Color);
ObjectSet("Weekly_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Weekly_Open_Line", OBJPROP_WIDTH, WeeklyOpen_Width);
// Monthly open line
ObjectCreate("Monthly_Open_Line", OBJ_HLINE, 0, Time[0], mo);
ObjectSet("Monthly_Open_Line", OBJPROP_COLOR, MonthlyOpen_Color);
ObjectSet("Monthly_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Monthly_Open_Line", OBJPROP_WIDTH, MonthlyOpen_Width);
return (0);
}
//+------------------------------------------------------------------+
//| GetLineStyle int |
//+------------------------------------------------------------------+
int GetLineStyle()
{
int ls = 0;
string stylearray[5] = {"SOLID", "DASH", "DOT", "DASHDOT", "DASHDOTDOT"};
if (DailyOpen_Style == stylearray[1]) ls = 1;
else if (DailyOpen_Style == stylearray[2]) ls = 2;
else if (DailyOpen_Style == stylearray[3]) ls = 3;
else if (DailyOpen_Style == stylearray[4]) ls = 4;
if (WeeklyOpen_Style == stylearray[1]) ls = 1;
else if (WeeklyOpen_Style == stylearray[2]) ls = 2;
else if (WeeklyOpen_Style == stylearray[3]) ls = 3;
else if (WeeklyOpen_Style == stylearray[4]) ls = 4;
if (MonthlyOpen_Style == stylearray[1]) ls = 1;
else if (MonthlyOpen_Style == stylearray[2]) ls = 2;
else if (MonthlyOpen_Style == stylearray[3]) ls = 3;
else if (MonthlyOpen_Style == stylearray[4]) ls = 4;
return(ls);
}
//+------------------------------------------------------------------+
I need help with a custom indicator I have developed. I have 3 lines being drawn at the start of every day, one for daily open price, one for weekly open price, and one for monthly open price. My problem is that I am moving to a broker who doesn't give the new daily candle at 00:00 GMT. They give it at 22:00 GMT. So basically, my Daily Open price line needs to now be based on the broker's 02:00 hourly candle open price. Can you look at my script below and let me know how I can accomplish this? I've exhausted all that I know how to do. Thanks.
extern color DailyOpen_Color = Lime;
extern string DailyOpen_Style = "DOT";
extern int DailyOpen_Width = 1;
//
extern color WeeklyOpen_Color = Yellow;
extern string WeeklyOpen_Style = "DOT";
extern int WeeklyOpen_Width = 1;
//
extern color MonthlyOpen_Color = Red;
extern string MonthlyOpen_Style = "DOT";
extern int MonthlyOpen_Width = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// Only the style SOLID width can be greater than 1
if (DailyOpen_Style != "SOLID" && DailyOpen_Width > 1)
DailyOpen_Width = 1;
if (WeeklyOpen_Style != "SOLID" && WeeklyOpen_Width > 1)
WeeklyOpen_Width = 1;
if (MonthlyOpen_Style != "SOLID" && MonthlyOpen_Width > 1)
MonthlyOpen_Width = 1;
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
// Delete lines
ObjectDelete("Daily_Open_Line");
ObjectDelete("Weekly_Open_Line");
ObjectDelete("Monthly_Open_Line");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
// Current Daily bar open price
double do = iOpen(NULL, PERIOD_D1, 0);
double wo = iOpen(NULL, PERIOD_W1, 0);
double mo = iOpen(NULL, PERIOD_MN1, 0);
// Daily open line
ObjectCreate("Daily_Open_Line", OBJ_HLINE, 0, Time[0], do);
ObjectSet("Daily_Open_Line", OBJPROP_COLOR, DailyOpen_Color);
ObjectSet("Daily_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Daily_Open_Line", OBJPROP_WIDTH, DailyOpen_Width);
// Weekly open line
ObjectCreate("Weekly_Open_Line", OBJ_HLINE, 0, Time[0], wo);
ObjectSet("Weekly_Open_Line", OBJPROP_COLOR, WeeklyOpen_Color);
ObjectSet("Weekly_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Weekly_Open_Line", OBJPROP_WIDTH, WeeklyOpen_Width);
// Monthly open line
ObjectCreate("Monthly_Open_Line", OBJ_HLINE, 0, Time[0], mo);
ObjectSet("Monthly_Open_Line", OBJPROP_COLOR, MonthlyOpen_Color);
ObjectSet("Monthly_Open_Line", OBJPROP_STYLE, GetLineStyle());
ObjectSet("Monthly_Open_Line", OBJPROP_WIDTH, MonthlyOpen_Width);
return (0);
}
//+------------------------------------------------------------------+
//| GetLineStyle int |
//+------------------------------------------------------------------+
int GetLineStyle()
{
int ls = 0;
string stylearray[5] = {"SOLID", "DASH", "DOT", "DASHDOT", "DASHDOTDOT"};
if (DailyOpen_Style == stylearray[1]) ls = 1;
else if (DailyOpen_Style == stylearray[2]) ls = 2;
else if (DailyOpen_Style == stylearray[3]) ls = 3;
else if (DailyOpen_Style == stylearray[4]) ls = 4;
if (WeeklyOpen_Style == stylearray[1]) ls = 1;
else if (WeeklyOpen_Style == stylearray[2]) ls = 2;
else if (WeeklyOpen_Style == stylearray[3]) ls = 3;
else if (WeeklyOpen_Style == stylearray[4]) ls = 4;
if (MonthlyOpen_Style == stylearray[1]) ls = 1;
else if (MonthlyOpen_Style == stylearray[2]) ls = 2;
else if (MonthlyOpen_Style == stylearray[3]) ls = 3;
else if (MonthlyOpen_Style == stylearray[4]) ls = 4;
return(ls);
}
//+------------------------------------------------------------------+