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_v4
//+------------------------------------------------------------------+
//|     Ñèòíèêîâ Âàëåðèé ßêîâëåâè÷          valerasva@mail.ru        |
//+------------------------------------------------------------------+

extern double Lot         = 0.01;
extern double TrSt        = 100;
extern double ÓðÑòîïîâ    = 50;
extern double Risk        = 0.1;
extern bool Çâóê          = true;
extern double MAGICMA     = 55555;
extern string Buy         = "Red";
extern string Sell        = "Blue";
extern string BuySell     = "Yellow";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
double line=0;
double line0=0;
double linek;
double Lots=(NormalizeDouble(AccountFreeMargin()*Risk/1000.0,2));
if(Lots<Lot) Lots=Lot;
double stop=MarketInfo(Symbol(),MODE_STOPLEVEL);
Comment("Ñòîïû=",stop);
//+-----------------------------------------------------------------  
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++)
  {
if(ObjectGet(ObjectName(k),OBJPROP_STYLE)!=DRAW_LINE) continue;
   {
linek=ObjectGetValueByShift(ObjectName(k), 0);
    {    
if(Bid>linek-ÓðÑòîïîâ*Point && Bid<linek+ÓðÑòîïîâ*Point) line0=linek;
if(Bid>linek-ÓðÑòîïîâ*2*Point && Bid<linek+ÓðÑòîïîâ*2*Point) line=linek;      
if(Bid>linek-ÓðÑòîïîâ*2*Point && Bid<linek+ÓðÑòîïîâ*2*Point) 
    {  
if(ObjectGet(ObjectName(k),OBJPROP_COLOR)==Red)bool Buy=true;
if(ObjectGet(ObjectName(k),OBJPROP_COLOR)==Blue)bool Sell=true;
if(ObjectGet(ObjectName(k),OBJPROP_COLOR)==Yellow)bool BuySell=true;
if(ObjectGet(ObjectName(k),OBJPROP_COLOR)!=Red &&
ObjectGet(ObjectName(k),OBJPROP_COLOR)!=Blue &&
ObjectGet(ObjectName(k),OBJPROP_COLOR)!=Yellow)return;    
    }
   }
  }
 }
//+-----------------------------------------------------------------    
if(BuyOp==false)
   {
if(Bid>line0 && line0!=0 && (Buy==true || BuySell==true))  
      {
OrderSend(Symbol(),OP_BUY,Lots,Ask,5,0,0,"",MAGICMA);
if(Çâóê) PlaySound("alert.wav");
      }              
if(Ask<line0 && line0!=0 && (Sell==true || BuySell==true))
      {     
OrderSend(Symbol(),OP_SELL,Lots,Bid,5,0,0,"",MAGICMA);
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_BUY)   
          {
          if(Ask<line0-ÓðÑòîïîâ/2*Point  && line0!=0)
            {
            OrderClose(OrderTicket(),OrderLots(),Bid,5); 
            }
            if(((OrderStopLoss()<(Bid-Point*TrSt) && (Bid-OrderOpenPrice())>Point*TrSt))||OrderStopLoss()==0)  
            {                 
            OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrSt,OrderTakeProfit(),0);
            }
          }
        if(OrderType()==OP_SELL) 
          {
          if(Bid>line0+ÓðÑòîïîâ/2*Point && line0!=0)
            {
            OrderClose(OrderTicket(),OrderLots(),Ask,5); 
            }
          if(((OrderStopLoss()>(Ask+Point*TrSt) && (OrderOpenPrice()-Ask)>Point*TrSt))||OrderStopLoss()==0)   
            {                 
            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 ---