Author: RamilT
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
0 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
45.00 %
Total Trades 573
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -11.83
Gross Profit 5598.80
Gross Loss -12377.50
Total Net Profit -6778.70
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
51.00 %
Total Trades 1658
Won Trades 321
Lost trades 1337
Win Rate 0.19 %
Expected payoff -5.76
Gross Profit 9846.80
Gross Loss -19401.10
Total Net Profit -9554.30
-100%
-50%
0%
50%
100%
qq_v2.2
// 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=11; 
extern int sl=35; 
extern int tp=75; 
extern int tz=60; 
extern int mm=1; 
extern int qq=10; 
extern int chas1=5; 
extern int chas2=17; 
extern double Lots=0.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); 
   } 
//-----------------------------------Ìîíýé ìåíäæìåíò----------------------------------------------------------- 
   //Print("Takeprofit=",GlobalVariableGet("takeprofit"), " Stoploss=",GlobalVariableGet("stoploss"));
   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(Month()!=12 && DayOfWeek()!=1 && ScanTrades()<1)
   { 
      if (((iOpen(NULL,5,1)-iClose(NULL,5,pr))>(Point*tz))&&(Ask>iOpen(NULL,5,1))) 
      { 
      if( tp>0 ) TakeProfit = NormalizeDouble(Ask+tp*Point,Digits); else TakeProfit = 0;
      if( sl>0 ) StopLoss =  NormalizeDouble(Ask-sl*Point,Digits);  else StopLoss = 0;
      GlobalVariableSet("takeprofit",TakeProfit);
      GlobalVariableSet("stoploss",StopLoss);
      
      OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"qq-buy60",Magic,0,Blue); 
      } 


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


 

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) 
      {
      TakeProfit = GlobalVariableGet("takeprofit");    
              
         if (mode==OP_BUY) 
         {
			   if ( TrailingStop > 0 )
			   {
			   
			   BuyStop = NormalizeDouble(Bid - TrailingStop*Point,Digits);
			     
			      if( OrderOpenPrice() > BuyStop ) BuyStop = GlobalVariableGet("stoploss");
			      else
			      {
			      PrevBuyStop = GlobalVariableGet("stoploss");
			      
			      if (BuyStop <= PrevBuyStop ) BuyStop = PrevBuyStop;
			      else GlobalVariableSet("stoploss",BuyStop); 
			      }
			   
			      if ( Bid <= BuyStop || (Bid >= TakeProfit && TakeProfit>0))
			      {
			      Print("BUY: TP = ",TakeProfit," BuyStop=", BuyStop," PrevStop=",PrevBuyStop);
			      OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Yellow);
			      return(0);
			      }
            }
            else
            {
            StopLoss   = GlobalVariableGet("stoploss");   
               if ( (Bid >= TakeProfit && TakeProfit>0) || Bid <= 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 = NormalizeDouble(Ask + Point * TrailingStop,Digits);   
               
               if( OrderOpenPrice() < SellStop ) SellStop = GlobalVariableGet("stoploss");
			      else
			      {
			      PrevSellStop = GlobalVariableGet("stoploss");
			      if (SellStop >= PrevSellStop ) SellStop = PrevSellStop;
			      else GlobalVariableSet("stoploss",SellStop); 
			      }
               
               if ( (Ask >= SellStop && SellStop > 0) || Ask <= TakeProfit )
               {
               Print("SELL: TP = ",TakeProfit," SellStop=", SellStop," PrevStop=",PrevSellStop);
               OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
               return(0);
               }
   			}
            else
            {
            StopLoss   = GlobalVariableGet("stoploss");  
               if ( Ask <= TakeProfit || ( Ask >= StopLoss && StopLoss > 0))
               {
               //Print("SEll: TP = ",TakeProfit," SL=", StopLoss);
               OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,White);
               return(0);
               }
            }   
         }
      }     
   }   
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---