Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
GEP_Dm
//+------------------------------------------------------------------+
//|Åñëè ÃÝÏ âûøå óêàçàííîãî çíà÷åíèÿ, òî îòêðûâàåì îðäåð     Gep.mq4 |
//|                               Copyright © 2011, Õëûñòîâ Âëàäèìèð |
//|                                                cmillion@narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, http://cmillion.narod.ru"
#property link      "cmillion@narod.ru"
//--------------------------------------------------------------------
extern int    GepDelta     = 6,        //Åñëè ÃÝÏ âûøå ýòîãî çíà÷åíèÿ, òî îòêðûâàåì îðäåð ïðîòèâîïîëîæíûéé ÃÝÏó
              SL           = 120,      //Ñòîïëîññ â ïóíêòàõ
              TP           = 90;       //Òåéêïðîôèò â ïóíêòàõ
extern double Lot          = 0.10;     //èñïîëüçóåòñÿ òîëüêî ïðè risk = 0
extern int    MaxOrders    = 10;       //Ìàêñèìàëüíîå êîë-âî îðäåðîâ îäíîãî íàïðàâëåíèÿ
//--------------------------------------------------------------------
int STOPLEVEL,magic=123321,tip,TimeBar;
string txt;
bool D;
//--------------------------------------------------------------------
int init()
{
   STOPLEVEL = MarketInfo(Symbol(),MODE_STOPLEVEL);
   if (SL < STOPLEVEL) SL = STOPLEVEL;
   if (TP < STOPLEVEL) TP = STOPLEVEL;
   if (IsDemo() || IsTesting()) D=0; else D=1;
   txt = StringConcatenate("Copyright © 2011 cmillion@narod.ru\nÓñòàíîâëåííûå ïàðàìåòðû "+"\n"+
      "GepDelta         " , GepDelta,         "\n",
      "MaxOrders   " , MaxOrders,      "\n",
      "SL               ", SL,             "\n",
      "TP               " , TP,             "\n",
      "Lot               ", DoubleToStr(Lot,2));
}
//--------------------------------------------------------------------
int start()
{
   int bay,sel;
   for (int i=0; i<OrdersTotal(); i++)
   {  if (OrderSelect(i, SELECT_BY_POS))
      {  
         if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic) continue;
         tip=OrderType();
         if (tip==0) bay++;
         if (tip==1) sel++;
      }   
   }
   Comment(txt,"\nÁàëàíñ ",DoubleToStr(AccountBalance(),2),"\nÝêâèòè ",DoubleToStr(AccountEquity(),2),"\nBuy ",bay,"\nSel ",sel);
   if (D) {Comment("Äåìî âåðñèÿ, îáðàòèòåñü cmillion@narod.ru ");return;}
   double TrPr,StLo;
   double close = NormalizeDouble(Close[1],Digits);
   double open  = NormalizeDouble(Open[0],Digits);
   if (bay<MaxOrders && TimeBar!=Time[0] && (close - open)/Point>=GepDelta)
   {
      if (TP!=0) TrPr = NormalizeDouble(Ask + TP * Point,Digits);                 
      if (SL!=0) StLo = NormalizeDouble(Bid - SL * Point,Digits);                 
      if (!OrderSend(Symbol(),OP_BUY,Lot,NormalizeDouble(Ask,Digits),3,StLo,TrPr,"BreakdownLevelCandleMA",magic,0,Blue))
         Print("Error BUY ",GetLastError(),"   ",Symbol(),"   Lot ",Lot,"   SL ",StLo,"   TP ",TrPr);
      else TimeBar=Time[0];
   }
   if (sel<MaxOrders && TimeBar!=Time[0] && (open - close)/Point>=GepDelta)
   {
      if (TP!=0) TrPr = NormalizeDouble(Bid - TP * Point,Digits);                 
      if (SL!=0) StLo = NormalizeDouble(Ask + SL * Point,Digits);   
      if (!OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),3,StLo,TrPr,"BreakdownLevelCandleMA",magic,0,Red ))
         Print("Error SELL ",GetLastError(),"   ",Symbol(),"   Lot ",Lot,"   SL ",StLo,"   TP ",TrPr);
      else TimeBar=Time[0];
   }
   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 ---