Nachdem der Wunsch jetzt schon mehrfach geäussert wurde, hab ich da mal was programmiert. Ist allerdings für den MT5.
Code:
//+------------------------------------------------------------------+
//| Handelszeiten.mq5 |
//| Copyright © 2017 Ing. Otto Pauser |
//| https://www.opa-trader.at |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017 Ing. Otto Pauser"
#property link "https://www.opa-trader.at"
#property version "1.00"
#property indicator_chart_window
#property indicator_plots 0
input string d1 = "--------- Linie 1 ---------"; // --------- Linie 1 ---------
input string t1 = "17:30"; // Time 1
input color c1 = clrRed; // Color 1
input int w1 = 2; // Width 1
input ENUM_LINE_STYLE s1 = STYLE_SOLID; // Style 1
input string d2 = "--------- Linie 2 ---------"; // --------- Linie 2 ---------
input string t2 = "22:00"; // Time 2
input color c2 = clrGold; // Color 2
input int w2 = 2; // Width 2
input ENUM_LINE_STYLE s2 = STYLE_SOLID; // Style 2
int ObjNr = 0;
int OnInit()
{
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{
for(int i=ObjNr; i>=0; i--)
ObjectDelete(ChartID(),"VLine"+IntegerToString(i));
}
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int startIdx = MathMax(prev_calculated,0);
for(int i=startIdx; i<rates_total; i++)
{
string st=TimeOnly(time[i]);
if(TimeOnly(time[i])==t1) CreateVLine(time[i],close[i],c1,w1,s1);
if(TimeOnly(time[i])==t2) CreateVLine(time[i],close[i],c2,w2,s2);
}
return(rates_total);
}
string TimeOnly(datetime aDateTime)
{
return(StringSubstr(TimeToString(aDateTime),11,5));
}
void CreateVLine(datetime _t, double _p, int _c, int _w, ENUM_LINE_STYLE _s)
{
string objName="VLine"+IntegerToString(ObjNr);
ObjectCreate (ChartID(),objName,OBJ_VLINE,0,_t,_p);
ObjectSetInteger(ChartID(),objName,OBJPROP_COLOR,_c);
ObjectSetInteger(ChartID(),objName,OBJPROP_WIDTH,_w);
ObjectSetInteger(ChartID(),objName,OBJPROP_STYLE,_s);
ObjNr++;
}
Der gewählte Timeframe sollte aber mit den Eingabezeiten zusammenpassen, sonst kommt kein Signal.
Die eingestellten Vorgabewerte funktionieren von M1 bis M30.