支持中心 帮助文档 联系我们
📱 微信: 18391752892 | 💬 QQ: 3313198376 | ✈️ Telegram | 📧 fishfx123@gmail.com
EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34% EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34%

Cascade trading combined with Reverse MA

👤 作者: Chia Leilypour

4.5 分

¥0.00

📌 版本: v1.0
📥 下载: 0
⭐ 评分: 4.5

📝 产品详情

Cascade trading combined with Reverse MA

作者Chia Leilypour
版本v1.0
激活数0
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Most_Common_Classes.mqh>


   // Define parameters for the moving averages
   input int fastMAPeriod = 10;  // Fast MA period (e.g., 10 for scalping)
   input int slowMAPeriod = 20;  // Slow MA period (e.g., 20 for scalping)
   input ENUM_MA_METHOD maMethod = MODE_SMA;
   double lotSize;
   int maShift_current = 0; 
   int maShift_Previous = 1;
   
   bool enough_money;
   bool enough_valume;
   string message;
   bool IsBuy;
   bool TradeIsOk;
   double StopLoss;
   double TakeProfit;

   input double RiskPercent=0.01;
   input double R2R=2;
   input double StopLossPoints=100;
   input double MinimumStopLossPoints=25;
   ST_StopLoss_TakeProfit arr;

int OnInit()
  {
   // Initialization
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   // Cleanup code
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
       // No shift for moving averages
    // Use Simple Moving Average (SMA)
   ENUM_APPLIED_PRICE appliedPrice = PRICE_CLOSE; // Apply to Close prices

   // Get the values of the current and previous moving averages
   
   // if (AccountInfoDouble(ACCOUNT_PROFIT)>100){close_All_Orders();}
   
   double fastMA_Current = MACalculator(_Symbol,PERIOD_CURRENT,fastMAPeriod,maShift_current,maMethod,appliedPrice);   // Current Fast MA
   double slowMA_Current = MACalculator(_Symbol,PERIOD_CURRENT,slowMAPeriod,maShift_current,maMethod,appliedPrice);   // Current Slow MA
   double fastMA_Previous = MACalculator(_Symbol,PERIOD_CURRENT,fastMAPeriod,maShift_Previous,maMethod,appliedPrice);  // Previous Fast MA
   double slowMA_Previous = MACalculator(_Symbol,PERIOD_CURRENT,slowMAPeriod,maShift_Previous,maMethod,appliedPrice);   // Previous Slow MA
   double Refference_MA = MACalculator(_Symbol,PERIOD_CURRENT,100,maShift_Previous,maMethod,appliedPrice);
// Get current account information
     // Set lot size for trades
   double ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); // Current Ask price
   double bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits); // Current Bid price

   
     if(IsNewCanddle(PERIOD_H1))
      {
         TradeIsOk=true;
         
         //if(PositionsTotal() != 0)canddleCount=canddleCount+1;
         
      }
   

   if(fastMA_Previous < slowMA_Previous && fastMA_Current > slowMA_Current && SymbolOpenOrders(Symbol())==0 && bid< Refference_MA)
   {
      
               //lotSize=OptimumLotSize(_Symbol,ask,StopLoss,RiskPercent);
               lotSize=0.01;
               enough_money =CheckMoneyForTrade(Symbol(),lotSize,ORDER_TYPE_SELL);
               enough_valume=CheckVolumeValue(lotSize,message);
               StopLoss=bid+StopLossPoints*Point();
               TakeProfit=bid-R2R*StopLossPoints*Point();
              if(enough_money && enough_valume)  Trading.Sell(lotSize, NULL, bid, StopLoss,0, "Logic Order");
               IsBuy=false;
   }


   if(fastMA_Previous > slowMA_Previous && fastMA_Current < slowMA_Current && SymbolOpenOrders(Symbol())==0 && ask > Refference_MA)
   {

 
               //lotSize=OptimumLotSize(_Symbol,ask,StopLoss,RiskPercent);
               lotSize=0.01;
               enough_money =CheckMoneyForTrade(Symbol(),lotSize,ORDER_TYPE_BUY);
               enough_valume=CheckVolumeValue(lotSize,message);
               StopLoss=bid-StopLossPoints*Point();
               TakeProfit=bid+R2R*StopLossPoints*Point();
               if(enough_money && enough_valume)Trading.Buy(lotSize, NULL, ask,  StopLoss,0, "Logic Order");
               IsBuy=true;

   }
     if(TradeIsOk && SymbolOpenOrders(Symbol())>=1)
      {   
        //arr=Cascade_trading(_Symbol,lotSize,IsBuy,ask,bid,TakeProfit,StopLoss,StopLossPoints,MinimumStopLossPoints,R2R,true, SymbolOpenOrders(Symbol()));
        
       
         //TakeProfit=arr.NewTakeProfit;
         //StopLoss=arr.NewStopLoss;

      }  
  }
  
  
  



安全须知

本产品仅通过 MQL5.com 官方渠道获取。其他渠道版本可能缺少完整功能和技术支持。

EA 配置

交易品种XAUUSD
时间框架H1 (推荐)
推荐经纪商IC Markets, IC Trading
最低存款$300 / 0.01手

📸 截图预览