update
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
#property library
|
||||
#include <Trade/Trade.mqh>
|
||||
#include <MyLibs/TimeZones.mqh>
|
||||
#include <MyLibs/Myfunctions.mqh>
|
||||
|
||||
enum EXIT_INDICATORS_LIST{
|
||||
AROON,
|
||||
ASO,
|
||||
};
|
||||
|
||||
class ExitIndicators : public CObject{
|
||||
|
||||
protected:
|
||||
int handle;
|
||||
|
||||
public:
|
||||
int init_exit_indi_handle(EXIT_INDICATORS_LIST indi, string symbol, ENUM_TIMEFRAMES time_frame);
|
||||
bool get_exit_indi_bool(EXIT_INDICATORS_LIST indi, int exit_handle, int data_type);
|
||||
|
||||
};
|
||||
|
||||
int ExitIndicators::init_exit_indi_handle(EXIT_INDICATORS_LIST indi, string symbol, ENUM_TIMEFRAMES time_frame){
|
||||
|
||||
if(indi==AROON){
|
||||
handle=iCustom(symbol, time_frame, "MyIndicators\\AROON.ex5");
|
||||
|
||||
}
|
||||
if(indi==ASO){
|
||||
handle=iCustom(symbol, time_frame, "MyIndicators\\ASO.ex5", 26, 9, 0, 3);
|
||||
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool ExitIndicators::get_exit_indi_bool(EXIT_INDICATORS_LIST indi, int exit_handle, int data_type){
|
||||
|
||||
bool long_exit;
|
||||
bool short_exit;
|
||||
|
||||
if(indi==AROON){
|
||||
|
||||
double indi_up[];
|
||||
ArraySetAsSeries(indi_up, true);
|
||||
CopyBuffer(exit_handle,0,1,10,indi_up);
|
||||
|
||||
double indi_down[];
|
||||
ArraySetAsSeries(indi_down, true);
|
||||
CopyBuffer(exit_handle,1,1,10,indi_down);
|
||||
|
||||
long_exit = (
|
||||
indi_up[0] < indi_down[0]
|
||||
&& indi_up[1] > indi_down[1]
|
||||
);
|
||||
|
||||
short_exit = (
|
||||
indi_up[0] > indi_down[0]
|
||||
&& indi_up[1] < indi_down[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(indi==ASO){
|
||||
|
||||
double Bulls[];
|
||||
ArraySetAsSeries(Bulls, true);
|
||||
CopyBuffer(exit_handle,0,1,10,Bulls);
|
||||
|
||||
double Bears[];
|
||||
ArraySetAsSeries(Bears, true);
|
||||
CopyBuffer(exit_handle,1,1,10,Bears);
|
||||
|
||||
long_exit = (
|
||||
Bulls[0] < Bears[0]
|
||||
&& Bulls[1] > Bears[1]
|
||||
);
|
||||
|
||||
short_exit = (
|
||||
Bulls[0] > Bears[0]
|
||||
&& Bulls[1] < Bears[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if(data_type==1){return long_exit;}
|
||||
|
||||
if(data_type==2){return short_exit;}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
+37
-20
@@ -12,14 +12,14 @@ class MyFunctions : public CObject{
|
||||
datetime bar_open_time;
|
||||
|
||||
public:
|
||||
bool is_new_daily_bar(string symbol, datetime start_time);
|
||||
// bool is_new_daily_bar(string symbol, datetime start_time);
|
||||
double period_high(string symbol, int periods, int shift);
|
||||
double period_low(string symbol, int periods, int shift);
|
||||
void draw_line(double value, string name,color clr);
|
||||
bool check_indicator_handles(int &indicator_handles[]);
|
||||
double adjusted_point(string symbol);
|
||||
double get_bid_ask_price(string symbol, int price_side);
|
||||
bool is_new_bar(string symbol, ENUM_TIMEFRAMES time_frame);
|
||||
bool is_new_bar(string symbol, ENUM_TIMEFRAMES time_frame, string daily_start_time="00:10");
|
||||
bool trade_window(string t1, string t2, string time_zone, bool plot_range_inp=true);
|
||||
bool in_test_period(MODE_SPLIT_DATA data_period);
|
||||
};
|
||||
@@ -29,27 +29,29 @@ bool MyFunctions::trade_window(string t1, string t2, string time_zone="Broker",
|
||||
return in_window;
|
||||
}
|
||||
|
||||
//if(!mf.is_new_daily_bar(symbol, PERIOD_M1)){return;}
|
||||
bool MyFunctions::is_new_bar(string symbol, ENUM_TIMEFRAMES time_frame){
|
||||
bar_open_time = iTime(symbol,time_frame,0);
|
||||
if(previousTime!=bar_open_time){
|
||||
previousTime=bar_open_time;
|
||||
return true;
|
||||
//if(!mf.is_new_bar(symbol, PERIOD_D1, "00:06")){return;}
|
||||
bool MyFunctions::is_new_bar(string symbol, ENUM_TIMEFRAMES time_frame, string daily_start_time="00:10"){
|
||||
|
||||
bar_open_time = iTime(symbol, time_frame, 0);
|
||||
if(previousTime!=bar_open_time){
|
||||
|
||||
if(PeriodSeconds(time_frame)==PeriodSeconds(PERIOD_D1)){
|
||||
if(TimeCurrent() > StringToTime(daily_start_time)){
|
||||
Print("new bar");
|
||||
previousTime=bar_open_time;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
previousTime=bar_open_time;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// e.g. if(!mf.is_new_daily_bar(symbol, StringToTime("00:06"))){return;}
|
||||
bool MyFunctions::is_new_daily_bar(string symbol, datetime start_time){
|
||||
// https://www.youtube.com/watch?v=9BdnTcGrlUM (m-25:00)
|
||||
bar_open_time = iTime(symbol,PERIOD_D1,0);
|
||||
if(previousTime!=bar_open_time && TimeCurrent() > start_time){
|
||||
previousTime=bar_open_time;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//if(!mf.in_test_period(data_split_method){return;}
|
||||
bool MyFunctions::in_test_period(MODE_SPLIT_DATA data_split_method){
|
||||
|
||||
@@ -233,4 +235,19 @@ double MyFunctions::get_bid_ask_price(string symbol, int price_side){
|
||||
|
||||
return price;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // e.g. if(!mf.is_new_daily_bar(symbol, StringToTime("00:06"))){return;}
|
||||
// bool MyFunctions::is_new_daily_bar(string symbol, datetime start_time){
|
||||
// // https://www.youtube.com/watch?v=9BdnTcGrlUM (m-25:00)
|
||||
// bar_open_time = iTime(symbol,PERIOD_D1,0);
|
||||
// if(previousTime!=bar_open_time && TimeCurrent() > start_time){
|
||||
// previousTime=bar_open_time;
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
Reference in New Issue
Block a user