Loza_gdemo0

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
0 Views
0 Downloads
0 Favorites
Loza_gdemo0
  
extern int        Slippage          =  5;
extern int        Target            =  25 ;
extern int        Loss              =  25;
extern double     Lot               =  0.1;

#define STUPID 0x1
int begin=0,OP_;

int TS  = 100;// Äèñò. ïðåñëåäîâàíèÿ


//--------------------------------------------------------------
// çàêðûòèå ïîêóïîê
int ClOrder?(int MagicNumber){
   for(int i = 0; i <= OrdersTotal(); i++){
      if(OrderSelect(i, SELECT_BY_POS) == false) continue;
      return(1);
   }
return(0);
}
//-----------------------------------------------------
// ïîêóïêà


void OpenBuy()
    
   {  
   //int tickbuy1  =OrderSend(Symbol (), OP_BUY, Lot,  NormalizeDouble(Ask,Digits), Slippage, Ask-40*Point,0, NULL, STUPID, 0, Green);
   int tickbuy2  =OrderSend(Symbol (), OP_BUY, Lot,  NormalizeDouble(Ask,Digits), Slippage, Ask-30*Point,0, NULL, STUPID, 0, Green);  
   //int tickbuy3  =OrderSend(Symbol (), OP_BUY, Lot,  NormalizeDouble(Ask,Digits), Slippage, Ask-20*Point,0, NULL, STUPID, 0, Green);
   //int tickbuy4  =OrderSend(Symbol (), OP_BUY, Lot,  NormalizeDouble(Ask,Digits), Slippage, Ask-10*Point,0, NULL, STUPID, 0, Green);
   OP_=OP_BUY;
   }




//----------------------------------------------------
// ïðîäàæà
void OpenSell()
  
   {   
   //int ticksell1  =OrderSend(Symbol (), OP_SELL, Lot,  NormalizeDouble(Bid,Digits), Slippage, Bid+40*Point,0,NULL, STUPID, 0, Red);
   int ticksell2  =OrderSend(Symbol (), OP_SELL, Lot,  NormalizeDouble(Bid,Digits), Slippage, Bid+30*Point,0,NULL, STUPID, 0, Red);   
   //int ticksell3  =OrderSend(Symbol (), OP_SELL, Lot,  NormalizeDouble(Bid,Digits), Slippage, Bid+20*Point,0,NULL, STUPID, 0, Red);
   //int ticksell4  =OrderSend(Symbol (), OP_SELL, Lot,  NormalizeDouble(Bid,Digits), Slippage, Bid+10*Point,0,NULL, STUPID, 0, Red);
   OP_=OP_SELL;  
   }
   
//------------------------------------------------------------------------   
   

 int start(){
 if(begin==0)
 OpenSell();
 
         string Symb=Symbol();                      
         for(int i=1; i<=OrdersTotal(); i++)          
         {
         if (OrderSelect(i-1,SELECT_BY_POS)==true)   
         {                                           
         int Tip=OrderType();                       
         if(OrderSymbol()!=Symb||Tip>1)continue;      
         double SL=OrderStopLoss();                   
         
        
         
         
           //------------------------------------------------------  
           while(true)                            
           {
                
            //--------------------------------------------------- 
            bool Modify=false;                 
            switch(Tip)                        
              {
              case 0 :                       
              if (NormalizeDouble(SL,Digits) < NormalizeDouble(Bid-TS*Point,Digits))
              {
              SL=Bid-20*Point;           
              string Text="Buy ";      
              Modify=true;              
              }       
              break;      
                                     
              case 1 :                          
              if (NormalizeDouble(SL,Digits) > NormalizeDouble(Ask+TS*Point,Digits)|| NormalizeDouble(SL,Digits)==0)
              {      
              SL=Ask+20*Point;           
              Text="Sell ";         
              Modify=true;  
              }
              break;        
              }                          
              if (Modify==false)                  
              break;                               

                       
                                    
       
       
       
       //------------------------------------------------------------- 
   
            double Price  =OrderOpenPrice();     
            int    Ticket =OrderTicket();        

            Alert ("Ìîäèôèêàöèÿ ",Text,Ticket,". Æä¸ì îòâåò..");
            bool Ans1=OrderModify(Ticket,Price,SL,0,0);
          
          
       //-------------------------------------------------------------- 
            if (Ans1==true)                     
            {
            Alert ("Îðäåð ",Text,Ticket," ìîäèôèöèðîâàí:)");
            break;                              
            }      
       //--------------------------------------------------------------- 
            break;  
              
                                         
    
              
              
         }  // Êîíåö öèêëà ìîä.
         }  // Êîíåö àíàëèçà îðä.
         }  // Êîíåö ïåðåáîðà îðä.
  

 
 
 
 if(ClOrder?(STUPID)==0){
  if(OP_==0)
  { 
  OpenSell();

  
  
  } 
  else
  { 
  OpenBuy();
  
  
  
  }
  }
   begin=1;
   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 ---