Orders Execution
It automatically opens orders when conditions are reached
Miscellaneous
It plays sound alertsIt issuies visual alerts to the screenIt opens Message Boxes to the user
0 Views
0 Downloads
0 Favorites
BuyStop
#property show_inputs
#include <WinUser32.mqh>
extern string COMMENT = "";
extern double LOT = 0.0;
extern int FILTER = 1;
extern double RISK = 1.50;
//+------------------------------------------------------------------------+
double STOP;
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int start(){
 PlaySound("tick.wav");
int timdrop=WindowTimeOnDropped();
if(timdrop==0){Alert("Íóæíî áðîñèòü íà ñâå÷ó");return;}
graf();
//+------------------------------------------------------------------------+ 
int ret=MessageBox("Óêàæèòå ñòîï è íàæìèòå  ÎÊ","BUY STOP",MB_OKCANCEL);
if(ret==IDCANCEL){PlaySound("timeout.wav");ObjectDelete("%df");return;}
double stop=ObjectGet("%df",OBJPROP_PRICE1);
ObjectDelete("%df");
if(stop==Low[0])STOP=0;else STOP=NormalizeDouble(stop,Digits); 
if(STOP==0&&LOT==0){Alert("Íå óêàçàí ñòîï");return;}
if(STOP>stop)STOP=STOP-1*Point;
//+------------------------------------------------------------------------+
int spread=MarketInfo(Symbol(),MODE_SPREAD);
int i=0;
while(Time[i]!=timdrop)i++;
double price=NormalizeDouble(High[i]+Point*(FILTER+spread),Digits);
if(STOP>price){Alert("Ñòîï äîëæåí áûòü íèæå öåíû îòêðûòèÿ.");return;}
int pips=(price-STOP)/Point;
double tickvalue=MarketInfo(Symbol(),MODE_TICKVALUE);
if(Digits==5||Digits==3){pips=pips/10;tickvalue=tickvalue*10;}
//---------------------------------------------------------------------------------------+
if(LOT>0&&STOP>0)
{
double risk=tickvalue*LOT*pips/(AccountBalance()/100);
string f=DoubleToStr(risk,2);
ret=MessageBox("Ðèñê   "+f+"%","BUY STOP",MB_OKCANCEL);
   if(ret==IDCANCEL){PlaySound("timeout.wav");return;}
   PlaySound("tick.wav");
   OrderSend(Symbol(),OP_BUYSTOP,LOT,price,0,STOP,0,COMMENT);error();return;
}
//---------------------------------------------------------------------------------------+
if(LOT>0){OrderSend(Symbol(),OP_BUYSTOP,LOT,price,0,0,0,COMMENT);error();return;}
//---------------------------------------------------------------------------------------+
double sum=AccountBalance()/100*RISK;
double sp=sum/pips;
double minlot=MarketInfo(Symbol(),MODE_MINLOT);
double Lot=sp/tickvalue;
if(Lot<minlot)
{
risk=tickvalue*minlot*pips/(AccountBalance()/100);
if(risk<0){Alert("Íåïðàâèëüíûé ñòîï");return;}
f=DoubleToStr(risk,2);
ret=MessageBox("Ðèñê   "+f+"%   ñ ìèíèìàëüíûì ëîòîì.\n\n                       ÏÐÎÄÎËÆÈÒÜ?","ÂÎÏÐÎÑ",MB_YESNO);
if(ret==IDNO){PlaySound("timeout.wav");return;}
PlaySound("tick.wav");
OrderSend(Symbol(),OP_BUYSTOP,minlot,price,0,STOP,0,COMMENT);
error();return;
}
else
{
double step=MarketInfo(Symbol(),MODE_LOTSTEP);
double lot=NormalizeDouble(Lot,2);
if(step==0.1)lot=NormalizeDouble(Lot,1);
if(lot>Lot)lot=lot-step;
if(lot<minlot)lot=minlot;
OrderSend(Symbol(),OP_BUYSTOP,lot,price,0,STOP,0,COMMENT);
error();return;
}
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int error(){
int error=GetLastError();
 switch(error)
  {
   case 0: PlaySound("ok.wav");return;
   case 1: Alert("Íåò îøèáêè, íî ðåçóëüòàò íåèçâåñòåí");return;
   case 2: Alert("Îáùàÿ îøèáêà");return;
   case 3: Alert("Íåïðàâèëüíûå ïàðàìåòðû");return;
   case 4: Alert("Òîðãîâûé ñåðâåð çàíÿò");return;
   case 6: Alert("Íåò ñâÿçè");return;
   case 8: Alert("Ñëèøêîì ÷àñòûå çàïðîñû");return;
   case 128: Alert("Èñòåê ñðîê îæèäàíèÿ ñîâåðøåíèÿ ñäåëêè");return;
   case 129: Alert("Íåïðàâèëüíàÿ öåíà");return;
   case 130: Alert("Íåïðàâèëüíûå ñòîïû");return;
   case 131: Alert("Íåïðàâèëüíûé îáúåì");return;
   case 132: Alert("Ðûíîê çàêðûò");return;
   case 133: Alert("Òîðãîâëÿ çàïðåùåíà");return;
   case 134: Alert("Íåäîñòàòî÷íî äåíåã äëÿ ñîâåðøåíèÿ îïåðàöèè");return;
   case 136: Alert("Íåò öåíû");return;
   case 137: Alert("Áðîêåð çàíÿò");return;
   case 138: Alert("Íîâûå öåíû");return;
   case 141: Alert("×àñòûå çàïðîñû");return;
   default : Alert("Îøèáêà ",error);return;
  }
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int graf(){
ObjectCreate("%df",OBJ_HLINE,0,0,Low[0]);
ObjectSet("%df",OBJPROP_COLOR,Blue);
ObjectSet("%df",OBJPROP_STYLE,STYLE_DASHDOT);
WindowRedraw();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+

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