☞ EUR,USD,GBP,CHF,JPY,CAD,AUD,NZD로 구성된 28개통화쌍에 대하여 강세통화와 약세통화의 상대적인 추세를 %R을 통해 판단하고 매매하는 EA 버전을 개발하였다.
%R Version (윌리엄 % R)
- 통화별 강세와 약세를 %R로 판단(0이하 weak, 100이상 strong)
- 약세통화와 강세통화의 조합을 추세대로 진입하는 로직 구성
- M1 ~ H4까지의 Time Frame 전체에 대해 고려
//********************************************************************
//| YS_BaseCurrency_%R_V0.2 |
//| Copyright @ 2012 Gguri FX LAB |
//********************************************************************
//********************************************************************
//| Trading EA(Based On William %R) |
//********************************************************************
//********************************************************************
//| Version History |
//********************************************************************
/*
Version 0.1
- 통화별 강세와 약세를 %R로 판단(40이하 weak, 60이상 strong)
- 약세통화와 강세통화의 조합을 추세대로 진입하는 로직 구성
- M1 ~ H4까지의 Time Frame 전체에 대해 고려
Version 0.2
- 주문함수 수정
- SL, TP 주문함수 반영
- Date/Time Filter 추가
*/
/*
Time Frame : Any TimeFrame
Pairs : All Pairs(USD,EUR,GBP,JPY,CAD,CHF,AUD,NZD)
*/
//********************************************************************
//| Import Library |
//********************************************************************
#import "stdlib.ex4"
string ErrorDescription(int a0);
//********************************************************************
//| 외생변수 및 기타 내생변수 |
//********************************************************************
extern double FixLot=0.1 ; // 진입 랏사이즈 설정
extern double slippage = 3.0; // 슬리피지 허용 변수
extern bool ECN = FALSE;
extern int XSL = 120; // 목표 StopLoss
extern int XTP = 40; // 목표 TakeProfit
extern int All_SL = 300; // CloseAll StopLoss
extern int All_TP = 100; // CloseAll TakeProfit
extern string subfix = ""; // 통화쌍 접미어가 있는 경우
extern double StopOutBalance = 500; // 모든 거래 종료 잔고 설정
extern int MaxTrades = 1; // 통화당 최대 허용 거래수
extern int MaxSpread = 10; // 통화당 최대 허용 스프레드
/*
extern double TrailingStop = 0.0; // 트레일링 설정시 > 0
extern double BreakEven = 0.0; // Break Even 설정시 > 0
extern double BreakPoint = 0.0; // Break Even 설정시 손절치(본전 + 손절치)
*/
string Commentary = "YS_BaseCurrency_%R_V0.2"; // Entry 주문시 비고
string NowSym, StartDay;
datetime PreviousBarTime; // NewBar함수 사용변수
double mypoint;
int TicketBuy,TicketSell;
//********************************************************************
//| Entry Logic 관련 변수 설정 |
//********************************************************************
string gs_unused_284 = "Entry Settings";
extern int periods = 14;
extern int weakvalue = 0;
extern int strongvalue = 100;
// 통화별 거래선택 변수
extern bool PairTrade01 = TRUE;
extern bool PairTrade02 = TRUE;
extern bool PairTrade03 = TRUE;
extern bool PairTrade04 = TRUE;
extern bool PairTrade05 = TRUE;
extern bool PairTrade06 = TRUE;
extern bool PairTrade07 = TRUE;
extern bool PairTrade08 = TRUE;
extern bool PairTrade09 = TRUE;
extern bool PairTrade10 = TRUE;
extern bool PairTrade11 = TRUE;
extern bool PairTrade12 = TRUE;
extern bool PairTrade13 = TRUE;
extern bool PairTrade14 = TRUE;
extern bool PairTrade15 = TRUE;
extern bool PairTrade16 = TRUE;
extern bool PairTrade17 = TRUE;
extern bool PairTrade18 = TRUE;
extern bool PairTrade19 = TRUE;
extern bool PairTrade20 = TRUE;
extern bool PairTrade21 = TRUE;
extern bool PairTrade22 = TRUE;
extern bool PairTrade23 = TRUE;
extern bool PairTrade24 = TRUE;
extern bool PairTrade25 = TRUE;
extern bool PairTrade26 = TRUE;
extern bool PairTrade27 = TRUE;
extern bool PairTrade28 = TRUE;
//********************************************************************
//| Day/Time Filter 변수설정 |
//********************************************************************
extern bool DateFilter = FALSE;
extern bool TimeFilter = TRUE;
extern bool MON = TRUE;
extern bool TUE = TRUE;
extern bool WED = TRUE;
extern bool THU = TRUE;
extern bool FRI = TRUE;
extern int mon_start_time = 9;
extern int mon_finish_time = 19;
extern int tue_start_time = 9;
extern int tue_finish_time = 19;
extern int wed_start_time = 9;
extern int wed_finish_time = 19;
extern int thu_start_time = 9;
extern int thu_finish_time = 19;
extern int fri_start_time = 9;
extern int fri_finish_time = 19;
//********************************************************************
//| 초기화 |
//********************************************************************
int init()
{
StartDay = TimeToStr(TimeCurrent(),TIME_DATE); // EA 시작날짜를 표시하기 위해 시작일을 변수로 저장
//********************************************************************
// 5 digit broker adjustment
if(MarketInfo(Symbol(), MODE_DIGITS)==3 || MarketInfo(Symbol(), MODE_DIGITS)==5)
{
mypoint = 10;
}
else
{
mypoint = 1;
}
}
//********************************************************************
//| 종료시 설정 |
//********************************************************************
int deinit()
{
return(0);
}
//********************************************************************
//| EA Start |
//********************************************************************
int start()
{
//********************************************************************
// StopOut Balance도달시 강제청산함수 가져오기
StopOutClose();
//********************************************************************
// 개별 통화쌍 변수설정
string symbol_01 = "AUDUSD" + subfix;
string symbol_02 = "EURUSD" + subfix;
string symbol_03 = "USDCHF" + subfix;
string symbol_04 = "NZDUSD" + subfix;
string symbol_05 = "GBPUSD" + subfix;
string symbol_06 = "USDJPY" + subfix;
string symbol_07 = "USDCAD" + subfix;
string symbol_08 = "GBPJPY" + subfix;
string symbol_09 = "EURJPY" + subfix;
string symbol_10 = "AUDJPY" + subfix;
string symbol_11 = "NZDJPY" + subfix;
string symbol_12 = "CADJPY" + subfix;
string symbol_13 = "CHFJPY" + subfix;
string symbol_14 = "GBPAUD" + subfix;
string symbol_15 = "EURAUD" + subfix;
string symbol_16 = "AUDNZD" + subfix;
string symbol_17 = "AUDCHF" + subfix;
string symbol_18 = "AUDCAD" + subfix;
string symbol_19 = "GBPCAD" + subfix;
string symbol_20 = "EURCAD" + subfix;
string symbol_21 = "NZDCAD" + subfix;
string symbol_22 = "CADCHF" + subfix;
string symbol_23 = "GBPNZD" + subfix;
string symbol_24 = "EURNZD" + subfix;
string symbol_25 = "NZDCHF" + subfix;
string symbol_26 = "EURGBP" + subfix;
string symbol_27 = "EURCHF" + subfix;
string symbol_28 = "GBPCHF" + subfix;
//********************************************************************
// 데이타 다운로드 미비에 의한 오류계산 방지 로직
if(iBars(symbol_01, PERIOD_H4)<periods) Print ("아! "+symbol_01+" Bar가 모자라");
if(iBars(symbol_02, PERIOD_H4)<periods) Print ("아! "+symbol_02+" Bar가 모자라");
if(iBars(symbol_03, PERIOD_H4)<periods) Print ("아! "+symbol_03+" Bar가 모자라");
if(iBars(symbol_04, PERIOD_H4)<periods) Print ("아! "+symbol_04+" Bar가 모자라");
if(iBars(symbol_05, PERIOD_H4)<periods) Print ("아! "+symbol_05+" Bar가 모자라");
if(iBars(symbol_06, PERIOD_H4)<periods) Print ("아! "+symbol_06+" Bar가 모자라");
if(iBars(symbol_07, PERIOD_H4)<periods) Print ("아! "+symbol_07+" Bar가 모자라");
if(iBars(symbol_08, PERIOD_H4)<periods) Print ("아! "+symbol_08+" Bar가 모자라");
if(iBars(symbol_09, PERIOD_H4)<periods) Print ("아! "+symbol_09+" Bar가 모자라");
if(iBars(symbol_10, PERIOD_H4)<periods) Print ("아! "+symbol_10+" Bar가 모자라");
if(iBars(symbol_11, PERIOD_H4)<periods) Print ("아! "+symbol_11+" Bar가 모자라");
if(iBars(symbol_12, PERIOD_H4)<periods) Print ("아! "+symbol_12+" Bar가 모자라");
if(iBars(symbol_13, PERIOD_H4)<periods) Print ("아! "+symbol_13+" Bar가 모자라");
if(iBars(symbol_14, PERIOD_H4)<periods) Print ("아! "+symbol_14+" Bar가 모자라");
if(iBars(symbol_15, PERIOD_H4)<periods) Print ("아! "+symbol_15+" Bar가 모자라");
if(iBars(symbol_16, PERIOD_H4)<periods) Print ("아! "+symbol_16+" Bar가 모자라");
if(iBars(symbol_17, PERIOD_H4)<periods) Print ("아! "+symbol_17+" Bar가 모자라");
if(iBars(symbol_18, PERIOD_H4)<periods) Print ("아! "+symbol_18+" Bar가 모자라");
if(iBars(symbol_19, PERIOD_H4)<periods) Print ("아! "+symbol_19+" Bar가 모자라");
if(iBars(symbol_20, PERIOD_H4)<periods) Print ("아! "+symbol_20+" Bar가 모자라");
if(iBars(symbol_21, PERIOD_H4)<periods) Print ("아! "+symbol_21+" Bar가 모자라");
if(iBars(symbol_22, PERIOD_H4)<periods) Print ("아! "+symbol_22+" Bar가 모자라");
if(iBars(symbol_23, PERIOD_H4)<periods) Print ("아! "+symbol_23+" Bar가 모자라");
if(iBars(symbol_24, PERIOD_H4)<periods) Print ("아! "+symbol_24+" Bar가 모자라");
if(iBars(symbol_25, PERIOD_H4)<periods) Print ("아! "+symbol_25+" Bar가 모자라");
if(iBars(symbol_26, PERIOD_H4)<periods) Print ("아! "+symbol_26+" Bar가 모자라");
if(iBars(symbol_27, PERIOD_H4)<periods) Print ("아! "+symbol_27+" Bar가 모자라");
if(iBars(symbol_28, PERIOD_H4)<periods) Print ("아! "+symbol_28+" Bar가 모자라");
//********************************************************************
// 통화별 매직넘버 가져오기
int magic01 = 10103971;
int magic02 = 20103971;
int magic03 = 30103971;
int magic04 = 40103971;
int magic05 = 50103971;
int magic06 = 60103971;
int magic07 = 70103971;
int magic08 = 80103971;
int magic09 = 90103971;
int magic10 = 10003971;
int magic11 = 11003971;
int magic12 = 12003971;
int magic13 = 13003971;
int magic14 = 14003971;
int magic15 = 15003971;
int magic16 = 16003971;
int magic17 = 17003971;
int magic18 = 18003971;
int magic19 = 19003971;
int magic20 = 20003971;
int magic21 = 21003971;
int magic22 = 22003971;
int magic23 = 23003971;
int magic24 = 24003971;
int magic25 = 25003971;
int magic26 = 26003971;
int magic27 = 27003971;
int magic28 = 28003971;
//********************************************************************
// Max Spread 초과시 진입금지 로직
if(TradeEnable(symbol_01)==false || !PairTrade01) PairTrade01 = FALSE;
else PairTrade01 = TRUE;
if(TradeEnable(symbol_02)==false || !PairTrade02) PairTrade02 = FALSE;
else PairTrade02 = TRUE;
if(TradeEnable(symbol_03)==false || !PairTrade03) PairTrade03 = FALSE;
else PairTrade03 = TRUE;
if(TradeEnable(symbol_04)==false || !PairTrade04) PairTrade04 = FALSE;
else PairTrade04 = TRUE;
if(TradeEnable(symbol_05)==false || !PairTrade05) PairTrade05 = FALSE;
else PairTrade05 = TRUE;
if(TradeEnable(symbol_06)==false || !PairTrade06) PairTrade06 = FALSE;
else PairTrade06 = TRUE;
if(TradeEnable(symbol_07)==false || !PairTrade07) PairTrade07 = FALSE;
else PairTrade07 = TRUE;
if(TradeEnable(symbol_08)==false || !PairTrade08) PairTrade08 = FALSE;
else PairTrade08 = TRUE;
if(TradeEnable(symbol_09)==false || !PairTrade09) PairTrade09 = FALSE;
else PairTrade09 = TRUE;
if(TradeEnable(symbol_10)==false || !PairTrade10) PairTrade10 = FALSE;
else PairTrade10 = TRUE;
if(TradeEnable(symbol_11)==false || !PairTrade11) PairTrade11 = FALSE;
else PairTrade11 = TRUE;
if(TradeEnable(symbol_12)==false || !PairTrade12) PairTrade12 = FALSE;
else PairTrade12 = TRUE;
if(TradeEnable(symbol_13)==false || !PairTrade13) PairTrade13 = FALSE;
else PairTrade13 = TRUE;
if(TradeEnable(symbol_14)==false || !PairTrade14) PairTrade14 = FALSE;
else PairTrade14 = TRUE;
if(TradeEnable(symbol_15)==false || !PairTrade15) PairTrade15 = FALSE;
else PairTrade15 = TRUE;
if(TradeEnable(symbol_16)==false || !PairTrade16) PairTrade16 = FALSE;
else PairTrade16 = TRUE;
if(TradeEnable(symbol_17)==false || !PairTrade17) PairTrade17 = FALSE;
else PairTrade17 = TRUE;
if(TradeEnable(symbol_18)==false || !PairTrade18) PairTrade18 = FALSE;
else PairTrade18 = TRUE;
if(TradeEnable(symbol_19)==false || !PairTrade19) PairTrade19 = FALSE;
else PairTrade19 = TRUE;
if(TradeEnable(symbol_20)==false || !PairTrade20) PairTrade20 = FALSE;
else PairTrade20 = TRUE;
if(TradeEnable(symbol_21)==false || !PairTrade21) PairTrade21 = FALSE;
else PairTrade21 = TRUE;
if(TradeEnable(symbol_22)==false || !PairTrade22) PairTrade22 = FALSE;
else PairTrade22 = TRUE;
if(TradeEnable(symbol_23)==false || !PairTrade23) PairTrade23 = FALSE;
else PairTrade23 = TRUE;
if(TradeEnable(symbol_24)==false || !PairTrade24) PairTrade24 = FALSE;
else PairTrade24 = TRUE;
if(TradeEnable(symbol_25)==false || !PairTrade25) PairTrade25 = FALSE;
else PairTrade25 = TRUE;
if(TradeEnable(symbol_26)==false || !PairTrade26) PairTrade26 = FALSE;
else PairTrade26 = TRUE;
if(TradeEnable(symbol_27)==false || !PairTrade27) PairTrade27 = FALSE;
else PairTrade27 = TRUE;
if(TradeEnable(symbol_28)==false || !PairTrade28) PairTrade28 = FALSE;
else PairTrade28 = TRUE;
//********************************************************************
//| Date/Time Filter |
//********************************************************************
bool EntryEnabled = FALSE;
if ( DayOfWeek() == 0 || DayOfWeek() == 6 ) EntryEnabled = FALSE;
if (NewBar() && DayFilter()) EntryEnabled = TRUE;
else EntryEnabled = FALSE;
/*
if(TrailingStop>0) MoveTrailingStop();
if(BreakEven>0) MoveBreakEven();
*/
//********************************************************************
//| Entry Logic |
//********************************************************************
bool USD_Weak = FALSE;
bool EUR_Weak = FALSE;
bool GBP_Weak = FALSE;
bool JPY_Weak = FALSE;
bool CHF_Weak = FALSE;
bool CAD_Weak = FALSE;
bool AUD_Weak = FALSE;
bool NZD_Weak = FALSE;
if(USD_WPR(1,1) if(EUR_WPR(1,1) if(GBP_WPR(1,1) if(JPY_WPR(1,1) if(CHF_WPR(1,1) if(CAD_WPR(1,1) if(AUD_WPR(1,1) if(NZD_WPR(1,1)
bool USD_Strong = FALSE;
bool EUR_Strong = FALSE;
bool GBP_Strong = FALSE;
bool JPY_Strong = FALSE;
bool CHF_Strong = FALSE;
bool CAD_Strong = FALSE;
bool AUD_Strong = FALSE;
bool NZD_Strong = FALSE;
if(USD_WPR(1,1)>strongvalue && USD_WPR(5,1)>strongvalue && USD_WPR(15,1)>strongvalue && USD_WPR(30,1)>strongvalue && USD_WPR(60,1)>strongvalue && USD_WPR(240,1)>strongvalue) USD_Strong = TRUE;
if(EUR_WPR(1,1)>strongvalue && EUR_WPR(5,1)>strongvalue && EUR_WPR(15,1)>strongvalue && EUR_WPR(30,1)>strongvalue && EUR_WPR(60,1)>strongvalue && EUR_WPR(240,1)>strongvalue) EUR_Strong = TRUE;
if(GBP_WPR(1,1)>strongvalue && GBP_WPR(5,1)>strongvalue && GBP_WPR(15,1)>strongvalue && GBP_WPR(30,1)>strongvalue && GBP_WPR(60,1)>strongvalue && GBP_WPR(240,1)>strongvalue) GBP_Strong = TRUE;
if(JPY_WPR(1,1)>strongvalue && JPY_WPR(5,1)>strongvalue && JPY_WPR(15,1)>strongvalue && JPY_WPR(30,1)>strongvalue && JPY_WPR(60,1)>strongvalue && JPY_WPR(240,1)>strongvalue) JPY_Strong = TRUE;
if(CHF_WPR(1,1)>strongvalue && CHF_WPR(5,1)>strongvalue && CHF_WPR(15,1)>strongvalue && CHF_WPR(30,1)>strongvalue && CHF_WPR(60,1)>strongvalue && CHF_WPR(240,1)>strongvalue) CHF_Strong = TRUE;
if(CAD_WPR(1,1)>strongvalue && CAD_WPR(5,1)>strongvalue && CAD_WPR(15,1)>strongvalue && CAD_WPR(30,1)>strongvalue && CAD_WPR(60,1)>strongvalue && CAD_WPR(240,1)>strongvalue) CAD_Strong = TRUE;
if(AUD_WPR(1,1)>strongvalue && AUD_WPR(5,1)>strongvalue && AUD_WPR(15,1)>strongvalue && AUD_WPR(30,1)>strongvalue && AUD_WPR(60,1)>strongvalue && AUD_WPR(240,1)>strongvalue) AUD_Strong = TRUE;
if(NZD_WPR(1,1)>strongvalue && NZD_WPR(5,1)>strongvalue && NZD_WPR(15,1)>strongvalue && NZD_WPR(30,1)>strongvalue && NZD_WPR(60,1)>strongvalue && NZD_WPR(240,1)>strongvalue) NZD_Strong = TRUE;
if(USD_WPR(1,1)*USD_WPR(5,1)*USD_WPR(15,1)*USD_WPR(30,1)*USD_WPR(60,1)*USD_WPR(240,1)==0) USD_Weak = FALSE;
if(EUR_WPR(1,1)*EUR_WPR(5,1)*EUR_WPR(15,1)*EUR_WPR(30,1)*EUR_WPR(60,1)*EUR_WPR(240,1)==0) EUR_Weak = FALSE;
if(GBP_WPR(1,1)*GBP_WPR(5,1)*GBP_WPR(15,1)*GBP_WPR(30,1)*GBP_WPR(60,1)*GBP_WPR(240,1)==0) GBP_Weak = FALSE;
if(JPY_WPR(1,1)*JPY_WPR(5,1)*JPY_WPR(15,1)*JPY_WPR(30,1)*JPY_WPR(60,1)*JPY_WPR(240,1)==0) JPY_Weak = FALSE;
if(CHF_WPR(1,1)*CHF_WPR(5,1)*CHF_WPR(15,1)*CHF_WPR(30,1)*CHF_WPR(60,1)*CHF_WPR(240,1)==0) CHF_Weak = FALSE;
if(CAD_WPR(1,1)*CAD_WPR(5,1)*CAD_WPR(15,1)*CAD_WPR(30,1)*CAD_WPR(60,1)*CAD_WPR(240,1)==0) CAD_Weak = FALSE;
if(AUD_WPR(1,1)*AUD_WPR(5,1)*AUD_WPR(15,1)*AUD_WPR(30,1)*AUD_WPR(60,1)*AUD_WPR(240,1)==0) AUD_Weak = FALSE;
if(NZD_WPR(1,1)*NZD_WPR(5,1)*NZD_WPR(15,1)*NZD_WPR(30,1)*NZD_WPR(60,1)*NZD_WPR(240,1)==0) NZD_Weak = FALSE;
//********************************************************************
//| Close Condition Function |
//********************************************************************
//********************************************************************
// TP, SL 도달시 청산(Hidden TP, SL)
if(Profit(magic01)>XTP || Profit(magic01)<-XSL) CloseAllOpens(magic01);
if(Profit(magic02)>XTP || Profit(magic02)<-XSL) CloseAllOpens(magic02);
if(Profit(magic03)>XTP || Profit(magic03)<-XSL) CloseAllOpens(magic03);
if(Profit(magic04)>XTP || Profit(magic04)<-XSL) CloseAllOpens(magic04);
if(Profit(magic05)>XTP || Profit(magic05)<-XSL) CloseAllOpens(magic05);
if(Profit(magic06)>XTP || Profit(magic06)<-XSL) CloseAllOpens(magic06);
if(Profit(magic07)>XTP || Profit(magic07)<-XSL) CloseAllOpens(magic07);
if(Profit(magic08)>XTP || Profit(magic08)<-XSL) CloseAllOpens(magic08);
if(Profit(magic09)>XTP || Profit(magic09)<-XSL) CloseAllOpens(magic09);
if(Profit(magic10)>XTP || Profit(magic10)<-XSL) CloseAllOpens(magic10);
if(Profit(magic11)>XTP || Profit(magic11)<-XSL) CloseAllOpens(magic11);
if(Profit(magic12)>XTP || Profit(magic12)<-XSL) CloseAllOpens(magic12);
if(Profit(magic13)>XTP || Profit(magic13)<-XSL) CloseAllOpens(magic13);
if(Profit(magic14)>XTP || Profit(magic14)<-XSL) CloseAllOpens(magic14);
if(Profit(magic15)>XTP || Profit(magic15)<-XSL) CloseAllOpens(magic15);
if(Profit(magic16)>XTP || Profit(magic16)<-XSL) CloseAllOpens(magic16);
if(Profit(magic17)>XTP || Profit(magic17)<-XSL) CloseAllOpens(magic17);
if(Profit(magic18)>XTP || Profit(magic18)<-XSL) CloseAllOpens(magic18);
if(Profit(magic19)>XTP || Profit(magic19)<-XSL) CloseAllOpens(magic19);
if(Profit(magic20)>XTP || Profit(magic20)<-XSL) CloseAllOpens(magic20);
if(Profit(magic21)>XTP || Profit(magic21)<-XSL) CloseAllOpens(magic21);
if(Profit(magic22)>XTP || Profit(magic22)<-XSL) CloseAllOpens(magic22);
if(Profit(magic23)>XTP || Profit(magic23)<-XSL) CloseAllOpens(magic23);
if(Profit(magic24)>XTP || Profit(magic24)<-XSL) CloseAllOpens(magic24);
if(Profit(magic25)>XTP || Profit(magic25)<-XSL) CloseAllOpens(magic25);
if(Profit(magic26)>XTP || Profit(magic26)<-XSL) CloseAllOpens(magic26);
if(Profit(magic27)>XTP || Profit(magic27)<-XSL) CloseAllOpens(magic27);
if(Profit(magic28)>XTP || Profit(magic28)<-XSL) CloseAllOpens(magic28);
//********************************************************************
//| Close All Function |
//********************************************************************
//********************************************************************
// 전체수익이나 손실이 설정치 이상인 경우 Close All
double bprofit01 = BProfit(magic01)+BProfit(magic02)+BProfit(magic03)+BProfit(magic04)+BProfit(magic05)+BProfit(magic06)+BProfit(magic07)+BProfit(magic08)+BProfit(magic09)+BProfit(magic10);
double bprofit02 = BProfit(magic11)+BProfit(magic12)+BProfit(magic13)+BProfit(magic14)+BProfit(magic15)+BProfit(magic16)+BProfit(magic17)+BProfit(magic18)+BProfit(magic19)+BProfit(magic20);
double bprofit03 = BProfit(magic21)+BProfit(magic22)+BProfit(magic23)+BProfit(magic24)+BProfit(magic25)+BProfit(magic26)+BProfit(magic27)+BProfit(magic28);
double bprofits = bprofit01+bprofit02+bprofit03;
double sprofit01 = SProfit(magic01)+SProfit(magic02)+SProfit(magic03)+SProfit(magic04)+SProfit(magic05)+SProfit(magic06)+SProfit(magic07)+SProfit(magic08)+SProfit(magic09)+SProfit(magic10);
double sprofit02 = SProfit(magic11)+SProfit(magic12)+SProfit(magic13)+SProfit(magic14)+SProfit(magic15)+SProfit(magic16)+SProfit(magic17)+SProfit(magic18)+SProfit(magic19)+SProfit(magic20);
double sprofit03 = SProfit(magic21)+SProfit(magic22)+SProfit(magic23)+SProfit(magic24)+SProfit(magic25)+SProfit(magic26)+SProfit(magic27)+SProfit(magic28);
double sprofits = sprofit01+sprofit02+sprofit03;
double profits = bprofits+sprofits;
if(profits>All_TP || profits<-All_SL) {
if(TotalOrders(magic01)>0) CloseAllOpens(magic01);
if(TotalOrders(magic02)>0) CloseAllOpens(magic02);
if(TotalOrders(magic03)>0) CloseAllOpens(magic03);
if(TotalOrders(magic04)>0) CloseAllOpens(magic04);
if(TotalOrders(magic05)>0) CloseAllOpens(magic05);
if(TotalOrders(magic06)>0) CloseAllOpens(magic06);
if(TotalOrders(magic07)>0) CloseAllOpens(magic07);
if(TotalOrders(magic08)>0) CloseAllOpens(magic08);
if(TotalOrders(magic09)>0) CloseAllOpens(magic09);
if(TotalOrders(magic10)>0) CloseAllOpens(magic10);
if(TotalOrders(magic11)>0) CloseAllOpens(magic11);
if(TotalOrders(magic12)>0) CloseAllOpens(magic12);
if(TotalOrders(magic13)>0) CloseAllOpens(magic13);
if(TotalOrders(magic14)>0) CloseAllOpens(magic14);
if(TotalOrders(magic15)>0) CloseAllOpens(magic15);
if(TotalOrders(magic16)>0) CloseAllOpens(magic16);
if(TotalOrders(magic17)>0) CloseAllOpens(magic17);
if(TotalOrders(magic18)>0) CloseAllOpens(magic18);
if(TotalOrders(magic19)>0) CloseAllOpens(magic19);
if(TotalOrders(magic20)>0) CloseAllOpens(magic20);
if(TotalOrders(magic21)>0) CloseAllOpens(magic21);
if(TotalOrders(magic22)>0) CloseAllOpens(magic22);
if(TotalOrders(magic23)>0) CloseAllOpens(magic23);
if(TotalOrders(magic24)>0) CloseAllOpens(magic24);
if(TotalOrders(magic25)>0) CloseAllOpens(magic25);
if(TotalOrders(magic26)>0) CloseAllOpens(magic26);
if(TotalOrders(magic27)>0) CloseAllOpens(magic27);
if(TotalOrders(magic28)>0) CloseAllOpens(magic28);
}
//********************************************************************
//| Buy/Sell Condition Function |
//********************************************************************
//********************************************************************
// Buy Condition
bool BuyCon01 = FALSE;
bool BuyCon02 = FALSE;
bool BuyCon03 = FALSE;
bool BuyCon04 = FALSE;
bool BuyCon05 = FALSE;
bool BuyCon06 = FALSE;
bool BuyCon07 = FALSE;
bool BuyCon08 = FALSE;
bool BuyCon09 = FALSE;
bool BuyCon10 = FALSE;
bool BuyCon11 = FALSE;
bool BuyCon12 = FALSE;
bool BuyCon13 = FALSE;
bool BuyCon14 = FALSE;
bool BuyCon15 = FALSE;
bool BuyCon16 = FALSE;
bool BuyCon17 = FALSE;
bool BuyCon18 = FALSE;
bool BuyCon19 = FALSE;
bool BuyCon20 = FALSE;
bool BuyCon21 = FALSE;
bool BuyCon22 = FALSE;
bool BuyCon23 = FALSE;
bool BuyCon24 = FALSE;
bool BuyCon25 = FALSE;
bool BuyCon26 = FALSE;
bool BuyCon27 = FALSE;
bool BuyCon28 = FALSE;
if(AUD_Strong && USD_Weak) BuyCon01 = TRUE;
else BuyCon01 = FALSE;
if(EUR_Strong && USD_Weak) BuyCon02 = TRUE;
else BuyCon02 = FALSE;
if(USD_Strong && CHF_Weak) BuyCon03 = TRUE;
else BuyCon03 = FALSE;
if(NZD_Strong && USD_Weak) BuyCon04 = TRUE;
else BuyCon04 = FALSE;
if(GBP_Strong && USD_Weak) BuyCon05 = TRUE;
else BuyCon05 = FALSE;
if(USD_Strong && JPY_Weak) BuyCon06 = TRUE;
else BuyCon06 = FALSE;
if(USD_Strong && CAD_Weak) BuyCon07 = TRUE;
else BuyCon07 = FALSE;
if(GBP_Strong && JPY_Weak) BuyCon08 = TRUE;
else BuyCon08 = FALSE;
if(EUR_Strong && JPY_Weak) BuyCon09 = TRUE;
else BuyCon09 = FALSE;
if(AUD_Strong && JPY_Weak) BuyCon10 = TRUE;
else BuyCon10 = FALSE;
if(NZD_Strong && JPY_Weak) BuyCon11 = TRUE;
else BuyCon11 = FALSE;
if(CAD_Strong && JPY_Weak) BuyCon12 = TRUE;
else BuyCon12 = FALSE;
if(CHF_Strong && JPY_Weak) BuyCon13 = TRUE;
else BuyCon13 = FALSE;
if(GBP_Strong && AUD_Weak) BuyCon14 = TRUE;
else BuyCon14 = FALSE;
if(EUR_Strong && AUD_Weak) BuyCon15 = TRUE;
else BuyCon15 = FALSE;
if(AUD_Strong && NZD_Weak) BuyCon16 = TRUE;
else BuyCon16 = FALSE;
if(AUD_Strong && CHF_Weak) BuyCon17 = TRUE;
else BuyCon17 = FALSE;
if(AUD_Strong && CAD_Weak) BuyCon18 = TRUE;
else BuyCon18 = FALSE;
if(GBP_Strong && CAD_Weak) BuyCon19 = TRUE;
else BuyCon19 = FALSE;
if(EUR_Strong && CAD_Weak) BuyCon20 = TRUE;
else BuyCon20 = FALSE;
if(NZD_Strong && CAD_Weak) BuyCon21 = TRUE;
else BuyCon21 = FALSE;
if(CAD_Strong && CHF_Weak) BuyCon22 = TRUE;
else BuyCon22 = FALSE;
if(GBP_Strong && NZD_Weak) BuyCon23 = TRUE;
else BuyCon23 = FALSE;
if(EUR_Strong && NZD_Weak) BuyCon24 = TRUE;
else BuyCon24 = FALSE;
if(NZD_Strong && CHF_Weak) BuyCon25 = TRUE;
else BuyCon25 = FALSE;
if(EUR_Strong && GBP_Weak) BuyCon26 = TRUE;
else BuyCon26 = FALSE;
if(EUR_Strong && CHF_Weak) BuyCon27 = TRUE;
else BuyCon27 = FALSE;
if(GBP_Strong && CHF_Weak) BuyCon28 = TRUE;
else BuyCon28 = FALSE;
if(EntryEnabled && PairTrade01 && TotalOrders(magic01) if(EntryEnabled && PairTrade02 && TotalOrders(magic02) if(EntryEnabled && PairTrade03 && TotalOrders(magic03) if(EntryEnabled && PairTrade04 && TotalOrders(magic04) if(EntryEnabled && PairTrade05 && TotalOrders(magic05) if(EntryEnabled && PairTrade06 && TotalOrders(magic06) if(EntryEnabled && PairTrade07 && TotalOrders(magic07) if(EntryEnabled && PairTrade08 && TotalOrders(magic08) if(EntryEnabled && PairTrade09 && TotalOrders(magic09) if(EntryEnabled && PairTrade10 && TotalOrders(magic10) if(EntryEnabled && PairTrade11 && TotalOrders(magic11) if(EntryEnabled && PairTrade12 && TotalOrders(magic12) if(EntryEnabled && PairTrade13 && TotalOrders(magic13) if(EntryEnabled && PairTrade14 && TotalOrders(magic14) if(EntryEnabled && PairTrade15 && TotalOrders(magic15) if(EntryEnabled && PairTrade16 && TotalOrders(magic16) if(EntryEnabled && PairTrade17 && TotalOrders(magic17) if(EntryEnabled && PairTrade18 && TotalOrders(magic18) if(EntryEnabled && PairTrade19 && TotalOrders(magic19) if(EntryEnabled && PairTrade20 && TotalOrders(magic20) if(EntryEnabled && PairTrade21 && TotalOrders(magic21) if(EntryEnabled && PairTrade22 && TotalOrders(magic22) if(EntryEnabled && PairTrade23 && TotalOrders(magic23) if(EntryEnabled && PairTrade24 && TotalOrders(magic24) if(EntryEnabled && PairTrade25 && TotalOrders(magic25) if(EntryEnabled && PairTrade26 && TotalOrders(magic26) if(EntryEnabled && PairTrade27 && TotalOrders(magic27) if(EntryEnabled && PairTrade28 && TotalOrders(magic28)
//********************************************************************
// Sell Condition
bool SellCon01 = FALSE;
bool SellCon02 = FALSE;
bool SellCon03 = FALSE;
bool SellCon04 = FALSE;
bool SellCon05 = FALSE;
bool SellCon06 = FALSE;
bool SellCon07 = FALSE;
bool SellCon08 = FALSE;
bool SellCon09 = FALSE;
bool SellCon10 = FALSE;
bool SellCon11 = FALSE;
bool SellCon12 = FALSE;
bool SellCon13 = FALSE;
bool SellCon14 = FALSE;
bool SellCon15 = FALSE;
bool SellCon16 = FALSE;
bool SellCon17 = FALSE;
bool SellCon18 = FALSE;
bool SellCon19 = FALSE;
bool SellCon20 = FALSE;
bool SellCon21 = FALSE;
bool SellCon22 = FALSE;
bool SellCon23 = FALSE;
bool SellCon24 = FALSE;
bool SellCon25 = FALSE;
bool SellCon26 = FALSE;
bool SellCon27 = FALSE;
bool SellCon28 = FALSE;
if(AUD_Weak && USD_Strong) SellCon01 = TRUE;
else SellCon01 = FALSE;
if(EUR_Weak && USD_Strong) SellCon02 = TRUE;
else SellCon02 = FALSE;
if(USD_Weak && CHF_Strong) SellCon03 = TRUE;
else SellCon03 = FALSE;
if(NZD_Weak && USD_Strong) SellCon04 = TRUE;
else SellCon04 = FALSE;
if(GBP_Weak && USD_Strong) SellCon05 = TRUE;
else SellCon05 = FALSE;
if(USD_Weak && JPY_Strong) SellCon06 = TRUE;
else SellCon06 = FALSE;
if(USD_Weak && CAD_Strong) SellCon07 = TRUE;
else SellCon07 = FALSE;
if(GBP_Weak && JPY_Strong) SellCon08 = TRUE;
else SellCon08 = FALSE;
if(EUR_Weak && JPY_Strong) SellCon09 = TRUE;
else SellCon09 = FALSE;
if(AUD_Weak && JPY_Strong) SellCon10 = TRUE;
else SellCon10 = FALSE;
if(NZD_Weak && JPY_Strong) SellCon11 = TRUE;
else SellCon11 = FALSE;
if(CAD_Weak && JPY_Strong) SellCon12 = TRUE;
else SellCon12 = FALSE;
if(CHF_Weak && JPY_Strong) SellCon13 = TRUE;
else SellCon13 = FALSE;
if(GBP_Weak && AUD_Strong) SellCon14 = TRUE;
else SellCon14 = FALSE;
if(EUR_Weak && AUD_Strong) SellCon15 = TRUE;
else SellCon15 = FALSE;
if(AUD_Weak && NZD_Strong) SellCon16 = TRUE;
else SellCon16 = FALSE;
if(AUD_Weak && CHF_Strong) SellCon17 = TRUE;
else SellCon17 = FALSE;
if(AUD_Weak && CAD_Strong) SellCon18 = TRUE;
else SellCon18 = FALSE;
if(GBP_Weak && CAD_Strong) SellCon19 = TRUE;
else SellCon19 = FALSE;
if(EUR_Weak && CAD_Strong) SellCon20 = TRUE;
else SellCon20 = FALSE;
if(NZD_Weak && CAD_Strong) SellCon21 = TRUE;
else SellCon21 = FALSE;
if(CAD_Weak && CHF_Strong) SellCon22 = TRUE;
else SellCon22 = FALSE;
if(GBP_Weak && NZD_Strong) SellCon23 = TRUE;
else SellCon23 = FALSE;
if(EUR_Weak && NZD_Strong) SellCon24 = TRUE;
else SellCon24 = FALSE;
if(NZD_Weak && CHF_Strong) SellCon25 = TRUE;
else SellCon25 = FALSE;
if(EUR_Weak && GBP_Strong) SellCon26 = TRUE;
else SellCon26 = FALSE;
if(EUR_Weak && CHF_Strong) SellCon27 = TRUE;
else SellCon27 = FALSE;
if(GBP_Weak && CHF_Strong) SellCon28 = TRUE;
else SellCon28 = FALSE;
if(EntryEnabled && PairTrade01 && TotalOrders(magic01) if(EntryEnabled && PairTrade02 && TotalOrders(magic02) if(EntryEnabled && PairTrade03 && TotalOrders(magic03) if(EntryEnabled && PairTrade04 && TotalOrders(magic04) if(EntryEnabled && PairTrade05 && TotalOrders(magic05) if(EntryEnabled && PairTrade06 && TotalOrders(magic06) if(EntryEnabled && PairTrade07 && TotalOrders(magic07) if(EntryEnabled && PairTrade08 && TotalOrders(magic08) if(EntryEnabled && PairTrade09 && TotalOrders(magic09) if(EntryEnabled && PairTrade10 && TotalOrders(magic10) if(EntryEnabled && PairTrade11 && TotalOrders(magic11) if(EntryEnabled && PairTrade12 && TotalOrders(magic12) if(EntryEnabled && PairTrade13 && TotalOrders(magic13) if(EntryEnabled && PairTrade14 && TotalOrders(magic14) if(EntryEnabled && PairTrade15 && TotalOrders(magic15) if(EntryEnabled && PairTrade16 && TotalOrders(magic16) if(EntryEnabled && PairTrade17 && TotalOrders(magic17) if(EntryEnabled && PairTrade18 && TotalOrders(magic18) if(EntryEnabled && PairTrade19 && TotalOrders(magic19) if(EntryEnabled && PairTrade20 && TotalOrders(magic20) if(EntryEnabled && PairTrade21 && TotalOrders(magic21) if(EntryEnabled && PairTrade22 && TotalOrders(magic22) if(EntryEnabled && PairTrade23 && TotalOrders(magic23) if(EntryEnabled && PairTrade24 && TotalOrders(magic24) if(EntryEnabled && PairTrade25 && TotalOrders(magic25) if(EntryEnabled && PairTrade26 && TotalOrders(magic26) if(EntryEnabled && PairTrade27 && TotalOrders(magic27) if(EntryEnabled && PairTrade28 && TotalOrders(magic28)
//********************************************************************
//| 전송 데이타와 전송받은 데이타 화면표시 |
//********************************************************************
int border01 = TotalBuyOrders(magic01)+TotalBuyOrders(magic02)+TotalBuyOrders(magic03)+TotalBuyOrders(magic04)+TotalBuyOrders(magic05)+TotalBuyOrders(magic06)+TotalBuyOrders(magic07)+TotalBuyOrders(magic08)+TotalBuyOrders(magic09)+TotalBuyOrders(magic10);
int border02 = TotalBuyOrders(magic11)+TotalBuyOrders(magic12)+TotalBuyOrders(magic13)+TotalBuyOrders(magic14)+TotalBuyOrders(magic15)+TotalBuyOrders(magic16)+TotalBuyOrders(magic17)+TotalBuyOrders(magic18)+TotalBuyOrders(magic19)+TotalBuyOrders(magic20);
int border03 = TotalBuyOrders(magic21)+TotalBuyOrders(magic22)+TotalBuyOrders(magic23)+TotalBuyOrders(magic24)+TotalBuyOrders(magic25)+TotalBuyOrders(magic26)+TotalBuyOrders(magic27)+TotalBuyOrders(magic28);
int borders = border01+border02+border03;
int sorder01 = TotalSellOrders(magic01)+TotalSellOrders(magic02)+TotalSellOrders(magic03)+TotalSellOrders(magic04)+TotalSellOrders(magic05)+TotalSellOrders(magic06)+TotalSellOrders(magic07)+TotalSellOrders(magic08)+TotalSellOrders(magic09)+TotalSellOrders(magic10);
int sorder02 = TotalSellOrders(magic11)+TotalSellOrders(magic12)+TotalSellOrders(magic13)+TotalSellOrders(magic14)+TotalSellOrders(magic15)+TotalSellOrders(magic16)+TotalSellOrders(magic17)+TotalSellOrders(magic18)+TotalSellOrders(magic19)+TotalSellOrders(magic20);
int sorder03 = TotalSellOrders(magic21)+TotalSellOrders(magic22)+TotalSellOrders(magic23)+TotalSellOrders(magic24)+TotalSellOrders(magic25)+TotalSellOrders(magic26)+TotalSellOrders(magic27)+TotalSellOrders(magic28);
int sorders = sorder01+sorder02+sorder03;
int orders = borders+sorders;
double hbprofit01 = HBProfit(magic01)+HBProfit(magic02)+HBProfit(magic03)+HBProfit(magic04)+HBProfit(magic05)+HBProfit(magic06)+HBProfit(magic07)+HBProfit(magic08)+HBProfit(magic09)+HBProfit(magic10);
double hbprofit02 = HBProfit(magic11)+HBProfit(magic12)+HBProfit(magic13)+HBProfit(magic14)+HBProfit(magic15)+HBProfit(magic16)+HBProfit(magic17)+HBProfit(magic18)+HBProfit(magic19)+HBProfit(magic20);
double hbprofit03 = HBProfit(magic21)+HBProfit(magic22)+HBProfit(magic23)+HBProfit(magic24)+HBProfit(magic25)+HBProfit(magic26)+HBProfit(magic27)+HBProfit(magic28);
double hbprofit = hbprofit01+hbprofit02+hbprofit03;
double hsprofit01 = HSProfit(magic01)+HSProfit(magic02)+HSProfit(magic03)+HSProfit(magic04)+HSProfit(magic05)+HSProfit(magic06)+HSProfit(magic07)+HSProfit(magic08)+HSProfit(magic09)+HSProfit(magic10);
double hsprofit02 = HSProfit(magic11)+HSProfit(magic12)+HSProfit(magic13)+HSProfit(magic14)+HSProfit(magic15)+HSProfit(magic16)+HSProfit(magic17)+HSProfit(magic18)+HSProfit(magic19)+HSProfit(magic20);
double hsprofit03 = HSProfit(magic21)+HSProfit(magic22)+HSProfit(magic23)+HSProfit(magic24)+HSProfit(magic25)+HSProfit(magic26)+HSProfit(magic27)+HSProfit(magic28);
double hsprofit = hsprofit01+hsprofit02+hsprofit03;
double hprofit = hbprofit+hsprofit;
int hborder01 = HBuyOrders(magic01)+HBuyOrders(magic02)+HBuyOrders(magic03)+HBuyOrders(magic04)+HBuyOrders(magic05)+HBuyOrders(magic06)+HBuyOrders(magic07)+HBuyOrders(magic08)+HBuyOrders(magic09)+HBuyOrders(magic10);
int hborder02 = HBuyOrders(magic11)+HBuyOrders(magic12)+HBuyOrders(magic13)+HBuyOrders(magic14)+HBuyOrders(magic15)+HBuyOrders(magic16)+HBuyOrders(magic17)+HBuyOrders(magic18)+HBuyOrders(magic19)+HBuyOrders(magic20);
int hborder03 = HBuyOrders(magic21)+HBuyOrders(magic22)+HBuyOrders(magic23)+HBuyOrders(magic24)+HBuyOrders(magic25)+HBuyOrders(magic26)+HBuyOrders(magic27)+HBuyOrders(magic28);
int hborders = hborder01+hborder02+hborder03;
int hsorder01 = HSellOrders(magic01)+HSellOrders(magic02)+HSellOrders(magic03)+HSellOrders(magic04)+HSellOrders(magic05)+HSellOrders(magic06)+HSellOrders(magic07)+HSellOrders(magic08)+HSellOrders(magic09)+HSellOrders(magic10);
int hsorder02 = HSellOrders(magic11)+HSellOrders(magic12)+HSellOrders(magic13)+HSellOrders(magic14)+HSellOrders(magic15)+HSellOrders(magic16)+HSellOrders(magic17)+HSellOrders(magic18)+HSellOrders(magic19)+HSellOrders(magic20);
int hsorder03 = HSellOrders(magic21)+HSellOrders(magic22)+HSellOrders(magic23)+HSellOrders(magic24)+HSellOrders(magic25)+HSellOrders(magic26)+HSellOrders(magic27)+HSellOrders(magic28);
int hsorders = hsorder01+hsorder02+hsorder03;
int horders = hborders+hsorders;
string ScreenStr;
ScreenStr = StringConcatenate("Server : ",AccountServer()," Start Day_",StartDay, " , My Time : ",TimeToStr(TimeCurrent(),TIME_SECONDS)," 평가잔액 = ",AccountEquity()," Weak Value_",weakvalue," Strong Value_",strongvalue)+"\n";
ScreenStr = ScreenStr + StringConcatenate("StopLevel : ",MarketInfo(Symbol(), MODE_STOPLEVEL)," , Freeze Level : ",MarketInfo(Symbol(), MODE_FREEZELEVEL)," , StopOut : ",AccountStopoutLevel(),"%, 목표수익 : ",XTP," 목표손실 : ",XSL," 일괄청산수익 : ",All_TP," 일괄청산손실 : ",-All_SL)+"\n";
ScreenStr = ScreenStr + StringConcatenate("USD Strong_",USD_Strong," Weak_",USD_Weak," USD_M1_WPR_",USD_WPR(1,1)," M5_WPR_",USD_WPR(5,1)," M15_WPR_",USD_WPR(15,1)," M30_WPR_",USD_WPR(30,1)," H1_WPR_",USD_WPR(60,1)," H4_WPR_",USD_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("EUR Strong_",EUR_Strong," Weak_",EUR_Weak," EUR_M1_WPR_",EUR_WPR(1,1)," M5_WPR_",EUR_WPR(5,1)," M15_WPR_",EUR_WPR(15,1)," M30_WPR_",EUR_WPR(30,1)," H1_WPR_",EUR_WPR(60,1)," H4_WPR_",EUR_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("GBP Strong_",GBP_Strong," Weak_",GBP_Weak," GBP_M1_WPR_",GBP_WPR(1,1)," M5_WPR_",GBP_WPR(5,1)," M15_WPR_",GBP_WPR(15,1)," M30_WPR_",GBP_WPR(30,1)," H1_WPR_",GBP_WPR(60,1)," H4_WPR_",GBP_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("JPY Strong_",JPY_Strong," Weak_",JPY_Weak," JPY_M1_WPR_",JPY_WPR(1,1)," M5_WPR_",JPY_WPR(5,1)," M15_WPR_",JPY_WPR(15,1)," M30_WPR_",JPY_WPR(30,1)," H1_WPR_",JPY_WPR(60,1)," H4_WPR_",JPY_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("CAD Strong_",CAD_Strong," Weak_",CAD_Weak," CAD_M1_WPR_",CAD_WPR(1,1)," M5_WPR_",CAD_WPR(5,1)," M15_WPR_",CAD_WPR(15,1)," M30_WPR_",CAD_WPR(30,1)," H1_WPR_",CAD_WPR(60,1)," H4_WPR_",CAD_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("CHF Strong_",CHF_Strong," Weak_",CHF_Weak," CHF_M1_WPR_",CHF_WPR(1,1)," M5_WPR_",CHF_WPR(5,1)," M15_WPR_",CHF_WPR(15,1)," M30_WPR_",CHF_WPR(30,1)," H1_WPR_",CHF_WPR(60,1)," H4_WPR_",CHF_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("AUD Strong_",AUD_Strong," Weak_",AUD_Weak," AUD_M1_WPR_",AUD_WPR(1,1)," M5_WPR_",AUD_WPR(5,1)," M15_WPR_",AUD_WPR(15,1)," M30_WPR_",AUD_WPR(30,1)," H1_WPR_",AUD_WPR(60,1)," H4_WPR_",AUD_WPR(240,1))+"\n";
ScreenStr = ScreenStr + StringConcatenate("NZD Strong_",NZD_Strong," Weak_",NZD_Weak," NZD_M1_WPR_",NZD_WPR(1,1)," M5_WPR_",NZD_WPR(5,1)," M15_WPR_",NZD_WPR(15,1)," M30_WPR_",NZD_WPR(30,1)," H1_WPR_",NZD_WPR(60,1)," H4_WPR_",NZD_WPR(240,1))+"\n";
ScreenStr = ScreenStr + "=============================================================================================================================" + "\n";
ScreenStr = ScreenStr + StringConcatenate("Pair01_",symbol_01," TradeEnabled_",PairTrade01," 현재수익_$",Profit(magic01)," 매수건수_",TotalBuyOrders(magic01)," 매도건수_",TotalSellOrders(magic01)," 총수익_$",HistoryProfit(magic01)," 매수수익_$",HBProfit(magic01)," 매수건수_",HBuyOrders(magic01)," 매도수익_$",HSProfit(magic01)," 매도건수_",HSellOrders(magic01)," 총건수_",HOrders(magic01))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair02_",symbol_02," TradeEnabled_",PairTrade02," 현재수익_$",Profit(magic02)," 매수건수_",TotalBuyOrders(magic02)," 매도건수_",TotalSellOrders(magic02)," 총수익_$",HistoryProfit(magic02)," 매수수익_$",HBProfit(magic02)," 매수건수_",HBuyOrders(magic02)," 매도수익_$",HSProfit(magic02)," 매도건수_",HSellOrders(magic02)," 총건수_",HOrders(magic02))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair03_",symbol_03," TradeEnabled_",PairTrade03," 현재수익_$",Profit(magic03)," 매수건수_",TotalBuyOrders(magic03)," 매도건수_",TotalSellOrders(magic03)," 총수익_$",HistoryProfit(magic03)," 매수수익_$",HBProfit(magic03)," 매수건수_",HBuyOrders(magic03)," 매도수익_$",HSProfit(magic03)," 매도건수_",HSellOrders(magic03)," 총건수_",HOrders(magic03))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair04_",symbol_04," TradeEnabled_",PairTrade04," 현재수익_$",Profit(magic04)," 매수건수_",TotalBuyOrders(magic04)," 매도건수_",TotalSellOrders(magic04)," 총수익_$",HistoryProfit(magic04)," 매수수익_$",HBProfit(magic04)," 매수건수_",HBuyOrders(magic04)," 매도수익_$",HSProfit(magic04)," 매도건수_",HSellOrders(magic04)," 총건수_",HOrders(magic04))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair05_",symbol_05," TradeEnabled_",PairTrade05," 현재수익_$",Profit(magic05)," 매수건수_",TotalBuyOrders(magic05)," 매도건수_",TotalSellOrders(magic05)," 총수익_$",HistoryProfit(magic05)," 매수수익_$",HBProfit(magic05)," 매수건수_",HBuyOrders(magic05)," 매도수익_$",HSProfit(magic05)," 매도건수_",HSellOrders(magic05)," 총건수_",HOrders(magic05))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair06_",symbol_06," TradeEnabled_",PairTrade06," 현재수익_$",Profit(magic06)," 매수건수_",TotalBuyOrders(magic06)," 매도건수_",TotalSellOrders(magic06)," 총수익_$",HistoryProfit(magic06)," 매수수익_$",HBProfit(magic06)," 매수건수_",HBuyOrders(magic06)," 매도수익_$",HSProfit(magic06)," 매도건수_",HSellOrders(magic06)," 총건수_",HOrders(magic06))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair07_",symbol_07," TradeEnabled_",PairTrade07," 현재수익_$",Profit(magic07)," 매수건수_",TotalBuyOrders(magic07)," 매도건수_",TotalSellOrders(magic07)," 총수익_$",HistoryProfit(magic07)," 매수수익_$",HBProfit(magic07)," 매수건수_",HBuyOrders(magic07)," 매도수익_$",HSProfit(magic07)," 매도건수_",HSellOrders(magic07)," 총건수_",HOrders(magic07))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair08_",symbol_08," TradeEnabled_",PairTrade08," 현재수익_$",Profit(magic08)," 매수건수_",TotalBuyOrders(magic08)," 매도건수_",TotalSellOrders(magic08)," 총수익_$",HistoryProfit(magic08)," 매수수익_$",HBProfit(magic08)," 매수건수_",HBuyOrders(magic08)," 매도수익_$",HSProfit(magic08)," 매도건수_",HSellOrders(magic08)," 총건수_",HOrders(magic08))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair09_",symbol_09," TradeEnabled_",PairTrade09," 현재수익_$",Profit(magic09)," 매수건수_",TotalBuyOrders(magic09)," 매도건수_",TotalSellOrders(magic09)," 총수익_$",HistoryProfit(magic09)," 매수수익_$",HBProfit(magic09)," 매수건수_",HBuyOrders(magic09)," 매도수익_$",HSProfit(magic09)," 매도건수_",HSellOrders(magic09)," 총건수_",HOrders(magic09))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair10_",symbol_10," TradeEnabled_",PairTrade10," 현재수익_$",Profit(magic10)," 매수건수_",TotalBuyOrders(magic10)," 매도건수_",TotalSellOrders(magic10)," 총수익_$",HistoryProfit(magic10)," 매수수익_$",HBProfit(magic10)," 매수건수_",HBuyOrders(magic10)," 매도수익_$",HSProfit(magic10)," 매도건수_",HSellOrders(magic10)," 총건수_",HOrders(magic10))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair11_",symbol_11," TradeEnabled_",PairTrade11," 현재수익_$",Profit(magic11)," 매수건수_",TotalBuyOrders(magic11)," 매도건수_",TotalSellOrders(magic11)," 총수익_$",HistoryProfit(magic11)," 매수수익_$",HBProfit(magic11)," 매수건수_",HBuyOrders(magic11)," 매도수익_$",HSProfit(magic11)," 매도건수_",HSellOrders(magic11)," 총건수_",HOrders(magic11))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair12_",symbol_12," TradeEnabled_",PairTrade12," 현재수익_$",Profit(magic12)," 매수건수_",TotalBuyOrders(magic12)," 매도건수_",TotalSellOrders(magic12)," 총수익_$",HistoryProfit(magic12)," 매수수익_$",HBProfit(magic12)," 매수건수_",HBuyOrders(magic12)," 매도수익_$",HSProfit(magic12)," 매도건수_",HSellOrders(magic12)," 총건수_",HOrders(magic12))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair13_",symbol_13," TradeEnabled_",PairTrade13," 현재수익_$",Profit(magic13)," 매수건수_",TotalBuyOrders(magic13)," 매도건수_",TotalSellOrders(magic13)," 총수익_$",HistoryProfit(magic13)," 매수수익_$",HBProfit(magic13)," 매수건수_",HBuyOrders(magic13)," 매도수익_$",HSProfit(magic13)," 매도건수_",HSellOrders(magic13)," 총건수_",HOrders(magic13))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair14_",symbol_14," TradeEnabled_",PairTrade14," 현재수익_$",Profit(magic14)," 매수건수_",TotalBuyOrders(magic14)," 매도건수_",TotalSellOrders(magic14)," 총수익_$",HistoryProfit(magic14)," 매수수익_$",HBProfit(magic14)," 매수건수_",HBuyOrders(magic14)," 매도수익_$",HSProfit(magic14)," 매도건수_",HSellOrders(magic14)," 총건수_",HOrders(magic14))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair15_",symbol_15," TradeEnabled_",PairTrade15," 현재수익_$",Profit(magic15)," 매수건수_",TotalBuyOrders(magic15)," 매도건수_",TotalSellOrders(magic15)," 총수익_$",HistoryProfit(magic15)," 매수수익_$",HBProfit(magic15)," 매수건수_",HBuyOrders(magic15)," 매도수익_$",HSProfit(magic15)," 매도건수_",HSellOrders(magic15)," 총건수_",HOrders(magic15))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair16_",symbol_16," TradeEnabled_",PairTrade16," 현재수익_$",Profit(magic16)," 매수건수_",TotalBuyOrders(magic16)," 매도건수_",TotalSellOrders(magic16)," 총수익_$",HistoryProfit(magic16)," 매수수익_$",HBProfit(magic16)," 매수건수_",HBuyOrders(magic16)," 매도수익_$",HSProfit(magic16)," 매도건수_",HSellOrders(magic16)," 총건수_",HOrders(magic16))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair17_",symbol_17," TradeEnabled_",PairTrade17," 현재수익_$",Profit(magic17)," 매수건수_",TotalBuyOrders(magic17)," 매도건수_",TotalSellOrders(magic17)," 총수익_$",HistoryProfit(magic17)," 매수수익_$",HBProfit(magic17)," 매수건수_",HBuyOrders(magic17)," 매도수익_$",HSProfit(magic17)," 매도건수_",HSellOrders(magic17)," 총건수_",HOrders(magic17))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair18_",symbol_18," TradeEnabled_",PairTrade18," 현재수익_$",Profit(magic18)," 매수건수_",TotalBuyOrders(magic18)," 매도건수_",TotalSellOrders(magic18)," 총수익_$",HistoryProfit(magic18)," 매수수익_$",HBProfit(magic18)," 매수건수_",HBuyOrders(magic18)," 매도수익_$",HSProfit(magic18)," 매도건수_",HSellOrders(magic18)," 총건수_",HOrders(magic18))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair19_",symbol_19," TradeEnabled_",PairTrade19," 현재수익_$",Profit(magic19)," 매수건수_",TotalBuyOrders(magic19)," 매도건수_",TotalSellOrders(magic19)," 총수익_$",HistoryProfit(magic19)," 매수수익_$",HBProfit(magic19)," 매수건수_",HBuyOrders(magic19)," 매도수익_$",HSProfit(magic19)," 매도건수_",HSellOrders(magic19)," 총건수_",HOrders(magic19))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair20_",symbol_20," TradeEnabled_",PairTrade20," 현재수익_$",Profit(magic20)," 매수건수_",TotalBuyOrders(magic20)," 매도건수_",TotalSellOrders(magic20)," 총수익_$",HistoryProfit(magic20)," 매수수익_$",HBProfit(magic20)," 매수건수_",HBuyOrders(magic20)," 매도수익_$",HSProfit(magic20)," 매도건수_",HSellOrders(magic20)," 총건수_",HOrders(magic20))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair21_",symbol_21," TradeEnabled_",PairTrade21," 현재수익_$",Profit(magic21)," 매수건수_",TotalBuyOrders(magic21)," 매도건수_",TotalSellOrders(magic21)," 총수익_$",HistoryProfit(magic21)," 매수수익_$",HBProfit(magic21)," 매수건수_",HBuyOrders(magic21)," 매도수익_$",HSProfit(magic21)," 매도건수_",HSellOrders(magic21)," 총건수_",HOrders(magic21))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair22_",symbol_22," TradeEnabled_",PairTrade22," 현재수익_$",Profit(magic22)," 매수건수_",TotalBuyOrders(magic22)," 매도건수_",TotalSellOrders(magic22)," 총수익_$",HistoryProfit(magic22)," 매수수익_$",HBProfit(magic22)," 매수건수_",HBuyOrders(magic22)," 매도수익_$",HSProfit(magic22)," 매도건수_",HSellOrders(magic22)," 총건수_",HOrders(magic22))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair23_",symbol_23," TradeEnabled_",PairTrade23," 현재수익_$",Profit(magic23)," 매수건수_",TotalBuyOrders(magic23)," 매도건수_",TotalSellOrders(magic23)," 총수익_$",HistoryProfit(magic23)," 매수수익_$",HBProfit(magic23)," 매수건수_",HBuyOrders(magic23)," 매도수익_$",HSProfit(magic23)," 매도건수_",HSellOrders(magic23)," 총건수_",HOrders(magic23))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair24_",symbol_24," TradeEnabled_",PairTrade24," 현재수익_$",Profit(magic24)," 매수건수_",TotalBuyOrders(magic24)," 매도건수_",TotalSellOrders(magic24)," 총수익_$",HistoryProfit(magic24)," 매수수익_$",HBProfit(magic24)," 매수건수_",HBuyOrders(magic24)," 매도수익_$",HSProfit(magic24)," 매도건수_",HSellOrders(magic24)," 총건수_",HOrders(magic24))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair25_",symbol_25," TradeEnabled_",PairTrade25," 현재수익_$",Profit(magic25)," 매수건수_",TotalBuyOrders(magic25)," 매도건수_",TotalSellOrders(magic25)," 총수익_$",HistoryProfit(magic25)," 매수수익_$",HBProfit(magic25)," 매수건수_",HBuyOrders(magic25)," 매도수익_$",HSProfit(magic25)," 매도건수_",HSellOrders(magic25)," 총건수_",HOrders(magic25))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair26_",symbol_26," TradeEnabled_",PairTrade26," 현재수익_$",Profit(magic26)," 매수건수_",TotalBuyOrders(magic26)," 매도건수_",TotalSellOrders(magic26)," 총수익_$",HistoryProfit(magic26)," 매수수익_$",HBProfit(magic26)," 매수건수_",HBuyOrders(magic26)," 매도수익_$",HSProfit(magic26)," 매도건수_",HSellOrders(magic26)," 총건수_",HOrders(magic26))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair27_",symbol_27," TradeEnabled_",PairTrade27," 현재수익_$",Profit(magic27)," 매수건수_",TotalBuyOrders(magic27)," 매도건수_",TotalSellOrders(magic27)," 총수익_$",HistoryProfit(magic27)," 매수수익_$",HBProfit(magic27)," 매수건수_",HBuyOrders(magic27)," 매도수익_$",HSProfit(magic27)," 매도건수_",HSellOrders(magic27)," 총건수_",HOrders(magic27))+"\n";
ScreenStr = ScreenStr + StringConcatenate("Pair28_",symbol_28," TradeEnabled_",PairTrade28," 현재수익_$",Profit(magic28)," 매수건수_",TotalBuyOrders(magic28)," 매도건수_",TotalSellOrders(magic28)," 총수익_$",HistoryProfit(magic28)," 매수수익_$",HBProfit(magic28)," 매수건수_",HBuyOrders(magic28)," 매도수익_$",HSProfit(magic28)," 매도건수_",HSellOrders(magic28)," 총건수_",HOrders(magic28))+"\n";
ScreenStr = ScreenStr + "=============================================================================================================================" + "\n";
ScreenStr = ScreenStr + StringConcatenate("현재수익 : $",profits," Buy : $",bprofits," / Sell : $",sprofits,", New Orders : ",orders,"건 = Buy ",borders,"건 / Sell",sorders,"건") + "\n";
ScreenStr = ScreenStr + StringConcatenate("Total Profits : $",hprofit,", Buy : $",hbprofit,", Sell : $",hsprofit,", Total Orders : ",horders,"건 = Total Buy ",hborders,"건 / Total Sell",hsorders,"건");
Comment(ScreenStr);
return(0);
} // EA 종료
//********************************************************************
//| Allow One Action Per Bar |
//********************************************************************
// 현재 바에서 하나만 주문할때 사용하는 함수
bool NewBar()
{ // 0
if(PreviousBarTime<Time[0])
{ // 1
PreviousBarTime=Time[0];
return(true);
} // 1
return(false);
} // 0
//********************************************************************
// Max Spread Limitation 설정함수 |
//********************************************************************
bool TradeEnable(string symbols) {
if(MarketInfo(symbols,MODE_ASK)-MarketInfo(symbols,MODE_BID) > MaxSpread*mypoint*MarketInfo(symbols,MODE_POINT)) return(false);
else return(true);
}
//********************************************************************
//| Profit Calculate Function(수익 계산 함수) |
//********************************************************************
double Profit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))
{ // 2
if (OrderMagicNumber()==Magic)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| 총매수수익 계산 함수 |
//********************************************************************
double BProfit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))
{ // 2
if (OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| 총매도수익 계산 함수 |
//********************************************************************
double SProfit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_TRADES))
{ // 2
if (OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| Total order Calculate Function(총오더수 계산 함수) |
//********************************************************************
int TotalOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{ // 2
if (OrderMagicNumber()==MAGIC && (OrderType()==OP_BUY || OrderType()==OP_SELL))
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
//********************************************************************
//| Total Buy order Calculate Function(총매수 계약 계산 함수) |
//********************************************************************
int TotalBuyOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{ // 2
if ( OrderMagicNumber()==MAGIC && OrderType()==OP_BUY )
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
//********************************************************************
//| Total Sell order Calculate Function(총매도 계약 계산 함수) |
//********************************************************************
int TotalSellOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{ // 2
if ( OrderMagicNumber()==MAGIC && OrderType()==OP_SELL )
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
//********************************************************************
//| 총수익 계산 함수(과거치 포함) |
//********************************************************************
double HistoryProfit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersHistoryTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==Magic)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| 총매수수익 계산 함수(과거치 포함) |
//********************************************************************
double HBProfit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersHistoryTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| 총매도수익 계산 함수(과거치 포함) |
//********************************************************************
double HSProfit(int Magic)
{ // 0
double Prof=0;
for (int k=0; k < OrdersHistoryTotal(); k++)
{ // 1
if (OrderSelect(k, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{ // 3
Prof = NormalizeDouble(Prof + OrderProfit(),2);
} // 3
} // 2
} // 1
return(Prof);
} // 0
//********************************************************************
//| Total order Calculate Function(총오더수 계산 함수,과거치 포함) |
//********************************************************************
int HOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersHistoryTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==MAGIC && (OrderType()==OP_BUY || OrderType()==OP_SELL))
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
//********************************************************************
//| 총Buy오더수 계산 함수(과거치 포함) |
//********************************************************************
int HBuyOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersHistoryTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==MAGIC && OrderType()==OP_BUY)
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
//********************************************************************
//| 총Sell오더수 계산 함수(과거치 포함) |
//********************************************************************
int HSellOrders(int MAGIC)
{ // 0
int cnt=0;
for (int i=0; i < OrdersHistoryTotal(); i++)
{ // 1
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
{ // 2
if (OrderMagicNumber()==MAGIC && OrderType()==OP_SELL)
{ // 3
cnt++;
} // 3
} // 2
} // 1
return(cnt);
} // 0
/*
//********************************************************************
//| Trailing Stop |
//********************************************************************
void MoveTrailingStop()
{
int ct,totl=OrdersTotal();
RefreshRates();
if (OrdersTotal() > 0) {
for(ct=0;ct<totl;ct++)
{
OrderSelect(ct,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
if( TrailingStop>0 && Bid>NormalizeDouble(OrderOpenPrice()+TrailingStop*mypoint*Point,Digits) )
{
if((NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(Bid-mypoint*TrailingStop*Point,Digits))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid-mypoint*TrailingStop*Point,Digits),OrderTakeProfit(),0,Blue);
return(0);
}
}
}
if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
{
if( TrailingStop>0 && Ask<NormalizeDouble(OrderOpenPrice()-TrailingStop*mypoint*Point,Digits) )
{
if((NormalizeDouble(OrderStopLoss(),Digits)>(NormalizeDouble(Ask+(mypoint*TrailingStop*Point),Digits)))||(OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask+(mypoint*TrailingStop*Point),Digits),OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
//********************************************************************
//| Break Even Strategy |
//********************************************************************
void MoveBreakEven()
{
int cnt,total=OrdersTotal();
RefreshRates();
if (OrdersTotal() > 0) {
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if( OrderType()<=OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic )
{
if(OrderType()==OP_BUY)
{
if(BreakEven>0)
{
if(NormalizeDouble((Bid-OrderOpenPrice()),Digits) > BreakEven*mypoint*Point)
{
if(NormalizeDouble((OrderStopLoss()-OrderOpenPrice()),Digits) < 0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()+BreakPoint*mypoint*Point,Digits),OrderTakeProfit(),0,Blue);
return(0);
}
}
}
}
else
{
if(BreakEven>0)
{
if(NormalizeDouble((OrderOpenPrice()-Ask),Digits) > BreakEven*mypoint*Point)
{
if(NormalizeDouble((OrderOpenPrice()-OrderStopLoss()),Digits) < 0)
{
OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(OrderOpenPrice()-BreakPoint*mypoint*Point,Digits),OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
}
}
}
*/
//********************************************************************
//| Close All By Magic Number |
//********************************************************************
void CloseAllOpens(int Magic)
{ // 함수 시작
int total = OrdersTotal();
for(int i=total-1;i>=0;i--)
{ // Loop 시작
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
int type = OrderType();
bool result = false;
if (OrderMagicNumber() == Magic) {
RefreshRates();
switch(type)
{ // Order Type 검색 및 처리
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID),MarketInfo(OrderSymbol(), MODE_POINT)), slippage, Blue );
break;
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK),MarketInfo(OrderSymbol(), MODE_POINT)), slippage, Red );
} // Order Type 검색 및 처리 종료
if(result == false)
{ // 에러 처리
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
} // 에러 처리 종료
}
} // Loop 종료
} // 함수 종료
//********************************************************************
//| Williams %R Average Function |
//********************************************************************
double USD_WPR(int TF,int shifts) {
string symbol_1 = "EURUSD" + subfix;
string symbol_2 = "GBPUSD" + subfix;
string symbol_3 = "AUDUSD" + subfix;
string symbol_4 = "NZDUSD" + subfix;
string symbol_5 = "USDJPY" + subfix;
string symbol_6 = "USDCHF" + subfix;
string symbol_7 = "USDCAD" + subfix;
double wpr_pair1 = 100 - iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = 100 - iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double EUR_WPR(int TF,int shifts) {
string symbol_1 = "EURUSD" + subfix;
string symbol_2 = "EURGBP" + subfix;
string symbol_3 = "EURJPY" + subfix;
string symbol_4 = "EURCAD" + subfix;
string symbol_5 = "EURCHF" + subfix;
string symbol_6 = "EURAUD" + subfix;
string symbol_7 = "EURNZD" + subfix;
double wpr_pair1 = iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double GBP_WPR(int TF,int shifts) {
string symbol_1 = "GBPUSD" + subfix;
string symbol_2 = "EURGBP" + subfix;
string symbol_3 = "GBPJPY" + subfix;
string symbol_4 = "GBPCAD" + subfix;
string symbol_5 = "GBPCHF" + subfix;
string symbol_6 = "GBPAUD" + subfix;
string symbol_7 = "GBPNZD" + subfix;
double wpr_pair1 = iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double CHF_WPR(int TF,int shifts) {
string symbol_1 = "USDCHF" + subfix;
string symbol_2 = "EURCHF" + subfix;
string symbol_3 = "GBPCHF" + subfix;
string symbol_4 = "CADCHF" + subfix;
string symbol_5 = "CHFJPY" + subfix;
string symbol_6 = "AUDCHF" + subfix;
string symbol_7 = "NZDCHF" + subfix;
double wpr_pair1 = 100 - iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = 100 - iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = 100 - iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = 100 - iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double JPY_WPR(int TF,int shifts) {
string symbol_1 = "USDJPY" + subfix;
string symbol_2 = "EURJPY" + subfix;
string symbol_3 = "GBPJPY" + subfix;
string symbol_4 = "CADJPY" + subfix;
string symbol_5 = "CHFJPY" + subfix;
string symbol_6 = "AUDJPY" + subfix;
string symbol_7 = "NZDJPY" + subfix;
double wpr_pair1 = 100 - iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = 100 - iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = 100 - iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = 100 - iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = 100 - iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double CAD_WPR(int TF,int shifts) {
string symbol_1 = "USDCAD" + subfix;
string symbol_2 = "EURCAD" + subfix;
string symbol_3 = "GBPCAD" + subfix;
string symbol_4 = "AUDCAD" + subfix;
string symbol_5 = "CADCHF" + subfix;
string symbol_6 = "CADJPY" + subfix;
string symbol_7 = "NZDCAD" + subfix;
double wpr_pair1 = 100 - iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = 100 - iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = 100 - iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double AUD_WPR(int TF,int shifts) {
string symbol_1 = "AUDUSD" + subfix;
string symbol_2 = "EURAUD" + subfix;
string symbol_3 = "GBPAUD" + subfix;
string symbol_4 = "AUDCAD" + subfix;
string symbol_5 = "AUDCHF" + subfix;
string symbol_6 = "AUDJPY" + subfix;
string symbol_7 = "AUDNZD" + subfix;
double wpr_pair1 = iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
double NZD_WPR(int TF,int shifts) {
string symbol_1 = "NZDUSD" + subfix;
string symbol_2 = "EURNZD" + subfix;
string symbol_3 = "GBPNZD" + subfix;
string symbol_4 = "NZDCAD" + subfix;
string symbol_5 = "NZDCHF" + subfix;
string symbol_6 = "NZDJPY" + subfix;
string symbol_7 = "AUDNZD" + subfix;
double wpr_pair1 = iWPR(symbol_1, TF, periods, shifts);
double wpr_pair2 = 100 - iWPR(symbol_2, TF, periods, shifts);
double wpr_pair3 = 100 - iWPR(symbol_3, TF, periods, shifts);
double wpr_pair4 = iWPR(symbol_4, TF, periods, shifts);
double wpr_pair5 = iWPR(symbol_5, TF, periods, shifts);
double wpr_pair6 = iWPR(symbol_6, TF, periods, shifts);
double wpr_pair7 = 100 - iWPR(symbol_7, TF, periods, shifts);
double wpr_sum = wpr_pair1 + wpr_pair2 + wpr_pair3 + wpr_pair4 + wpr_pair5 + wpr_pair6 + wpr_pair7;
double results = NormalizeDouble(wpr_sum / 7.0,2);
return (results);
}
//********************************************************************
//| Stop Out조건발생시 전체 일괄 청산 함수 |
//********************************************************************
void StopOutClose() { // 0
bool CloseAllOrders = false;
if(AccountFreeMargin() < StopOutBalance || AccountBalance() < StopOutBalance) CloseAllOrders = true;
else CloseAllOrders = false;
if(CloseAllOrders) { // 15
int totalord = OrdersTotal();
for(int jk=totalord-1;jk >= 0;jk--) { // 16
OrderSelect(jk, SELECT_BY_POS, MODE_TRADES);
int types = OrderType();
bool resultall = false;
RefreshRates();
switch(types) { //switch
case OP_BUY : resultall = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red);
break;
case OP_SELL : resultall = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5, Blue);
} //switch
if(resultall == false) { // 17
Print("Order ", OrderTicket(), " failed to close. Error:", GetLastError() );
} // 17
} // 16
} // 15
} // 0
//********************************************************************
//| 주문 함수 (OpenOrder) |
//********************************************************************
int OpenOrder( string SymbolName, int CmdType, double Lots, int Slippages, double StopLosses, double TakeProfit, int magic) { // 함수 시작
static string OrderTypeToString[6] = {"OP_BUY", "OP_SELL", "OP_BUYLIMIT", "OP_SELLLIMIT", "OP_BUYSTOP", "OP_SELLSTOP"};
double ask00 = MarketInfo(SymbolName,MODE_ASK);
double bid00 = MarketInfo(SymbolName,MODE_BID);
int Ticket = -1;
int ErrorCodes;
int Slips = 0;
double Vol = 0;
string Comments;
color CLRs;
RefreshRates();
double stopbuy = NormalizeDouble(ask00-(StopLosses*mypoint*MarketInfo(SymbolName,MODE_POINT)),MarketInfo(SymbolName, MODE_DIGITS));
double stopsell = NormalizeDouble(bid00+(StopLosses*mypoint*MarketInfo(SymbolName,MODE_POINT)),MarketInfo(SymbolName, MODE_DIGITS));
double tpbuy = NormalizeDouble(ask00+(TakeProfit*mypoint*MarketInfo(SymbolName,MODE_POINT)),MarketInfo(SymbolName, MODE_DIGITS));
double tpsell = NormalizeDouble(bid00-(TakeProfit*mypoint*MarketInfo(SymbolName,MODE_POINT)),MarketInfo(SymbolName, MODE_DIGITS));
if (StopLosses == 0) {
stopbuy = 0;
stopsell = 0;
}
if (TakeProfit == 0) {
tpbuy = 0;
tpsell = 0;
}
if (StopLosses == 0 && TakeProfit == 0) ECN = FALSE;
if (CmdType == OP_BUY) { // Buy 시작
Comments = Commentary+"샀어";
CLRs = Red;
if (ECN == true) { // ECN 시작
double execution = GetTickCount();
Ticket = OrderSend(SymbolName, CmdType, Lots, ask00, Slippages, 0, 0,Comments,magic,0,CLRs);
if(Ticket == -1) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
OrderSelect(Ticket, SELECT_BY_TICKET);
if (!OrderSelect(Ticket, SELECT_BY_TICKET)) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
OrderModify(Ticket,OrderOpenPrice(),stopbuy,tpbuy,0,CLRs);
execution = GetTickCount()-execution;
return(0);
} // ECN 종료
else
{ // No ECN
execution = GetTickCount();
Ticket = OrderSend(SymbolName, CmdType, Lots, ask00, Slippages, stopbuy, tpbuy,Comments,magic,0,CLRs);
if(Ticket == -1) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
execution = GetTickCount()-execution;
return(0);
} // No ECN 종료
} // Buy 종료
else
if (CmdType == OP_SELL) { // Sell 시작
Comments = Commentary+"팔았어";
CLRs = Blue;
if (ECN == true) { // ECN 시작
execution = GetTickCount();
Ticket = OrderSend(SymbolName, CmdType, Lots, bid00, Slippages, 0, 0,Comments,magic,0,CLRs);
if(Ticket == -1) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
OrderSelect(Ticket, SELECT_BY_TICKET);
if (!OrderSelect(Ticket, SELECT_BY_TICKET)) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
OrderModify(Ticket,OrderOpenPrice(),stopsell, tpsell,0,CLRs);
execution = GetTickCount()-execution;
return(0);
} // ECN 종료
else
{ // No ECN
execution = GetTickCount();
Ticket = OrderSend(SymbolName, CmdType, Lots, bid00, Slippages, stopsell, tpsell,Comments,magic,0,CLRs);
if(Ticket == -1) { // check for errors
ErrorCodes = GetLastError();
Print("아씨!, Error: " + ErrorDescription(ErrorCodes));
return(-1);
} // check for errors
execution = GetTickCount()-execution;
return(0);
} // No ECN 종료
} // Sell 종료
OrderSelect(OrdersTotal() - 1, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == SymbolName)
{
Slips = OrderSlipPage(OrderOpenPrice());
Ticket = OrderTicket();
Vol = OrderLots();
}
Print(Ticket, " = OrderSend( ", Comments,", ", SymbolName, ", ", OrderTypeToString[CmdType], ", ", Lots, ", ", DoubleToStr(OrderOpenPrice(), MarketInfo(SymbolName, MODE_DIGITS)),", Execution : ",execution,"ms",
", ", Slippages, ", ", StopLosses, ", ", TakeProfit, ") - ", ErrorDescription(ErrorCodes), ", SlipPage = ", Slips, ", Lots = ", Vol);
return(Ticket);
} // 함수 종료
//********************************************************************
//| Slippage 계산 함수 |
//********************************************************************
int OrderSlipPage( double OriginalPrice )
{
double Tmp;
int Res;
if (OrderCloseTime() == 0)
{
if (OrderType() == OP_BUY)
Tmp = OriginalPrice - OrderOpenPrice();
else if (OrderType() == OP_SELL)
Tmp = OrderOpenPrice() - OriginalPrice;
}
else
{
if (OrderType() == OP_BUY)
Tmp = OrderClosePrice() - OriginalPrice;
else if (OrderType() == OP_SELL)
Tmp = OriginalPrice - OrderClosePrice();
}
if (Tmp > 0)
Res = Tmp / MarketInfo(OrderSymbol(), MODE_POINT) + 0.1;
else
Res = Tmp / MarketInfo(OrderSymbol(), MODE_POINT) - 0.1;
return(Res);
}
//********************************************************************
//| Day/Time Filter Function |
//********************************************************************
bool DayTimeFilter(int Dates, int start_time, int finish_time) {
int Current_Time = TimeHour(TimeCurrent());
if (start_time == 0) start_time = 24;
if (finish_time == 0) finish_time = 24;
if (Current_Time == 0) Current_Time = 24;
if (!TimeFilter) return(true) ;
else
if ( TimeFilter && DayOfWeek() == Dates && start_time < finish_time )
{
if ( (Current_Time >= start_time) && (Current_Time <= finish_time) ) return(true) ;
else return(false);
}
if ( TimeFilter && DayOfWeek() == Dates && start_time > finish_time )
{
if ( (Current_Time >= start_time) || (Current_Time <= finish_time) ) return(true) ;
else return(false);
}
}
bool DayFilter() {
if (!DateFilter) return(true) ;
else
if ((MON && DayTimeFilter(1, mon_start_time, mon_finish_time)) || (TUE && DayTimeFilter(2, tue_start_time, tue_finish_time)) || (WED && DayTimeFilter(3, wed_start_time, wed_finish_time)) || (THU && DayTimeFilter(4, thu_start_time, thu_finish_time)) || (FRI && DayTimeFilter(5, fri_start_time, fri_finish_time))) return(true) ;
else return(false);
}
'IT관련' 카테고리의 다른 글
메타트레이더 EA - GV Export (0) | 2019.09.16 |
---|---|
Entry Logic 구성 Indicator(Backtest) (0) | 2019.09.15 |
메타트레이더 EA - Combination Version (0) | 2019.09.13 |
메타트레이더 EA - BaseCurrency_Stochastic Version (0) | 2019.09.12 |
메타트레이더 EA - BaseCurrency_RSI 3. Weighted Version (0) | 2019.09.11 |