Author: Last_Don
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
Indicators Used
Bill Williams Awesome oscillatorMovement directional indexMoney flow indexMoving average indicatorIchimoku Kinko Hyo
0 Views
0 Downloads
0 Favorites
DigiDon
//+------------------------------------------------------------------+
//|                                                      DigiDon.mq4 |
//|                                                         Last_Don |
//|                            http://www.mql4.com/ru/users/Last_Don |
//+------------------------------------------------------------------+
#property copyright "Last_Don"
#property link      "http://www.mql4.com/ru/users/Last_Don"

//---- input parameters ---------

extern int     stopLOSS=80;

extern int     dif  = 1480;  

extern double   LOTs  =0.1; 
 
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

string s[6]={"_____"," AO "," ADX "," MFI "," MA "," Ichimoku "};

//---- other parameters ---------

   static int  prevtime=0; int ticket=0;int  x=1;
   
     int Magic_BUY  =120;int Magic_SELL =220;
     
//+---------- expert initialization function -------------+

int init(){ if(Digits == 5) x=10;MathSrand(GetTickCount());return(0);}  // ---

//+-------------expert start function------------------------------------+
int start()  {      if (Time[0] == prevtime) return(0); 
                             prevtime = Time[0];
    if (!IsTradeAllowed()) {
     prevtime=Time[1]; Sleep(30000 + MathRand());  //--- ôîðìèðóåì áàð---
                           }
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int n=Qn(Rand_10(MathRand()));int period_=Qp(n);int m=Rand_10(MathRand()); 

 Trade( Magic_BUY,i_(n,period_,0),i_(n,period_,1),n,period_,m,stopLOSS);//--òîðãè ïî ëîíãàì
 
    n=Qn(Rand_10(MathRand()));  period_=Qp(n);  m=Rand_10(MathRand()); 
    
 Trade(Magic_SELL,i_(n,period_,1),i_(n,period_,0),n,period_,m,stopLOSS);//--òîðãè  ïî øîðòàì
 
    return(0); }  //-----------âûõîä èç ñòàðòîâîé ôóíêöèè------------
    
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

void  Trade(int mn,double a,double aa,int n_,int per_,int m_,int step){

    int total=OrdersTotal();

    for (int i=0; i<total; i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES);//---ïðîõîä ïî îðäåðàì--
    
    if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn) {  return(0); } 
                                    }
 //--------------------------------
 
  ticket = -1;  string dir="?";
  
   if (  a > aa  &&  Q(MathRand()) && OrdersTotal()==0 && IsTradeAllowed()) {  //---âõîä â ðûíîê ---
       
         if (mn<200)      {
         
     ticket= OrderSend(Symbol(), OP_BUY,lot(),Ask,5*x,Bid-x*step*Point,
     
                          Ask+(1.5+m_*0.1)*x*step*Point,DoubleToStr(mn,0),mn,0,Blue);
                          
                   dir="BUY";       }
                   
                    else {
                    
     ticket= OrderSend(Symbol(),OP_SELL,lot(),Bid,5*x,Ask+x*step*Point,
 
                      Bid-(1.5+m_*0.1)*x*step*Point,DoubleToStr(mn,0),mn,0, Red);
                        
                     dir="SELL";       }
                     
           RefreshRates();  //---îñâåæàåì êîòèðû 
                 
 if ( ticket > 0)  Print(s[0]+s[n_]+s[0]+ToStr(per_)+s[0]+DoubleToStr(1.5+m_*0.1,1)+s[0]+dir+s[0]); 
      
     if ( ticket < 0) { Sleep(30000);   prevtime = Time[1]; } 
                                           
                                           } //-- Exit ---
   return(0); } 
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
double lot() {  return(LOTs);    } 
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
string  ToStr( int num) { if (num==1440) return ("D1");   return("W");}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 int Rand_10(int l) {   
 if(l>3000  && l< 3500) return(1); if(l> 6000  && l<6500)  return(2); 
 if(l>9000  && l< 9500) return(3); if(l>12000  && l<12500) return(4); 
 if(l>15000 && l<15500) return(5); if(l>18000  && l<18500) return(6);
 if(l>21000 && l<21500) return(7); if(l>24000  && l<24500) return(8); 
 if(l>27000 && l<27500) return(9); if(l>30000  && l<30500) return(10);
              return (Rand_10(MathRand())); //---ðåêóðñèÿ âû÷èñëåíèé---
              
                }
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int Qn (int qx) { if(qx==1 || qx==6) return (1);if(qx==2 || qx==7) return (2);
  
 if(qx==3 || qx==8) return (3); if (qx==4 || qx==9) return (4); if (qx==5 || qx==10) return (5);}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
int Qp (int qy) { if (qy==5 || qy==2) return (1440 ); return (10080); }
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
   double  i_(int in, int ip, int is ) {  if (in==1) return (iAO(NULL,ip, is)); 
    
  if (in==2) if (is==0) { return (iADX(NULL,ip,14,PRICE_TYPICAL,MODE_PLUSDI,0)); } 
    
    else 
                          
                        { return (iADX(NULL,ip,14,PRICE_TYPICAL,MODE_MINUSDI,0)); }   
    
    if (in==3) return (iMFI(NULL,ip,14,is));   
    
    if (in==4) return (iMA(NULL,ip,8,3,MODE_SMA,PRICE_TYPICAL,is));
    
    if (in==5)  if (is==0)     {return (iIchimoku(NULL, ip, 9, 26, 52, MODE_TENKANSEN, 0)); }
     
                           else 
                             
                                {return (iIchimoku(NULL, ip, 9, 26, 52, MODE_KIJUNSEN, 0)); }  
    
    
    return (0);  }
    
 //$$$$$$$$$$$$$$$$$$$$$$$$$$$ -  ðàíäîìíûé ìåõàíèçì - $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 
 bool Q(int u) { 
   if(u> 3000  && u< 4500-dif) return (true);   if(u>6000  && u< 7500-dif) return (true);
   if(u> 9000  && u<10500-dif) return (true);  if(u>12000  && u<13500-dif) return (true); 
   if(u>15000  && u<16500-dif) return (true);  if(u>18000  && u<19500-dif) return (true); 
   if(u>21000  && u<22500-dif) return (true);  if(u>24000  && u<25500-dif) return (true); 
   if(u>27000  && u<28500-dif) return (true);  if(u>30000  && u<31500-dif) return (true);  
   
   return(false);  //------
   
   } 
   


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