qq_v2.1_usdchf_MM

Download script
Author: RamilT
Profit factor:
0.26

This automated trading script is designed to manage and execute trades based on specific time constraints, market conditions, and risk management rules. Below is a breakdown of how the logic operates:

Operational Constraints

The script does not operate constantly. It features a built-in "active window" where it only scans for opportunities during specific hours of the day (defined by the user). Additionally, it includes a safety check to ensure there is sufficient historical price data available before it begins its calculations.

Dynamic Position Sizing

The tool includes a smart lot calculation feature. Depending on your settings, the script can automatically calculate the trade size based on your current account balance and available margin. This ensures that the volume of trades remains proportional to your capital, with a pre-set ceiling to prevent over-leveraging.

Trade Entry Logic

The core strategy relies on comparing price movements over a specific period:

  • Buy Signals: The script monitors the difference between a previous price point and the current market movement. If the price shows a significant upward trend (exceeding a specific threshold) and is positioned above a certain price level, it executes a "Buy" order.
  • Sell Signals: Conversely, if the price shows a significant downward trend that exceeds the established threshold and falls below a specific price level, the script executes a "Sell" order.

Trade Management and Exits

Once a trade is opened, the script manages the exit logic using three primary methods:

  1. Take Profit (TP): Automatically closes the trade when the price reaches a predefined profit target.
  2. Stop Loss (SL): Automatically closes the trade if the market moves against the position by a certain amount to limit losses.
  3. Trailing Stop: This is a dynamic protection mechanism. As the price moves in your favor, the "stop" level follows it at a set distance. If the market reverses and hits this moving threshold, the trade is closed, allowing the script to "lock in" gains while giving the trade room to fluctuate.

Order Monitoring

The script continuously scans for active positions associated with its unique identification number (Magic Number). This allows it to distinguish between trades it opened automatically and any manual trades you might place, ensuring it only manages its own specific operations.

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
5 Views
0 Downloads
0 Favorites
qq_v2.1_usdchf_MM
// Because of my dismal stupidity not even named this EA 
#property copyright "RamilT" 
#property link "RamilT@bk.ru" 


//-----------------------------------Òèïà ïåðåìåííûå----------------------------------------------------------- 
extern int Magic = 3333;
extern int pr=14; 
extern int sl=35; 
extern int tp=100; 
extern int tz=70; 
extern int mm=1; 
extern int qq=11; 
extern int chas1=5; 
extern int chas2=17; 
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
AUD/USD Oct 2024 - Jan 2025
0.52
Total Trades 798
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -9.63
Gross Profit 8191.60
Gross Loss -15872.50
Total Net Profit -7680.90
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.46
Total Trades 1580
Won Trades 230
Lost trades 1350
Win Rate 14.56 %
Expected payoff -6.31
Gross Profit 8471.80
Gross Loss -18435.80
Total Net Profit -9964.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.07
Total Trades 1139
Won Trades 22
Lost trades 1117
Win Rate 1.93 %
Expected payoff -8.76
Gross Profit 717.98
Gross Loss -10694.15
Total Net Profit -9976.17
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 717
Won Trades 0
Lost trades 717
Win Rate 0.00 %
Expected payoff -13.92
Gross Profit 0.00
Gross Loss -9984.10
Total Net Profit -9984.10
-100%
-50%
0%
50%
100%

Comments