Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
Modify_v3
#include <WinUser32.mqh>
int typ,timdrop;
double oop,raspp,rasps,WinPrice;
int z=0;
int start(){
PlaySound("tick.wav");
WinPrice=WindowPriceOnDropped();
if(WinPrice==0){bu();return;}
timdrop=WindowTimeOnDropped();
//+-----------------------------------------------------------------------------------------+
while(Time[z]>timdrop)z++;
if(timdrop<=Time[0]&&High[z]>WinPrice&&Low[z]<WinPrice){yastop();return;}
//+-----------------------------------------------------------------------------------------+
if(timdrop<=Time[0])
{
if(WinPrice>High[z]){typ=1;All();return;}
if(WinPrice<Low[z]){typ=0;All();return;}
}
bool a = false;
double s=9999999;
int Ticket;
for(int i=0;i<OrdersTotal();i++)
{//+-----------------------------------------------------------------------------------------+for
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()!= Symbol())continue;
a=true;
double OpPr = OrderOpenPrice();
double r = MathAbs(WinPrice-OpPr);
if(i==0){s=r;Ticket=OrderTicket();continue;}
if(r<s){s=r;Ticket=OrderTicket();}
}//+----------------------------------------------------------------------------------------+for
if(a==false){Alert("Íåò îðäåðîâ");return;}
OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES);
oop=OrderOpenPrice();
typ=OrderType();
graf();
string Tic=Ticket;
string st;
switch(typ)
{
case 0: st=" buy";break;
case 1: st=" sell";break;
case 2: st=" buy limit";break;
case 3: st=" sell limit";break;
case 4: st=" buy stop";break;
case 5: st=" sell stop";break;
}
int ret=MessageBox("Óêàæèòå ïàðàìåòðû","#"+Tic+st,MB_OKCANCEL);
if(ret==IDCANCEL){PlaySound("timeout.wav");ObjectDelete("%ds");ObjectDelete("%dp");ObjectDelete("%dc");return;}
double stop=NormalizeDouble(ObjectGet("%ds",OBJPROP_PRICE1),Digits);
double price=NormalizeDouble(ObjectGet("%dc",OBJPROP_PRICE1),Digits);
double profit=NormalizeDouble(ObjectGet("%dp",OBJPROP_PRICE1),Digits);
ObjectDelete("%ds");ObjectDelete("%dp");ObjectDelete("%dc");
double Lots = OrderLots();
if(typ<2)price=OrderOpenPrice();
if(stop==rasps)stop=OrderStopLoss();
if(profit==raspp)profit=OrderTakeProfit();
//+-----------------------------------------------------------------------------------------+
OrderModify(Ticket,price,stop,profit,0);
//+-----------------------------------------------------------------------------------------+
error();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int graf(){
raspp=OrderTakeProfit();
rasps=OrderStopLoss();
if(raspp==0){if(typ==0||typ==2||typ==4)raspp=NormalizeDouble(WindowPriceMax(),Digits);if(typ==1||typ==3||typ==5)raspp=NormalizeDouble(WindowPriceMin(),Digits);}
if(rasps==0){if(typ==1||typ==3||typ==5)rasps=NormalizeDouble(WindowPriceMax(),Digits);if(typ==0||typ==2||typ==4)rasps=NormalizeDouble(WindowPriceMin(),Digits);}
//+------------------------------------------------------------------+
ObjectCreate("%ds",OBJ_HLINE,0,0,rasps);
ObjectSet("%ds",OBJPROP_COLOR,Red);
ObjectSet("%ds",OBJPROP_STYLE,STYLE_SOLID);
//+------------------------------------------------------------------+
ObjectCreate("%dc",OBJ_HLINE,0,0,oop);
ObjectSet("%dc",OBJPROP_COLOR,Green);
ObjectSet("%dc",OBJPROP_STYLE,STYLE_SOLID);
//+------------------------------------------------------------------+
ObjectCreate("%dp",OBJ_HLINE,0,0,raspp);
ObjectSet("%dp",OBJPROP_COLOR,Gold);
ObjectSet("%dp",OBJPROP_STYLE,STYLE_SOLID);
WindowRedraw();
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 9: 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 136: Alert("Íåò öåíû");return;
case 137: Alert("Áðîêåð çàíÿò");return;
case 141: Alert("×àñòûå çàïðîñû");return;
case 4051: Alert("Íåäîïóñòèìîå çíà÷åíèå ïàðàìåòðà ôóíêöèè");return;
default : Alert("Îøèáêà ",error);return;
}
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int All(){
if(typ==0){color col=Blue;}else col=Red;
//+------------------------------------------------------------------+
ObjectCreate("%ds",OBJ_HLINE,0,0,WinPrice);
ObjectSet("%ds",OBJPROP_COLOR,col);
ObjectSet("%ds",OBJPROP_STYLE,STYLE_SOLID);
WindowRedraw();
//+------------------------------------------------------------------+
int ret=MessageBox("Óêàæèòå óðîâåíü ñòîï-ëîññ","Info",MB_OKCANCEL);
if(ret==IDCANCEL){PlaySound("timeout.wav");ObjectDelete("%ds");return;}
//+------------------------------------------------------------------+
double stop=NormalizeDouble(ObjectGet("%ds",OBJPROP_PRICE1),Digits);
ObjectDelete("%ds");
//+------------------------------------------------------------------+
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol())continue;
if(OrderType()!=typ)continue;
if(typ==0&&OrderStopLoss()<stop)OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0);
if(typ==1)if(OrderStopLoss()>stop||OrderStopLoss()==0)OrderModify(OrderTicket(),OrderOpenPrice(),stop,OrderTakeProfit(),0);
}
error();
//+------------------------------------------------------------------+
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int bu(){
OrderSelect(0,SELECT_BY_POS);
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);
error();
return;}
//ÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆÆ+
int yastop(){
bool o=false;
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderType()>1||Symbol()!=OrderSymbol())continue;
o=true;
double st=OrderStopLoss();
if(OrderType()==0)
{ OrderModify(OrderTicket(),OrderOpenPrice(),Low[z]-Point,OrderTakeProfit(),0);}
else
{
int spread=MarketInfo(Symbol(),MODE_SPREAD);
OrderModify(OrderTicket(),OrderOpenPrice(),High[z]+(spread+1)*Point,OrderTakeProfit(),0);
}
}
PlaySound("ok.wav");
if(o==false)Alert("Íåò ðûíî÷íûõ îðäåðîâ.");
return;}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---