FM-PIPS (TP,SL,TRAL)

FM-PIPS (TP,SL,TRAL)

官方版 无广告 99

更新日期:2022-11-08 分类标签: 语言:中文 平台:没限制

15 人已下载 手机查看

FM-PIPS (TP,SL,TRAL)

//+------------------------------------------------------------------+
//| FM-PIPS.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//-----------------------相疣戾蝠?-----------------------------------+
extern string c0="------------------------";
extern double Risk =50;
extern double ProfitProcent =1;
extern double StopProcent =50;
extern string c9="------------------------";
extern int TP =10000;
extern int SL =10000;
extern int Tral =3000;
extern string c1="------------------------";
extern double KoefBar =3;
extern double MinBar =50;
extern int MaxOrders =2;
extern string c2="------------------------";
extern int TimeStart =0; //吗屐 磬鬣豚 疣犷螓
extern int TimeEnd =23; //吗屐 铌铐鬣龛 疣犷螓
extern string c3="------------------------";
extern int FrameFiltr =60;
extern int TF =1;
extern int Magic =7777; //锑痍屦 铕溴痤?
//--------------------------------------------------------------------+
string CommentEA ="FM-PIPS";
int TralStep =1;
int D;
bool Buy,Sell;

int init()
{D=1;
if (Digits==5 || Digits==3)D=10;
return(0);}
//--------------------------------------------------------------------+
int start(){
//--------------------------------------------------------------------+
double Lot=0;
Lot=NormalizeDouble(AccountBalance()/100*Risk/(MarketInfo(Symbol(),MODE_TICKVALUE)*100*D),2);
if (Lot<MarketInfo(Symbol(),MODE_MINLOT))Lot=MarketInfo(Symbol(),MODE_MINLOT);
//--------------------------------------------------------------------+
double v1=(High[1]-Low[1])/Point;
double v2=(High[2]-Low[2])/Point;
double v3=(High[3]-Low[3])/Point;
double v4=(High[4]-Low[4])/Point;
double v5=(High[5]-Low[5])/Point;
double v6=(High[6]-Low[6])/Point;
double v7=(High[7]-Low[7])/Point;
double v8=(High[8]-Low[8])/Point;
double v9=(High[9]-Low[9])/Point;
double v10=(High[10]-Low[10])/Point;
//--------------------------------------------------------------------+
double sr=(v2+v3+v4+v5+v6+v7+v8+v9+v10)/9;
//--------------------------------------------------------------------+
Buy=false;Sell=false;
if (iLow(Symbol(),FrameFiltr,1)>Ask && sr<=MinBar && Open[1]>Close[1] && v1>sr*KoefBar){Buy=true;}
if (iHigh(Symbol(),FrameFiltr,1)<Bid && sr<=MinBar && Open[1]<Close[1] && v1>sr*KoefBar){Sell=true;}
//--------------------------------------------------------------------+
if(TimeHour(TimeCurrent())>=TimeStart && TimeHour(TimeCurrent())<TimeEnd)
{
if(Count(OP_SELL)==0 && Count1(OP_BUY)==0 && Count2(OP_BUY)==0 && Buy && Count(OP_BUY)<MaxOrders)
{OrderSend (Symbol(),OP_BUY,Lot,Ask,100,Ask-SL*Point,Bid+TP*Point,CommentEA,Magic,0,Green);}
if(Count(OP_BUY)==0 && Count1(OP_SELL)==0 && Count2(OP_SELL)==0 && Sell && Count(OP_SELL)<MaxOrders)
{OrderSend (Symbol(),OP_SELL,Lot,Bid,100,Bid+SL*Point,Ask-TP*Point,CommentEA,Magic,0,Red);}
}
//--------------------------------------------------------------------+
double ProfProc=(AccountBalance()/100)*ProfitProcent;
if(Profit(-1)>=ProfProc && ProfProc!=0)
{Closer();}

double S_Max=(AccountBalance()/100)*StopProcent*(-1);
if(Profit(-1)<S_Max && S_Max!=0)
{Closer();}
//--------------------------------------------------------------------+
if(Count(-1)>0)
{Trail(Magic);}
//--------------------------------------------------------------------+
return(0);}
//--------------------------------------------------------------------+
void Trail(int _key)
{for(int i=0; i<OrdersTotal(); i++)
if (OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==Symbol() && OrderMagicNumber()==_key)
{if(Tral!=0){
if (OrderType()==OP_BUY && Bid>MathMax(OrderOpenPrice(),OrderStopLoss())+(Tral+TralStep)*Point)
if (!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Tral*Point,OrderTakeProfit(),0))
{}
if (OrderType()==OP_SELL && ((Ask<MathMin(OrderOpenPrice(),OrderStopLoss())-(Tral+TralStep)*Point &&
OrderStopLoss()!=0)||(Ask<OrderOpenPrice()-(Tral+TralStep)*Point && OrderStopLoss()==0)))
if (!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Tral*Point,OrderTakeProfit(),0))
{}}}}
//--------------------------------------------------------------------+
int Count(int type)
{int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && (type==-1 || OrderType()==type)) count++;}
return(count);}

int Count1(int type)
{int count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderOpenTime()>=iTime(Symbol(),TF,0) && OrderMagicNumber()==Magic && (type==-1 || OrderType()==type)) count++;}
return(count);}

int Count2(int type)
{int count=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && OrderOpenTime()>=iTime(Symbol(),TF,0) && (type==-1 || OrderType()==type)) count++;}}
return(count);}
//--------------------------------------------------------------------+
double Profit(int type)
{double Profit = 0;
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
if(OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES))
{if (Symbol()==OrderSymbol() && OrderMagicNumber() == Magic && (OrderType() == type || type==-1)) Profit += OrderProfit()+OrderSwap()+OrderCommission();}}
return (Profit);}
//--------------------------------------------------------------------+
void Closer()
{double priceB, priceS;
for(int i=OrdersTotal()-1;i>=0;i--)
{if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && OrderType()==OP_BUY)
{priceB=NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID), Digits);
OrderClose(OrderTicket(),OrderLots(),priceB,1000,0);}
if(Symbol()==OrderSymbol() && OrderMagicNumber()==Magic && OrderType()==OP_SELL)
{priceS=NormalizeDouble(MarketInfo(OrderSymbol(),MODE_ASK), Digits);
OrderClose(OrderTicket(),OrderLots(),priceS,1000,0);}}}
return;}

相关资源

暂无评论

暂无评论...