Author: MNK
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Moving average indicatorOn Balance Volume indicatorMACD Histogram
0 Views
0 Downloads
0 Favorites
OBV_ZigZag
#property copyright "MNK"
int p=0;


int tic=0;
extern double lot=0.01;
double sl=80008;
double tp=80008;
int init()
  {
   return(0);
  }
int deinit()
  {
   return(0);
  }

int start()
  {
double a0; 
double a1; 
double a2; 
if(OrdersTotal()>0)
   {
a0=iMA(NULL,0,888,0,MODE_EMA,PRICE_CLOSE,0); 
a1=iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,0); 
a2=iMA(NULL,0,8,0,MODE_EMA,PRICE_CLOSE,1); 
if((a1<a0)&&(a2>a0))
  cl_order("SELL");
if((a1>a0)&&(a2<a0))
  cl_order("BUY");    
  }



  double a=0.0;
  int i,cf=0,ss=0;
//----
if(OrdersTotal()==0)
{
a0=iMA(NULL,0,888,0,MODE_EMA,PRICE_CLOSE,0); 

a=iCustom(NULL, 0,"ZigZag",12,5,3,1,1);
if ((a==iCustom(NULL, 0,"ZigZag",12,5,3,0,1))&&(a0>a)&&(a>0))
{
   i=2;
   
   while(iCustom(NULL, 0,"ZigZag",12,5,3,1,i)==0)
   {
   i++;
   }
   


if(iCustom(NULL, 0,"ZigZag",12,5,3,1,i)>iCustom(NULL, 0,"ZigZag",12,5,3,1,1))
   if(iOBV(NULL, 0, PRICE_CLOSE, i)<iOBV(NULL, 0, PRICE_CLOSE, 1))
      if(iMACD(NULL,0,8,88,8,PRICE_CLOSE,MODE_MAIN,i)<iMACD(NULL,0,8,88,8,PRICE_CLOSE,MODE_MAIN,1))
      
      {
      
      tic=OrderSend(Symbol(),OP_SELL,lot,Bid,10,Ask+sl*Point,Bid-tp*Point,"Graber SELL",888,0,Red);
         
         for(i=0;i<888;i++)
            {
            if(tic<0) 
               {
               Sleep(5000);
               RefreshRates();
               tic=OrderSend(Symbol(),OP_SELL,lot,Bid,10,Ask+sl*Point,Bid-tp*Point,"Graber SELL",888,0,Red);
               
               }
            }
      
      
      
      }

}


a=iCustom(NULL, 0,"ZigZag",12,5,3,2,1);
if((a==iCustom(NULL, 0,"ZigZag",12,5,3,0,1))&&(a0<a)&&(a>0))
{   
   i=2;
   
   while(iCustom(NULL, 0,"ZigZag",12,5,3,1,i)==0)
   {
   i++;
   }
   


if(iCustom(NULL, 0,"ZigZag",12,5,3,1,i)<iCustom(NULL, 0,"ZigZag",12,5,3,1,1))
   if(iOBV(NULL, 0, PRICE_CLOSE, i)>iOBV(NULL, 0, PRICE_CLOSE, 1))
     if(iMACD(NULL,0,8,88,8,PRICE_CLOSE,MODE_MAIN,i)>iMACD(NULL,0,8,88,8,PRICE_CLOSE,MODE_MAIN,1))
      
      {
            
          tic=OrderSend(Symbol(),OP_BUY,lot,Ask,10,Bid-sl*Point,Ask+tp*Point,"Graber2 BUY",888,0,Green);   
          for(i=0;i<888;i++)
            {
            if(tic<0) 
               {
               Sleep(5000);
               RefreshRates();
               tic=OrderSend(Symbol(),OP_BUY,lot,Ask,10,Bid-sl*Point,Ask+tp*Point,"Graber2 BUY",888,0,Green);   
               Print("Îðäåð òèêåò "+tic);
               }
            }   
      
      
      
      }

}




}





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



double cl_order(string ord)
   {
   
   if((OrdersTotal()>0))
      {
      
      
     if(OrderSelect(0,SELECT_BY_POS)==true)
      {
     // if((TimeCurrent()-OrderOpenTime())<24*60*60) return(1);
      
      if(OrderType()==OP_SELL)
               {
               if(ord=="SELL") return(1);
               OrderClose(OrderTicket(),OrderLots(),Ask,5,Blue);
               }
      
      if(OrderType()==OP_BUY)  
               {
               if(ord=="BUY") return(1);
               OrderClose(OrderTicket(),OrderLots(),Bid,5,Blue);
               }
            
      }

      
      }
   if((OrdersTotal()>0))
   {
   cl_order(ord);
   }   
   
   return(0.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 ---