SonicStoIkEA

Author: @2009 Desynced Tech
Orders Execution
It automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategyChecks for the total of open orders
Indicators Used
Stochastic oscillatorRelative strength indexDeMarker indicatorForce indexBill Williams Accelerator/Decelerator oscillatorBill Williams Awesome oscillatorMoving average indicator
1 Views
0 Downloads
0 Favorites

Profitability Reports

AUD/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 2
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 6.50
Gross Profit 13.00
Gross Loss 0.00
Total Net Profit 13.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.00 %
Total Trades 2
Won Trades 2
Lost trades 0
Win Rate 1.00 %
Expected payoff 6.50
Gross Profit 13.00
Gross Loss 0.00
Total Net Profit 13.00
-100%
-50%
0%
50%
100%
SonicStoIkEA
//+------------------------------------------------------------------+
//|                                                 SonicStoIkEA.mq4 |
//|                                              @2009 Desynced Tech |
//|                                     http://desynced.no-ip.org/fx |
//+------------------------------------------------------------------+
#property copyright "@2009 Desynced Tech"
#property link      "http://desynced.no-ip.org/fx"

int MAGIC = 41;



int iLastRegular;
double dLastAES;
double   ItrendLevel           = 0.0018;  //iTrend line must be above this level


extern int SMA_Filter_Period = 200;

extern int RSI_Filter_Period = 45;




double OzFX_AES;
  int OzFX_Regular;
  double Filter_SMA;
  double Filter_RSI;
  
  double iTredn1;
  double iTredn2;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

 int tik = getNumberTrades ();
 
 if ( tik > 0 ) {
 
  // trailingProfit(tik);
   return(0);
 }


decisionMaker();

  if (  OzFX_Regular == 1  &&  OzFX_AES == 0 && iTredn1 > 0.003 /*&& Filter_SMA == 1  /* && Filter_RSI == 1  */) {
  
    Print( OzFX_Regular , " " ,  OzFX_AES , " " ,Filter_SMA , " " ,Filter_RSI , " " , iTredn1 , " " , iTredn2);
    sendOrder(OP_BUY,0.1,65,0);
  }


if (  OzFX_Regular == -1 &&  OzFX_AES == -0.7 /*&& Filter_SMA == -1  /* && Filter_RSI == -1*/ ) {
  
  Print( OzFX_Regular , " " ,  OzFX_AES , " " ,Filter_SMA , " " ,Filter_RSI , " " , iTredn1 , " " , iTredn2);
      sendOrder(OP_SELL,0.1,65,0);
  }


   return(0);
  }
//+------------------------------------------------------------------+


int sendOrder(int type , double lots , int takeprofit , int stoploss ) {


   double tp;
   int ticket;
   if ( type == OP_SELL ) {
   
   if ( takeprofit > 0 ) tp = Bid-takeprofit*Point;
  
   else tp = 0;
   ticket =  OrderSend(Symbol(),OP_SELL, lots, Bid, 3, 0, tp,"", MAGIC, 0, Red); 
   
   
   return(ticket);
   }
   
   if ( type == OP_BUY ) {
   
        if ( takeprofit > 0 )  tp = Ask+takeprofit*Point;
        else tp = 0;

        ticket =  OrderSend(Symbol(),OP_BUY, lots, Ask, 3, 0, tp,"", MAGIC, 0, Red); 
         return (ticket);
   
   
   }
   
}



void trailingProfit(int tik) {

  
if ( tik != -1 ) {
   
   //if ( OrderProfit() > maxprofit ) maxprofit = OrderProfit();
   
   if ( OrderType() == OP_BUY && OrderProfit() > 0 ) {
         
       //  Print(" diff  " ,OrderProfit() , " = > " ,((OrderTakeProfit() - Ask)/Point));
         
         if ( ((OrderTakeProfit() - Ask)/Point) <= 6 ) OrderModify(tik,OrderOpenPrice(),OrderTakeProfit()/*Bid-65*Point*/,Ask+50*Point,0,Blue);
   
   }
   
   if ( OrderType() == OP_SELL && OrderProfit() > 0 ) {
   
  
   
   
            if ( (  (OrderTakeProfit()-Bid)/Point)*(-1) <= 6 ) OrderModify(tik,OrderOpenPrice(), Ask+65*Point,Bid-50*Point,0,Red);
   
   
           // Print(" diff sell " ,OrderProfit() , " = > " ,(  (OrderTakeProfit()-Bid)/Point)*(-1));
   }
   


}


}


int getNumberTrades()
{   
   int total = OrdersTotal();
   int numords = 0;
      
   for(int cnt=0; cnt<total; cnt++) 
   {        
   OrderSelect(cnt, SELECT_BY_POS);            
   if(OrderSymbol() == Symbol() &&  OrderMagicNumber() == MAGIC) 
      return (OrderTicket());
   }
   return(-1);
} 



void decisionMaker() {


   double sMain        = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_MAIN,0);
  double sSignal      = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_SIGNAL,0);
  
  double sMainprev        = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_MAIN,1);
  double sSignalprev      = iStochastic(NULL,0,14,5,5,MODE_SMA,0,MODE_SIGNAL,1);
  
  //--- i-Trend Index
 iTredn1      =iCustom(NULL, 0, "i_Trend", 0, 0, 0, 20, 2, 13, 300, 0,  0); //green
  iTredn2      =iCustom(NULL, 0, "i_Trend", 0, 0, 0, 20, 2, 13, 300, 1, 0); //red
  
  
  //--- RSI
  double sRSI         = iRSI(NULL,0,14,0,0); 
  double sRSIL1       = 51;
  double sRSIL2       = 49;
  
   //DeMaker and FI
  double  DEM  = iDeMarker(NULL, 0, 14, 0); 
  double  DEML = 0.5; 
  double  FI = iForce(NULL, 0, 14, 1, PRICE_CLOSE, 0);
  
  
  
  OzFX_Regular=0;
  
  /*---------------------*/            
/*  OZFX REGULAR CODE  */
/*---------------------*/
     
      if ((sMain>sSignal)&& (sMain>sMainprev)&&(iTredn1>ItrendLevel && iTredn1>iTredn2)&& (sRSI>=sRSIL1)&&(DEM>DEML)&&(FI>0)) // BUY
      {
         if (iLastRegular != 1) OzFX_Regular = 1;
         iLastRegular = 1;
      }   
      
     if ((sMain<sSignal)&&(sMain<sMainprev)&&(iTredn2>ItrendLevel && iTredn2>iTredn1)&& (sRSI<=sRSIL2)&&(DEM<DEML)&&(FI<0)) // SELL
       
      {   
         if (iLastRegular != -1) OzFX_Regular = -1;
         iLastRegular = -1;
      }   
      //if (Show_Sonic_Signals == false) OzFX_Regular[k] = 0.0;
      
/*-----------------*/            
/*  OZFX AES CODE  */
/*-----------------*/
       OzFX_AES = 0;
      if (/*iAC(Symbol(), 0, k) > 0 &&*/
          iAC(Symbol(), 0, 0) > iAC(Symbol(), 0, 1) &&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, 0)
          > iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 0) /*&&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k + 1)
          < iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k + 1) &&
          iAO(Symbol(), 0, k) > iAO(Symbol(), 0, k + 1)*/)
      {
         if (dLastAES != 0.7) OzFX_AES = 0.7;
         dLastAES = 0.7;
      }   
      
      if (/*iAC(Symbol(), 0, k) < 0 &&*/
          iAC(Symbol(), 0, 0) < iAC(Symbol(), 0, 1) &&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, 0)
          < iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 0) /*&&
          iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, k + 1)
          > iStochastic(Symbol(), 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, k + 1) &&
          iAO(Symbol(), 0, k) < iAO(Symbol(), 0, k + 1)*/)
      {
         if (dLastAES != -0.7) OzFX_AES = -0.7;
         dLastAES = -0.7;
      }   
      //if (Show_AES_Signals == false) OzFX_AES[k] = 0.0;             
/*-------------------*/            
/*  SMA FILTER CODE  */
/*-------------------*/            
      Filter_SMA = 0;
      if (Close[0] > iMA(Symbol(), 0, SMA_Filter_Period, 0, MODE_SMA, PRICE_CLOSE, 0))
         Filter_SMA = 1;
      if (Close[0] <= iMA(Symbol(), 0, SMA_Filter_Period, 0, MODE_SMA, PRICE_CLOSE, 0))
         Filter_SMA = -1;
      //if (Show_SMA_Filter == false) Filter_SMA[0] = EMPTY_VALUE;

/*-------------------*/            
/*  RSI FILTER CODE  */
/*-------------------*/            
       Filter_RSI = 0;
      if (50 > iRSI(Symbol(), 0, RSI_Filter_Period, PRICE_CLOSE, 0))
         Filter_RSI = -1;
      if (50 <= iRSI(Symbol(), 0, RSI_Filter_Period, PRICE_CLOSE, 0))
         Filter_RSI = 1;
     // if (Show_RSI_Filter == false) Filter_RSI[k] = EMPTY_VALUE;
  
  
       

}

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 ---