MT4跟MT5的寫法不一樣 你應該要註明清楚哪個版本的
Hung Wen Lin:
MT4跟MT5的寫法不一樣 你應該要註明清楚哪個版本的
MT4
MT4跟MT5的寫法不一樣 你應該要註明清楚哪個版本的
//+------------------------------------------------------------------+ //| 叉叉交易.mq4 | //| Submarine | //| https://www.mql5.com/zh/users/carllin000 | //+------------------------------------------------------------------+ #property copyright "Submarine" #property link "https://www.mql5.com/zh/users/carllin000" #property version "1.00" #property strict input double Lots = 0.1; input int Magic = 12345; input string Comm = "叉叉交易"; input int Fast = 5; input int Slow = 10; int BarCount; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy timer } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- if(AccountProfit()>=5) deleteorder(-100); if(BarCount!=iBars(NULL,0)) BarCount=iBars(NULL,0); else return; double SlowMA = iMA(NULL,0,Fast,0,0,0,1); double SlowMA1 = iMA(NULL,0,Fast,0,0,0,2); double FastMA = iMA(NULL,0,Slow,0,0,0,1); double FastMA1 = iMA(NULL,0,Slow,0,0,0,2); if(FastMA1<SlowMA1 && FastMA>SlowMA) { deleteorder(OP_SELL); if(OrdersTotal()==0) int b=OrderSend(NULL,OP_BUY,Lots,Ask,60,0,0,Comm,Magic,0,clrBlue); } if(FastMA1>SlowMA1 && FastMA<SlowMA) { deleteorder(OP_BUY); if(OrdersTotal()==0) int b=OrderSend(NULL,OP_SELL,Lots,Bid,60,0,0,Comm,Magic,0,clrRed); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void deleteorder(int type) { for(int i=OrdersTotal()-1;i>=0;i--) { if(OrderSelect(i,SELECT_BY_POS)) if(OrderType()==type || type==-100) { if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),60)==false) Print("ErrorDescription"+(string)GetLastError()); i=OrdersTotal(); } } }
這應該算是最簡單的寫法了
判断金死叉再考虑下等于,盈利5美金考虑下是本EA订单的盈利,似乎贴切些。
大家好,我刚刚接触EA。谁可以帮忙写个最简单的双均线模型?我参考参考。
要求,加载到黄金1小时线上
均线5金叉均线10,多开
均线5死叉均线10,空开
盈利5美金或者均线5死叉均线10,多单平
盈利5美金或者均线5金叉均线10,空单平