有您的持续关注
我们会做得更好

智能交易系统 暴风雨 EA



暴风雨 EA开仓没有止损和盈利数值。应该是用到的条件平仓。

本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。暴风雨 EA源码:

//+------------------------------------------------------------------+
//|                                                       暴风雨.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.125808047.com/"

double FirstLots=0.1;
extern double MaxOrderNum=50;
extern double GivenPointClose=100;
extern double AimPointCloseAll=100;
extern int Slippage = 3;
extern int MagicNumber = 888888;
extern int MaxLots=20;

static int RecordTime;
static bool done=false;
bool cg = false;

int init() {
   ObjectCreate("comment_label", OBJ_LABEL, 0, 0, 0);
   ObjectSet("comment_label", OBJPROP_XDISTANCE, 50);
   ObjectSet("comment_label", OBJPROP_YDISTANCE, 20);
   ObjectSetText("comment_label", "紅之匯【暴風雨系統】辭黛", 20, "Arial", Red);
   return (0);
}

int deinit() {
   ObjectDelete("comment_label");
   Comment("www.125808047.com");
   return (0);
}

int start() {
    double HighIn4 = iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 20, 1));
    double LowIn4 = iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 20, 1));
    double HighIn2 = iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 20, 1));
    double LowIn2 = iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 20, 1));
     
    if (AccountFreeMargin() <= 100.0) {
        Alert("No money!");
        return (0);
    }
    
    if(GetTotalProfit()>AimPointCloseAll*Point*100000*FirstLots){
        CloseAllOrder();
    }
    
    if(OrdersTotal()>=MaxOrderNum){
        CloseAllGivenWinSell();
        CloseAllGivenWinBuy();
    }
  
    if(Time[0]!=RecordTime){
        RecordTime=Time[0];
        done=false;
    }
    if (Bid < LowIn4 && done==false && OrdersTotal()<MaxOrderNum && AccountFreeMargin()>100){
        MoneyManagement();
        cg = OrderSend(Symbol(), OP_BUY, FirstLots, NormalizeDouble(Ask, Digits), 
            Slippage, 0, 0, "Order Buy", MagicNumber, 0, Blue);
        done=true;
    }else if (Ask > HighIn4 && done==false && OrdersTotal()<MaxOrderNum && AccountFreeMargin()>100){
        MoneyManagement();
        cg = OrderSend(Symbol(), OP_SELL, FirstLots, NormalizeDouble(Bid, Digits), 
            Slippage, 0, 0, "Order Sell", MagicNumber, 0, Red);
        done=true;
    }
    
    if (Bid < LowIn2){
        CloseAllWinSell();
    }else if (Ask > HighIn2){
        CloseAllWinBuy();
    }
   
    return (0);
}

void CloseAllOrder(){
    bool SucceedClose = FALSE;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if(OrderType()==OP_BUY)
            cg = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,Digits), Slippage, Blue);
        else if(OrderType()==OP_SELL)
            cg = OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,Digits), Slippage, Red);
    }
}

double GetTotalProfit(){
    double TotalProfit=0;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if ((OrderType() == OP_BUY || OrderType() == OP_SELL) && OrderMagicNumber() == MagicNumber) 
            TotalProfit += OrderProfit();
    }
    return (TotalProfit);
}

void CloseAllWinSell(){
    bool SucceedClose = FALSE;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber && OrderProfit()>0) 
            SucceedClose=OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,Digits), 
                Slippage, Red);
    }
}

void CloseAllWinBuy(){
    bool SucceedClose = FALSE;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber && OrderProfit()>0) 
            SucceedClose=OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,Digits), 
                Slippage, Blue);
    }
}

void CloseAllGivenWinSell(){
    bool SucceedClose = FALSE;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if (OrderType() == OP_SELL && OrderMagicNumber() == MagicNumber && OrderProfit()>GivenPointClose*Point*100000*FirstLots) 
            SucceedClose=OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Ask,Digits), 
                Slippage, Red);
    }
}

void CloseAllGivenWinBuy(){
    bool SucceedClose = FALSE;
    for (int j= OrdersTotal() - 1; j >= 0; j--) {
        cg = OrderSelect(j,SELECT_BY_POS, MODE_TRADES);
        if (OrderType() == OP_BUY && OrderMagicNumber() == MagicNumber && OrderProfit()>GivenPointClose*Point*100000*FirstLots) 
            SucceedClose=OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(Bid,Digits), 
                Slippage, Blue);
    }
}

void MoneyManagement(){
    if(AccountEquity()<100000){
        FirstLots=0.1;
    }else{
        int times = AccountEquity()/50000;
        FirstLots=0.1*times;
        if(FirstLots>MaxLots)
          FirstLots=MaxLots;
    }
    
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » 智能交易系统 暴风雨 EA
上一篇:
下一篇:
分享到:更多 ()