Orders Execution
It automatically opens orders when conditions are reached
Miscellaneous
It plays sound alertsIt opens Message Boxes to the userIt issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Send
#property show_inputs
#include <WinUser32.mqh>
extern string COMMENT = "";
extern double LOT = 0.0;
extern int FILTER = 1;
extern double RISK = 1.50;
extern bool MoneyRisk = false;
//+------------------------------------------------------------------------+
int mod=0;
int type;
double STOP,lot,price,step,minlot,tickvalue,pips;
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int start(){
 PlaySound("tick.wav");
int timdrop=WindowTimeOnDropped();
if(timdrop==0)mod=1;
if(timdrop>Time[0])mod=2;
if(mod==2)graf1();else graf();
//+------------------------------------------------------------------------+
string ty="Óêàæèòå ñòîï";
if(mod==2)ty="Óêàæèòå öåíó è ñòîï";
int ret=MessageBox(ty,"Info",MB_OKCANCEL);
if(ret==IDCANCEL){PlaySound("timeout.wav");ObjectDelete("%df");ObjectDelete("%ds");return;}
double stop=ObjectGet("%df",OBJPROP_PRICE1);
double PRICE=ObjectGet("%ds",OBJPROP_PRICE1);
ObjectDelete("%df");ObjectDelete("%ds");
STOP=NormalizeDouble(stop,Digits);
price=NormalizeDouble(PRICE,Digits);
//+------------------------------------------------------------------------+
if(mod==1&&STOP>Bid){type=1;price=NormalizeDouble(Bid,Digits);}
if(mod==1&&STOP<Bid){type=0;price=NormalizeDouble(Ask,Digits);}
//+------------------------------------------------------------------------+
if(mod==2&&STOP>price)type=3;if(mod==2&&STOP<price)type=2;
//+------------------------------------------------------------------------+
if(mod==0)
{
int spread=MarketInfo(Symbol(),MODE_SPREAD);
int i=0;while(Time[i]!=timdrop)i++;
double pr=(High[i]-Low[i])/2+Low[i];
if(STOP>pr){type=5;price=NormalizeDouble(Low[i]-Point*FILTER,Digits);}
else {type=4;price=NormalizeDouble(High[i]+Point*(FILTER+spread),Digits);}
}
//---------------------------------------------------------------------------------------+
pips=MathAbs(price-STOP)/Point;
tickvalue=MarketInfo(Symbol(),MODE_TICKVALUE);
if(Digits==5||Digits==3){pips=pips/10;tickvalue=tickvalue*10;}
//---------------------------------------------------------------------------------------+
if(LOT>0)
{
double risk=tickvalue*LOT*pips/(AccountBalance()/100);
string f=DoubleToStr(risk,2);
Comment("Ðèñê   "+f+"%");
lot=LOT;
send();return;
}
//---------------------------------------------------------------------------------------+
step=MarketInfo(Symbol(),MODE_LOTSTEP);
minlot=MarketInfo(Symbol(),MODE_MINLOT);
//---------------------------------------------------------------------------------------+
if(MoneyRisk==true){den();return;}
double sum=AccountBalance()/100*RISK;
double sp=sum/pips;
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");
lot=minlot;
send();return;
}
else
{
lot=NormalizeDouble(Lot,2);
if(step==0.1)lot=NormalizeDouble(Lot,1);
if(lot>Lot)lot=lot-step;
if(lot<minlot)lot=minlot;
send();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: rekvot();return;
   case 141: Alert("×àñòûå çàïðîñû");return;
   default : Alert("Îøèáêà ",error);return;
  }
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int graf(){
ObjectCreate("%df",OBJ_HLINE,0,0,Bid);
ObjectSet("%df",OBJPROP_COLOR,Blue);
ObjectSet("%df",OBJPROP_STYLE,STYLE_DASHDOT);
WindowRedraw();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int graf1(){
ObjectCreate("%ds",OBJ_HLINE,0,0,High[0]);
ObjectSet("%ds",OBJPROP_COLOR,Green);
ObjectSet("%ds",OBJPROP_STYLE,STYLE_SOLID);
graf();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
void rekvot(){ 
PlaySound("alert.wav");
int ret=MessageBox("Íîâûå öåíû.\n\n                       ÏÎÂÒÎÐÈÒÜ?","Info",MB_YESNO);
   if(ret==IDNO){PlaySound("timeout.wav");return;}
   PlaySound("tick.wav");send();
//---------------------------------------------------------------------------------------+
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int send(){
if(mod==1){RefreshRates();if(type==0)price=Ask;if(type==1)price=Bid;}
OrderSend(Symbol(),type,lot,price,0,STOP,0,COMMENT);error();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int den(){
double q=RISK/pips/tickvalue;
lot=NormalizeDouble(q,2);
 if(step==0.1){lot=NormalizeDouble(q,1);}
 if(lot>q)lot=lot-step;
   if(lot<minlot)
   {
   string f=DoubleToStr(pips*minlot*tickvalue,2);
   string ty="Ðèñê "+f+" ó.å. ñ ìèíèìàëüíûì ëîòîì\n\n                       ÏÐÎÄÎËÆÈÒÜ?";
   int ret=MessageBox(ty,"Info",MB_OKCANCEL);
   if(ret==IDCANCEL){PlaySound("timeout.wav");return;}
   lot=minlot;
   }
   send();
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 ---