FM-PIPS

FM-PIPS

官方版 无广告 113

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

19 人已下载 手机查看

FM-PIPS

//+------------------------------------------------------------------+
//| FM-PIPS.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright ""
#property link ""
//-----------------------相疣戾蝠?-----------------------------------+
extern string c0="------------------------";
extern double Risk =25;
extern double ProfitProcent =0.7;
extern double StopProcent =0;
extern string c1="------------------------";
extern int Pips =3;
extern int StepLock =2;
extern int Step =1;
extern int MaxOrder =5;
extern string c2="------------------------";
extern int TimeStart =0; //吗屐 磬鬣豚 疣犷螓
extern int TimeEnd =23; //吗屐 铌铐鬣龛 疣犷螓
extern string c3="------------------------";
extern int TimeLife =60; //怵屐 骅珥?铕溴痤??扈眢蜞?
extern double ProfitTimeClose =-2; //洛腓麒磬 爨犟桁嚯钽?筢赅 ?%
extern int FrameFiltr =60;
extern int TF =1;
extern int Magic =7777; //锑痍屦 铕溴痤?
//--------------------------------------------------------------------+
string CommentEA ="FM-PIPS";
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);
//--------------------------------------------------------------------+
Buy=false;Sell=false;
if (iMA(NULL,0,1,0,0,0,1)<iMA(NULL,0,1,0,0,0,2)-Pips*D*Point && iLow(Symbol(),FrameFiltr,1)>Ask){Buy=true;}
if (iMA(NULL,0,1,0,0,0,1)>iMA(NULL,0,1,0,0,0,2)+Pips*D*Point && iHigh(Symbol(),FrameFiltr,1)<Bid){Sell=true;}
//--------------------------------------------------------------------+
if(TimeHour(TimeCurrent())>=TimeStart && TimeHour(TimeCurrent())<TimeEnd)
{
if(Count(-1)==0 && Count2(OP_BUY)==0 && Buy)
{OrderSend (Symbol(),OP_BUY,Lot,Ask,100,0,0,CommentEA,Magic,0,Green);}
if(Count(-1)==0 && Count2(OP_SELL)==0 && Sell)
{OrderSend (Symbol(),OP_SELL,Lot,Bid,100,0,0,CommentEA,Magic,0,Red);}
}
//--------------------------------------------------------------------+
if(Count(OP_BUY)>0 && Count(OP_SELL)==0 && Ask+StepLock*D*Point<=BuyPric() && Sell)
{OrderSend(Symbol(),OP_SELL,Lot,Bid,100,0,0,CommentEA,Magic,0,Red);}
if(Count(OP_SELL)>0 && Count(OP_BUY)==0 && Bid-StepLock*D*Point>=SellPric() && Buy)
{OrderSend(Symbol(),OP_BUY,Lot,Ask,100,0,0,CommentEA,Magic,0,Green);}
//--------------------------------------------------------------------+
if(Count(OP_SELL)+MaxOrder>Count(OP_BUY) && Count(OP_BUY)>0 && Count(OP_SELL)>0 && Ask-Step*D*Point>=BuyPric())
{OrderSend(Symbol(),OP_BUY,Lot,Ask,100,0,0,CommentEA,Magic,0,Green);}
if(Count(OP_BUY)+MaxOrder>Count(OP_SELL) && Count(OP_SELL)>0 && Count(OP_BUY)>0 && Bid+Step*D*Point<=SellPric())
{OrderSend(Symbol(),OP_SELL,Lot,Bid,100,0,0,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(CountTime(-1)>0 && Count(-1)>1)
{double ProfProcL=(AccountBalance()/100)*ProfitTimeClose;
if(Profit(-1)>=ProfProcL)
Closer();}
//--------------------------------------------------------------------+
return(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 CountTime(int type)
{int count=0;
for(int i=OrdersTotal()-1;i>=0;i--){
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{if(OrderMagicNumber()==Magic && OrderOpenTime()+(TimeLife*60)<TimeCurrent() && (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;}
//----------痒栩噱?觐腓麇耱忸 镳铋溴睇?矬黻蝾?镱 徉?---------------+
double BuyPric() {
double oldorderopenprice;
int oldticketnumber;
double unused = 0;
int ticketnumber = 0;
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY) {
oldticketnumber = OrderTicket();
if (oldticketnumber > ticketnumber) {
oldorderopenprice = OrderOpenPrice();
unused = oldorderopenprice;
ticketnumber = oldticketnumber;}}}
return (oldorderopenprice);}
//----------痒栩噱?觐腓麇耱忸 镳铋溴睇?矬黻蝾?镱 皴腚---------------+
double SellPric() {
double oldorderopenprice;
int oldticketnumber;
double unused = 0;
int ticketnumber = 0;
for (int cnt = OrdersTotal() - 1; cnt >= 0; cnt--) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() != Symbol() || OrderMagicNumber() != Magic) continue;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_SELL) {
oldticketnumber = OrderTicket();
if (oldticketnumber > ticketnumber) {
oldorderopenprice = OrderOpenPrice();
unused = oldorderopenprice;
ticketnumber = oldticketnumber;}}}
return (oldorderopenprice);}

相关资源

暂无评论

暂无评论...