The Theory of Cycles

Author: The Theory of Cycles
Profit factor:
0.54
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Miscellaneous
It plays sound alerts
7 Views
0 Downloads
0 Favorites
The Theory of Cycles



#property copyright "The Theory of Cycles"
#define   MAGIC     02001010137


extern string _Parameters_Trade = "Parameters_Trade"; 
extern double Lots           = 0.1;    
extern int    StopLoss       = 50;     
extern int    TakeProfit     = 300;
extern int    TrailingStop   = 30;   
extern int    TrailingStep   = 0; 
extern string _Parameters_Expert = "Parameters_Expert";
extern int    DelayCycle     = 10;      
extern int    PassCycle      = 10;  

 bool   UseSound      = True;         
 string NameFileSound = "expert.wav"; 
color  clOpenBuy     = LightBlue;    
color  clOpenSell    = LightCoral;  
color  clModifyBuy   = Aqua;         
 color  clModifySell  = Tomato;       
color  clCloseBuy    = Blue;         
color  clCloseSell   = Red;   
bool   ProfitTrailing = True;  
int    cnt=0;
int    HighLowCycle=100;
int    NotyCycle=2;
int    AmpliCycle=10;


int    initialize=1;
int    iTmp=0;
int    s=0;
int    b=0;
double ho=0;
double lo=0;
int    i=0;
int    fl=0;
int    lotsi;


void start() {


if (OrdersTotal() > 0 )
   {
   if(CurTime()- OrderOpenTime() < DelayCycle * 864) return(0);
  
   }
  else
   {
   if (CurTime()- OrderOpenTime() < PassCycle * 10) return(0);
   }



if (initialize == 1)
   {
   if (OrdersTotal() == 0)
      {
      initialize = 0;
      fl = 0;
      return(0);
      }
   iTmp = 0;
  
   for (i=0; i<OrdersTotal(); i++) 
      {
      
       if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
          if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP ) iTmp++;
    }
     }
      }
   
   if (iTmp == 0 || iTmp == 2) 
      {
      initialize = 0;
      fl = 0;
      return(0);
      }
   
    for (i=0; i<OrdersTotal(); i++) 
      {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
          if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP ) OrderDelete(OrderTicket());
    }
     }
      }
  return(0);
   }



CheckForOpen();
TrailingPositions();


}


void CheckForOpen() {
 
 if (fl == 1 )
   {
   fl = 0;
   if (Low[0] > lo - AmpliCycle * Point ) 
   OrderSend(Symbol(),OP_SELLSTOP,Lots,lo - AmpliCycle * Point,3,lo + StopLoss * Point,lo - TakeProfit * Point,"B.A.R.S.",MAGIC,0,Red);

 
   
   if (Low[0] < lo - AmpliCycle * Point ) 
   OrderSend(Symbol(),OP_SELLSTOP,Lots,lo - AmpliCycle * Point,3,lo + StopLoss * Point,lo - TakeProfit * Point,"B.A.R.S.",MAGIC,0,Yellow);
}

b = 0;
s = 0;

if (OrdersTotal() != 0)
   {
   
    for (i=0; i<OrdersTotal(); i++) 
      {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
          if (OrderType()==OP_BUYSTOP ) b++;
          if (OrderType()==OP_SELLSTOP )s++;
          if (s + b == 2) return(0);
          }
         }
   }
   }
  

if (OrdersTotal() != 0 && b + s == 1) 
   {
   for (i=0; i<OrdersTotal(); i++) 
      {
     if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
          if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP ) OrderDelete(OrderTicket());
  
  }
  }
  }
  return(0);
  
}




if (OrdersTotal() == 0 && b + s == 0) 
   {

   ho = High[1];
   lo = Low[1];
  
   for (i=NotyCycle; i<=1; i++)

      {
      if (High[i] > ho) ho = High[i];
      if (Low[i] < lo ) lo = Low[i];
      }
   }


if ( OrdersTotal() == 0 && b + s == 0 && ho - lo < HighLowCycle * Point) 
   {
   fl = 1;
   if (High[0] > ho - AmpliCycle * Point) 
   
   OrderSend(Symbol(),OP_BUYSTOP,Lots,ho + AmpliCycle * Point,3,ho - StopLoss * Point,ho + TakeProfit * Point,"B.A.R.S.",MAGIC,0,Blue);

    if (High[0] < ho - AmpliCycle * Point) 
   
   OrderSend(Symbol(),OP_BUYSTOP,Lots,ho + AmpliCycle * Point,3,ho - StopLoss * Point,ho + TakeProfit * Point,"B.A.R.S.",MAGIC,0,Blue);

   }
}



void TrailingPositions() {

  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
  
        if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC ) {
          if (OrderType()==OP_BUY) {
            if (!ProfitTrailing || (Bid-OrderOpenPrice())>TrailingStop*Point) {
             
              if (OrderStopLoss()<Bid-(TrailingStop+TrailingStep-1)*Point) {
                  ModifyStopLoss(Bid-TrailingStop*Point, clModifyBuy);
              }
            }
          }
          if (OrderType()==OP_SELL) {
            if (!ProfitTrailing || OrderOpenPrice()-Ask>TrailingStop*Point) {
              if (OrderStopLoss()>Ask+(TrailingStop+TrailingStep-1)*Point || OrderStopLoss()==0) {
                ModifyStopLoss(Ask+TrailingStop*Point, clModifySell);
              }
            }
          }
        }
      }
    }
  }

void ModifyStopLoss(double ldStop, color clModify) {

  bool   fm;
  double ldOpen=OrderOpenPrice();
  double ldTake=OrderTakeProfit();

  fm=OrderModify(OrderTicket(), ldOpen, ldStop, ldTake, 0, clModify);
 
  if (fm && UseSound) PlaySound(NameFileSound);
}

Profitability Reports

NZD/USD Jul 2025 - Sep 2025
0.49
Total Trades 422
Won Trades 115
Lost trades 307
Win Rate 27.25 %
Expected payoff -2.22
Gross Profit 904.30
Gross Loss -1842.00
Total Net Profit -937.70
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.71
Total Trades 394
Won Trades 110
Lost trades 284
Win Rate 27.92 %
Expected payoff -1.23
Gross Profit 1218.20
Gross Loss -1704.00
Total Net Profit -485.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 364
Won Trades 0
Lost trades 364
Win Rate 0.00 %
Expected payoff -4.29
Gross Profit 0.00
Gross Loss -1559.97
Total Net Profit -1559.97
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 473
Won Trades 0
Lost trades 473
Win Rate 0.00 %
Expected payoff -3.91
Gross Profit 0.00
Gross Loss -1847.76
Total Net Profit -1847.76
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.01
Total Trades 391
Won Trades 130
Lost trades 261
Win Rate 33.25 %
Expected payoff 0.04
Gross Profit 1581.50
Gross Loss -1566.00
Total Net Profit 15.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.69
Total Trades 380
Won Trades 135
Lost trades 245
Win Rate 35.53 %
Expected payoff -1.20
Gross Profit 1015.60
Gross Loss -1470.00
Total Net Profit -454.40
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.74
Total Trades 350
Won Trades 114
Lost trades 236
Win Rate 32.57 %
Expected payoff -0.76
Gross Profit 748.25
Gross Loss -1014.20
Total Net Profit -265.95
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.51
Total Trades 408
Won Trades 108
Lost trades 300
Win Rate 26.47 %
Expected payoff -2.16
Gross Profit 918.70
Gross Loss -1800.00
Total Net Profit -881.30
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.67
Total Trades 245
Won Trades 59
Lost trades 186
Win Rate 24.08 %
Expected payoff -1.50
Gross Profit 747.90
Gross Loss -1116.00
Total Net Profit -368.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.56
Total Trades 363
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.90
Gross Profit 882.60
Gross Loss -1572.00
Total Net Profit -689.40
-100%
-50%
0%
50%
100%

Comments