qq_v2.1_eurusd_MM

Download script
Author: RamilT
Profit factor:
0.23

This automated trading script is designed to manage and execute trades on the MetaTrader platform by following a specific set of rules regarding market timing, price movement, and risk management. Below is a breakdown of how the logic operates in plain language:

Operational Constraints

Before the script performs any actions, it checks for three specific conditions:

  • Time Window: The script only operates during a specific time of day. If the current hour is outside the user-defined start and end times, the script remains idle.
  • Data Sufficiency: It requires a minimum amount of historical price data (at least 100 bars) to be present on the chart before it will begin its analysis.
  • Trade Availability: The script monitors existing positions to ensure it doesn't open redundant trades unless specific conditions are met.

Dynamic Lot Sizing and Risk Management

The script includes an automated "Money Management" feature. If enabled, it calculates the trade size based on your account's available free margin. It ensures that the position size is adjusted proportionally to your balance, providing a layer of safety by preventing over-leveraging while ensuring the trade volume stays within predefined limits.

Trade Entry Logic

The script identifies opportunities by comparing current price action against historical price points on 5-minute intervals. It looks for specific "momentum" signals:

  • Buy Signals: The script looks for instances where the opening price of a recent candle is significantly higher than a previous closing price, combined with the current market price being above that opening point.
  • Sell Signals: Conversely, it seeks out instances where the opening price is significantly lower than a previous closing price, paired with the current market price falling below that opening point.

When these conditions are met and there are no active trades of this type, the script automatically places a Buy or Sell order. It simultaneously sets:

  • Take Profit (TP): A target price to lock in gains.
  • Stop Loss (SL): A safety net to limit potential losses.

Trade Management and Exits

Once a trade is live, the script actively manages it using two primary mechanisms:

  1. Trailing Stops: If configured, the script can "trail" the price. As the market moves in your favor, the stop loss moves automatically to protect your profits. It ensures that the protective stop never moves backward, only forward.
  2. Automatic Closure: The script constantly monitors the live price against the Take Profit and Stop Loss levels. If the market hits either of these targets (or if the trailing stop is triggered), the script will immediately close the position to finalize the trade.
Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each bar
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself
11 Views
0 Downloads
0 Favorites
qq_v2.1_eurusd_MM
// Because of my dismal stupidity not even named this EA 
#property copyright "RamilT" 
#property link "RamilT@bk.ru" 


//-----------------------------------Òèïà ïåðåìåííûå----------------------------------------------------------- 
extern int Magic = 1111;
extern int pr=12; 
extern int sl=30; 
extern int tp=70; 
extern int tz=60; 
extern int mm=1; 
extern int qq=30; 
extern int chas1=11; 
extern int chas2=22; 
extern double Lots=1;
extern double TrailingStop = 0;

double BuyStop=0, PrevBuyStop=0, SellStop=0, PrevSellStop=0;
double Slippage =3, TakeProfit=0, StopLoss =0; 
//------------------------------------------------------------------------------------------------------------- 


int start() 
{ 
   if(Hour()<=chas1||Hour()>=chas2)return(0); 
   if(Bars<100) 
   { 
   Print("bars less than 100"); 
   return(0); 
   } 
//-----------------------------------Ìîíýé ìåíäæìåíò----------------------------------------------------------- 
   
   if (ScanTrades()>0 ) HideTrailStop();
   
   if (mm==1) 
   { 
   if(Lots<(MathCeil((AccountFreeMargin()/1000)*qq)/10)){Lots=(MathCeil((AccountFreeMargin()/10000)*qq)/10);if(Lots>100){Lots=100;}} 
   } 
//------------------------------------------------------------------------------------------------------------- 


//----------------------------------Ãëàâíûé àëãîðèòì----------------------------------------------------------- 
   if(ScanTrades()<1)
   { 
      if (((iOpen(NULL,5,1)-iClose(NULL,5,pr))>(Point*tz))&&(Ask>iOpen(NULL,5,1))) 
      { 
      if( tp>0 ) TakeProfit = Ask+tp*Point; else TakeProfit = 0;
      if( sl>0 ) StopLoss =  Ask-sl*Point;  else StopLoss = 0;
      OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"qq-buy60",Magic,0,Blue); 
      BuyStop=0; PrevBuyStop=StopLoss;
      } 


      if (((iOpen(NULL,5,1)-iClose(NULL,5,pr))<(-Point*tz))&&(Bid<iOpen(NULL,5,1))) 
      { 
      if( tp>0 ) TakeProfit = Bid-tp*Point; else TakeProfit = 0;
      if( sl>0 ) StopLoss =  Bid+sl*Point;  else StopLoss = 0;
      OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"qq-sell60",Magic,0,Red); 
      SellStop=0; PrevSellStop=StopLoss;
  
      } 
   } 
   
   

} 
//------------------------------------------------------------------------------------------------------------- 


 

int ScanTrades()
{   
   int total = OrdersTotal();
   int numords = 0;
      
   for(int cnt=0; cnt<total; cnt++) 
   {        
   OrderSelect(cnt, SELECT_BY_POS);            
   if(OrderSymbol() == Symbol() && OrderType()<=OP_SELLSTOP && OrderMagicNumber() == Magic) 
   numords++;
   }
   return(numords);
}  


void HideTrailStop()
{
   for (int cnt=0;cnt<OrdersTotal();cnt++)
   { 
   OrderSelect(cnt, SELECT_BY_POS);   
   int mode=OrderType();    
      if ( OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) 
      {
         if (mode==OP_BUY) 
         {
			   if ( TrailingStop >0 )
			   {
			   BuyStop = Bid - TrailingStop*Point;
			   if (BuyStop < PrevBuyStop ) BuyStop = PrevBuyStop;       
               if( OrderOpenPrice() <= BuyStop ) 
               {   
			         if ( Bid <= BuyStop || (Bid >= TakeProfit && TakeProfit>0) || Bid <= StopLoss)
			         {
			         OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Yellow);
			         return(0);
			         }
               }            
            }
            else
            if ( (Bid >= TakeProfit && TakeProfit>0) || Bid <= StopLoss)
			   {
			   Print("BUY: TP = ",TakeProfit," SL=", StopLoss);
			   OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Yellow);
			   return(0);
			   }
         }   
// - SELL Orders          
         if (mode==OP_SELL)
         {
            Print("SEll: TP = ",TakeProfit," SL=", StopLoss," Ask=", Ask);
            if ( TrailingStop >0 )
			   {
            SellStop = Ask + Point * TrailingStop;   
            if (SellStop > PrevSellStop && PrevSellStop > 0) SellStop = PrevSellStop; 
         
               if( OrderOpenPrice() >= SellStop) 
               {
                  if ( Ask >= SellStop || Ask <= TakeProfit || ( Ask >= StopLoss && StopLoss > 0))
                  {
                  OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
                  return(0);
                  }
   			   }	    
            }
            else
               if ( Ask <= TakeProfit || ( Ask >= StopLoss && StopLoss > 0))
               {
               Print("SEll: TP = ",TakeProfit," SL=", StopLoss);
               OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
               return(0);
               }
            }   
         }
      }     
   PrevBuyStop  = BuyStop;
   PrevSellStop = SellStop;
}

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
4 reports
GBP/USD Oct 2024 - Jan 2025
0.49
Total Trades 1128
Won Trades 224
Lost trades 904
Win Rate 19.86 %
Expected payoff -8.83
Gross Profit 9437.30
Gross Loss -19399.80
Total Net Profit -9962.50
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.42
Total Trades 1037
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -9.60
Gross Profit 7098.90
Gross Loss -17054.00
Total Net Profit -9955.10
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 345
Won Trades 0
Lost trades 345
Win Rate 0.00 %
Expected payoff -28.94
Gross Profit 0.00
Gross Loss -9984.50
Total Net Profit -9984.50
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 552
Won Trades 0
Lost trades 552
Win Rate 0.00 %
Expected payoff -18.07
Gross Profit 0.00
Gross Loss -9975.62
Total Net Profit -9975.62
-100%
-50%
0%
50%
100%

Comments