//+——————————————————————+
//| FrBestExp02_05.mq4 |
#property link “http://www.forex-instruments.info/”
extern double Lots = 1.00;
extern int Stop_Loss = 1000;
extern int Take_Profit = 1000;
extern int Trailing_Stop = 0;
extern int map=25;
extern int mash=1;
// Only for M15
extern int Vlim=50;
extern int fper=12,sper=26,sigper=9;// 镥痂钿?桧滂赅蝾疣 OsMA
extern int stop=300;// 羽钼屙?铗皴麝?镳铘栩?
extern int hedg=1;// 綦嚆 疣琊屮屙? 蹂滏?
extern double kh=10;// 觐?蹂滏桊钼囗?
extern int lok;// 綦嚆 疣琊屮屙? 腩觇痤忄龛 镱玷鲨?
extern int rpr=1;// 綦嚆 铒疱溴脲龛 镳铖噤觇 镱琨 桦?镱 怦屐?蝈耱?
extern int ttime=900;// 青溴疰赅 恹耱噔脲龛 蹂滏-铕溴疣 磬 1 疋鬻?
extern int hstop=-3000;// 耱铒-腩耨 潆 蹂滏?
int cnt;// 桧溴犟 鲨觌?
int sigs,sigb;// 耋祆桊簋?耔沩嚯 磬 镳钼邃屙桢 铒屦圉梃 牦镫?镳钿噫?
double ssig,bsig;// 耔沩嚯?磬 牦镫?镳钿噫?铗 桧滂赅蝾疣 麴嚓蜞腩?
double osmanul,osmaone;// 耔沩嚯?桧滂赅蝾疣 OsMA 铗 眢脲忸泐 ?镥疴钽?徉痤?
int s,b;// 觐腓麇耱忸 嚓蜩忭 颀腚 ?徉?铕溴痤?
int hml;// 綦嚆 玎牮? 镱玷鲨??扈眢耦恹?镳铘栩铎 (玎牮噱蝰 镱玷鲨 ?戾睃?腩蝾?
int pl;// 綦嚆 玎牮? 怦艴 镱玷鲨?镱 篑腩忤?磬腓麒 篑蜞眍怆屙眍泐 镱腩骅蝈朦眍泐 镳铘栩?
double summa;// 耋祆囵睇?镳铘栩 镱 怦屐 镱玷鲨?
double mlot;// 忮腓麒磬 蝾疸箦祛泐 腩蜞
double ssum,bsum;// 镳铘栩 镱 铕溴疣?颀腚 ?徉?疣玟咫?
double pr;// 忮腓麒磴?镳铖噤觇
int hblok,shblok,bhblok;// 綦嚆 犭铌桊钼囗? 恹耱噔脲龛 蹂滏-铕溴疣 ?綦嚆?镱怛铕眍泐 玎矬耜?蹂滏-镳铞邃箴?
double DHMax,DLMin;
bool ft=true;
int rang;
double pt;
int nul;// 镥疱戾眄 潆 恹麒耠屙? 镱忸痤蝽铋 蝾麝?镳?玎矬耜???00.00 赅驿 耋蝾?
int LastTradeTime;
double FractalBest(int Dir)
{
double up,dw;
if(High[3]>High[4] && High[3]>High[5] && High[3]>High[2] && High[3]>High[1]){
up=Low[0]-3*Point;
}
else{
up=0;
}
if(Low[3]<Low[4] && Low[3]<Low[5] && Low[3]<Low[2] && Low[3]<Low[1]){
dw=High[0]+3*Point;
}
else{
dw=0;
}
if (Dir==0) {return(up);}
if (Dir==1) {return(dw);}
}
int start(){
mlot=Lots; // 铒疱溴脲龛?忮腓麒睇 疣犷麇泐 腩蜞
//——————————————–蔓麒耠屙?镱忸痤蝽铋 蝾麝?—————————————–
if ((Hour()==0 && Minute()==0) || ft){//磬鬣腓顸 耋蜿?桦?镥疴 玎矬耜
DHMax=0;
DLMin=1000;
if(ft){// 镥疴 玎矬耜
rang=MathRound((Hour()*60+Minute())/Period());
nul=rang;
}
else{
nul=96;//玎 耋蜿?磬 15
rang=1;
}
for(cnt=rang;cnt<=rang+95;cnt++){//镱桉?爨犟 ?扈?玎 镱耠邃龛?耋蜿?
if(DHMax<High[cnt])DHMax=High[cnt];
if(DLMin>Low[cnt])DLMin=Low[cnt];
}
pt=(DHMax+DLMin+Close[nul])/3;//镱忸痤蝽? 蝾麝?
ft=false;
}
//—————————————————————————————————————-
if(CurTime()-LastTradeTime<20)return(0);
//—————————-物疱溴脲龛 钺泐 ?镱玷鲨铐眍泐 镳铘栩? ?蜞赕屣钿聍蛤 镱玷鲨?——————
s=0;b=0;summa=0;bsum=0;ssum=0;
for(cnt=0;cnt<OrdersTotal();cnt++){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL){
ssum=ssum+OrderProfit();
s=s+1;
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY){
bsum=bsum+OrderProfit();
b=b+1;
}
}
summa=bsum+ssum;summa=MathRound(summa);
//——————————————————茵彘腓磴-羊铒———————————————
if(Trailing_Stop>0 && hedg==1){
for(cnt=0;cnt<OrdersTotal();cnt++){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderProfit()>0){
if(Bid-OrderOpenPrice()>Point*Trailing_Stop){
if(OrderStopLoss()<Bid-Point*Trailing_Stop){
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*Trailing_Stop,OrderTakeProfit(),0,Red);
return(0);
}
}
if(OrderOpenPrice()-Ask>Point*Trailing_Stop){
if(OrderStopLoss()>Ask+Point*Trailing_Stop){
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*Trailing_Stop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}
}
//—————————————————蔓耱噔脲龛?蹂滏-铕溴疣————————————–
if(hblok==1){
shblok=0;bhblok=0;
for(cnt=0;cnt<OrdersTotal();cnt++){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && OrderLots()==mlot*kh)shblok=1;
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && OrderLots()==mlot*kh)bhblok=1;
}
}
if(shblok==1 && bhblok==1)hblok=1;
if(shblok==0 && bhblok==0)hblok=0;
//if s+b=0 then hblok=0;
if((s+b<=2 && (lok==1 || lok==0)) && hedg==1 && hblok==0){
if(CurTime()-LastTradeTime<ttime)return(0);
if(ssum>=150 || bsum<-300){
OrderSend(Symbol(),OP_SELL,kh*mlot,Bid,5,Bid+Stop_Loss*Point,Bid-Take_Profit*Point,NULL,0,0,Aqua);
//SetArrow(Time[0],H+5*Point,159,Aqua);
hblok=1;
return(0);
}
if(bsum>=150 || ssum<-300){
OrderSend(Symbol(),OP_BUY,kh*mlot,Ask,5,Ask-Stop_Loss*Point,Ask+Take_Profit*Point,NULL,0,0,Red);
//SetArrow(Time[0],L-5*Point,159,Red);
hblok=1;
return(0);
}
}
//——————————————蔓麒耠屙桢 镳铖噤觇 ?镳铞羼皴 蝾疸钼——————————
if(s+b==0 && rpr==0)pr=0;
if(pr>summa && summa<0)pr=MathRound(summa);
//———————————–物疱溴脲龛?铖眍忭钽?耔沩嚯??耔沩嚯钼 桧滂赅蝾痤?———————–
// bsig=iCustom(NULL,0,”FractalBest”,0,0);
// ssig=iCustom(NULL,0,”FractalBest”,1,0);
bsig=FractalBest(0);
ssig=FractalBest(1);
osmanul=iOsMA(NULL,0,fper,sper,sigper,PRICE_CLOSE,0);
osmaone=iOsMA(NULL,0,fper,sper,sigper,PRICE_CLOSE,1);
double ma1=iMA(NULL,60,map,0,0,0,0);
double ma2=iMA(NULL,60,map,0,0,0,mash);
if(ssig>1 && ma1>ma2 && Volume[1]>Vlim && Volume[1]>Volume[2] && osmaone>osmanul && osmaone<=0 && osmanul<0 && Close[0]>pt){
sigs=1;
}
else{
sigs=0;
}
if(bsig>1 && ma1<ma2 && Volume[1]>Vlim && Volume[1]>Volume[2] && osmaone<osmanul && osmaone>=0 && osmanul>0 && Close[0]<pt){
sigb=1;
}
else{
sigb=0;
}
if(s+b<=1){
hml=0;pl=0;
}
if(summa>=stop*mlot && s+b==1 && Trailing_Stop==0)pl=1;
if(summa>2*stop && s+b==2 && lok==0 && Trailing_Stop==0)pl=1;
if(summa>=3*stop*mlot && s+b==3 && lok==1 && Trailing_Stop==0)pl=1;
if(Trailing_Stop>0)pl=0;
if(Trailing_Stop>0 && (ssum<hstop || bsum<hstop))pl=1; // 耱铒 潆 礤箐圜眍泐 蹂滏?
if(Trailing_Stop>0 && ((ssum<-300 && bsum>300) || (ssum>300 && bsum<-300)) && s+b>=2 && hedg==1 && pl==0)hml=1;
// 愉嚯屙桢 戾腙铋 镱玷鲨??铗痂鲟蝈朦睇?镳铘栩钼 镱耠?箐圜眍泐 玎矬耜?蹂滏?
//——————————愉嚯屙桢 蹂滏桊箦祛泐 铕溴疣 镳?镱塍麇龛?玎溧眄钽?镳铘栩?———————-
if(hml==1){
for(cnt=OrdersTotal()-1;cnt>=0;cnt–){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL && ssum<-2*stop && NormalizeDouble(OrderLots(),1)==NormalizeDouble(1.0*mlot,1)){
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
//return(0);
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY && bsum<-2*stop && NormalizeDouble(OrderLots(),1)==NormalizeDouble(1.0*mlot,1)){
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
//return(0);
}
}
return(0);
}
//—————————青牮桢 怦艴 铗牮 磬 镟疱 铕溴痤?镳?漕耱桄屙梃 玎溧眄钽?镳铘栩?
if(pl==1){
for(cnt=OrdersTotal()-1;cnt>=0;cnt–){
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderType()==OP_SELL){
OrderClose(OrderTicket(),OrderLots(),Ask,3,Red);
//return(0);
}
if(OrderSymbol()==Symbol() && OrderType()==OP_BUY){
OrderClose(OrderTicket(),OrderLots(),Bid,3,Red);
//return(0);
}
}
return(0);
}
//——————————————蔓耱噔脲龛?铖眍忭 ?腩觇痼桴 铕溴痤?—————————–
if(s+b<=1){
if((sigs==1 && s+b==0) || (bsum<-150 && lok==1)){
OrderSend(Symbol(),OP_SELL,mlot,Bid,5,Bid+Stop_Loss*Point,Bid-Take_Profit*Point,NULL,0,0,Lime);
//SetArrow(Time[0],H+5*Point,242,Lime);
return(0);
}
if((sigb==1 && s+b==0) || (ssum<-150 && lok==1)){
OrderSend(Symbol(),OP_BUY,mlot,Ask,5,Ask-Stop_Loss*Point,Ask+Take_Profit*Point,NULL,0,0,Gold);
//SetArrow(Time[0],L-5*Point,241,Gold);
return(0);
}
}
return(0);
}
//+——————————————————————+
相关资源
暂无评论...