Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Miscellaneous
It plays sound alerts
0 Views
0 Downloads
0 Favorites
TL
//+------------------------------------------------------------------+
//|     Ñèòíèêîâ Âàëåðèé ßêîâëåâè÷          valerasva@mail.ru        |
//+------------------------------------------------------------------+

extern double Lot         = 0.1;
extern double TrSt        = 300;
extern double Slippage    = 50;
extern double Risk        = 0.1;
extern bool Îòîáðàæåíèå   = true;
extern bool Çâóê          = false;
extern double MAGICMA     = 11;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
double line=0;
double line1=0;
double Lots=(NormalizeDouble(AccountFreeMargin()*Risk/1000.0,1));
if(Lots<Lot) Lots=Lot;
//+-----------------------------------------------------------------  
for(int i = 0; i <= OrdersTotal(); i++) 
  {                
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber() == MAGICMA) bool BuyOp=true;  
   } 
//+-----------------------------------------------------------------
int obj_total=ObjectsTotal();
for(int k=0;k<obj_total;k++)
  { 
string name=ObjectName(k); 
line1=ObjectGetValueByShift(name, 0);
    {
if(Bid>line1-Slippage*Point && Bid<line1+Slippage*Point) line=line1;      
    }
  } 
//+-----------------------------------------------------------------    
if(BuyOp==false)
   {
if(Bid>line && Bid<line+Slippage*Point)   
      {
if(Îòîáðàæåíèå==false) OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-TrSt*Point,0,"",MAGICMA);
if(Îòîáðàæåíèå==true) OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid-TrSt*Point,0,"",MAGICMA,0,Green);
if(Çâóê) PlaySound("alert.wav");
      }              
if(Ask<line && Ask>line-Slippage*Point)
      {     
if(Îòîáðàæåíèå==false) OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+TrSt*Point,0,"",MAGICMA);
if(Îòîáðàæåíèå==true) OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+TrSt*Point,0,"",MAGICMA,0,Red);
if(Çâóê) PlaySound("alert.wav");
      } 
   }    
//+----------------------------------------------------------------- 
for(int cnt=0;cnt<OrdersTotal();cnt++)
    {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      {
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
if(OrderType()<=OP_SELL && OrderType()==OP_BUY)   
          {
if(Ask<line && Ask>line-Slippage*Point)
            {
if(Îòîáðàæåíèå==false) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage); 
if(Îòîáðàæåíèå==true) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Violet); 
            }
if(OrderStopLoss()<(Bid-Point*TrSt) && (Bid-OrderOpenPrice())>Point*TrSt)  
            {                 
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrSt,OrderTakeProfit(),0);
            }
          }
else 
          {
if(Bid>line && Bid<line+Slippage*Point)
            {
if(Îòîáðàæåíèå==false) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage); 
if(Îòîáðàæåíèå==true)OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Violet);
            }
if(OrderStopLoss()>(Ask+Point*TrSt) && (OrderOpenPrice()-Ask)>Point*TrSt)  
            {                 
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrSt,OrderTakeProfit(),0);
            }
          }
        }
      }
    }
return(0);
  }
// the end.

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