Danke für die schnelle Antwort.
Hm... Vielleicht habe ich das blöd geschrieben. Auf dem Screenshot sind drei pinke/lila Linien , jeweils bei ca. 12780/12770/12747. Das andere sind die S/L(rot) und Tradeeröffnungslinien(gelb).
Voraussetzung für eine Sellorder sind u.a. High[1] > Objektpreis && Close[1] < Objektpreis.
Voraussetzung für eine Buyorder sind u.a. Low[1] < Objektpreis && Close[1] > Objektpreis.
Nun hat der EA aber bei ca. 12796 zwei Sellorder eröffnet. Dort befindet sich aber keine lila Linie. Gleiches gilt für die Buyorder. Deswegen habe ich mir den relevanten "objectprice" anzeigen lassen, wenn der EA eine Position eröffnet, wie im Screenshot zu sehen. Das macht mich nun stutzig, da es ja anscheinend Objekte gibt bei 12800 und 12763. Ich kann diese aber nicht sehen und ich verstehe nicht warum..
Hier der Indikator:
PHP-Code:
extern int periode_to_next_extremum = 20;
extern int bars_to_check = 40;
extern int history_15 = 200;
extern int history_60 = 300;
extern int start_indicator = 4;
extern int stop_indicator = 20;
double ResLevel[], SupLevel[];
datetime ResTime[],SupTime[];
int objectcounterRES = 1;
int objectcounterSUP = 1;
string NameRES = "lineRES";
string NameSUP = "lineSUP";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ArrayResize(ResLevel,1);
ArrayResize(ResTime,2);
ArrayResize(SupLevel,1);
ArrayResize(SupTime,2);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
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[])
{
//---
check_15TF();
check_60TF();
//+-------check_for_objectdelete-----------------------------------------------------------+
check_for_objectdelete();
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
int number_of_objects_deleted = ObjectsDeleteAll(0,"",0,-1);
Print("number_of_objects-deleted = ", number_of_objects_deleted);
}
//+-------check_for_objectdelete_in_nighttime-----------------------------------------------------------+
void check_for_objectdelete()
{
for(int i = 0; i <= ObjectsTotal()-1; i++)
{
string object_name = ObjectName(i);
datetime object_time = ObjectGet(object_name,OBJPROP_TIME1);
if(start_indicator >= TimeHour(object_time) && TimeHour(object_time) <= stop_indicator)
{
ObjectDelete(ChartID(),object_name);
}
}
}
//+-------check_for_S/R_15min-----------------------------------------------------------+
int check_15TF()
{
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
limit=Bars - counted_bars;
//---limit to n bars
if(limit > history_15) limit = history_15;
int timeframe_15 = 15;
//---- S/R_Calculations_15min----------------------
for(int i = 1; i < limit; i++)
{
//--Resistance_15min----
if(iHighest(NULL,timeframe_15,MODE_HIGH,bars_to_check,i) == i + periode_to_next_extremum)
{
ResLevel[0] = iHigh(Symbol(),PERIOD_M15,i + periode_to_next_extremum);
ResTime[0] = iTime(Symbol(),PERIOD_M15,i + periode_to_next_extremum);
ResTime[1] = iTime(Symbol(),PERIOD_M15,i + periode_to_next_extremum) + 9999999;
objectcounterRES++;
//------Colour-----
if(!ObjectCreate(NameRES + (string)objectcounterRES,OBJ_TREND,0,ResTime[0],ResLevel[0],ResTime[1],ResLevel[0]))
{
Print("Failed to create Trend: ", GetLastError());
}
//------Colour-----
if(!ObjectSetInteger(0,NameRES + (string)objectcounterRES,OBJPROP_COLOR,clrMagenta))
Print("Failed to set colour", GetLastError());
//------Show_in_5min_chart-----
if(!ObjectSetInteger(ChartID(),NameRES + (string)objectcounterRES,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5|OBJ_PERIOD_M15))
{
Print("Failed to adjust timeframe: ", GetLastError());
}
}
//--Support_15min---
if(iLowest(NULL,timeframe_15,MODE_LOW,bars_to_check,i) == i + periode_to_next_extremum)
{
SupLevel[0] = iLow(Symbol(),PERIOD_M15,i + periode_to_next_extremum);
SupTime[0] = iTime(Symbol(),PERIOD_M15,i + periode_to_next_extremum);
SupTime[1] = iTime(Symbol(),PERIOD_M15,i + periode_to_next_extremum) + 9999999;
objectcounterSUP++;
//------Colour-----
if(!ObjectCreate(NameSUP + (string)objectcounterSUP,OBJ_TREND,0,SupTime[0],SupLevel[0],SupTime[1],SupLevel[0]))
{
Print("Failed to create Trend: ", GetLastError());
}
//------Colour-----
if(!ObjectSetInteger(0,NameSUP + (string)objectcounterSUP,OBJPROP_COLOR,clrMagenta))
Print("Failed to set colour", GetLastError());
//------Show_in_5min_chart-----
if(!ObjectSetInteger(ChartID(),NameSUP + (string)objectcounterSUP,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5|OBJ_PERIOD_M15))
{
Print("Failed to adjust timeframe: ", GetLastError());
}
}
}
return(0);}
//+-------check_for_S/R_60min-----------------------------------------------------------+
int check_60TF()
{
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
limit=Bars - counted_bars;
//---limit to n bars
if(limit > history_60) limit = history_60;
int timeframe_60 = 60;
//---- S/R_Calculations_15min----------------------
for(int i = 1; i < limit; i++)
{
//--Resistance_15min----
if(iHighest(NULL,timeframe_60,MODE_HIGH,bars_to_check,i) == i + periode_to_next_extremum)
{
ResLevel[0] = iHigh(Symbol(),PERIOD_H1,i + periode_to_next_extremum);
ResTime[0] = iTime(Symbol(),PERIOD_H1,i + periode_to_next_extremum);
ResTime[1] = iTime(Symbol(),PERIOD_H1,i + periode_to_next_extremum) + 9999999;
objectcounterRES++;
//------Colour-----
if(!ObjectCreate(NameRES + (string)objectcounterRES,OBJ_TREND,0,ResTime[0],ResLevel[0],ResTime[1],ResLevel[0]))
{
Print("Failed to create Trend: ", GetLastError());
}
//------Colour-----
if(!ObjectSetInteger(0,NameRES + (string)objectcounterRES,OBJPROP_COLOR,clrDeepPink))
Print("Failed to set colour", GetLastError());
//------Show_in_5min_chart-----
if(!ObjectSetInteger(ChartID(),NameRES + (string)objectcounterRES,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_H1))
{
Print("Failed to adjust timeframe: ", GetLastError());
}
}
//--Support_15min---
if(iLowest(NULL,timeframe_60,MODE_LOW,bars_to_check,i) == i + periode_to_next_extremum)
{
SupLevel[0] = iLow(Symbol(),PERIOD_H1,i + periode_to_next_extremum);
SupTime[0] = iTime(Symbol(),PERIOD_H1,i + periode_to_next_extremum);
SupTime[1] = iTime(Symbol(),PERIOD_H1,i + periode_to_next_extremum) + 9999999;
objectcounterSUP++;
//------Colour-----
if(!ObjectCreate(NameSUP + (string)objectcounterSUP,OBJ_TREND,0,SupTime[0],SupLevel[0],SupTime[1],SupLevel[0]))
{
Print("Failed to create Trend: ", GetLastError());
}
//------Colour-----
if(!ObjectSetInteger(0,NameSUP + (string)objectcounterSUP,OBJPROP_COLOR,clrDeepPink))
Print("Failed to set colour", GetLastError());
//------Show_in_5min_chart-----
if(!ObjectSetInteger(ChartID(),NameSUP + (string)objectcounterSUP,OBJPROP_TIMEFRAMES,OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_H1))
{
Print("Failed to adjust timeframe: ", GetLastError());
}
}
}
return(0);}
Ich benutze noch ein anderen Indikator, der mir MAs auf verschiedenen timeframes anzeigt. Falls der relevant ist, kann ich den auch noch posten.
|