Orders Execution
0
Views
0
Downloads
0
Favorites
7_stop_orders
#property copyright "Copyright © 2015, Õëûñòîâ Âëàäèìèð"
#property link "cmillion@narod.ru"
#property show_inputs
#property version "1.00"
#property strict
//--------------------------------------------------------------------
extern int stoploss_1 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_1 = 10; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_1 = 0.1; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_2 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_2 = 20; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_2 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_3 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_3 = 30; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_3 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_4 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_4 = 40; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_4 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_5 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_5 = 50; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_5 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_6 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_6 = 60; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_6 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int stoploss_7 = 100, //óðîâåíü âûñòàâëåíèÿ SL, åñëè 0, òî SL íå âûñòàâëÿåòñÿ
takeprofit_7 = 70; //óðîâåíü âûñòàâëåíèÿ TP, åñëè 0, òî TP íå âûñòàâëÿåòñÿ
extern double Lot_7 = 0.2; //îáúåì îðäåðà, åñëè 0, òî íå âûñòàâëÿåòñÿ
extern int Delta = 0; // ñìåùåíèå îðäåðîâ îòíîñèòåëüíî äðóã äðóãà
extern int slippage = 3, //Ìàêñèìàëüíî äîïóñòèìîå îòêëîíåíèå öåíû äëÿ ðûíî÷íûõ îðäåðîâ
Magic = 0; //óíèêàëüíûé íîìåð îðäåðà
//--------------------------------------------------------------------
void OnStart()
{
double SL,TP;
double Price = NormalizeDouble(WindowPriceOnDropped(),Digits);
if (Price>Ask)
{
if (takeprofit_1!=0) TP = NormalizeDouble(Price + takeprofit_1*Point,Digits); else TP=0;
if ( stoploss_1!=0) SL = NormalizeDouble(Price - stoploss_1*Point,Digits); else SL=0;
if (Lot_1>0) OPENORDER (OP_BUYSTOP,Price,Lot_1,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_2!=0) TP = NormalizeDouble(Price + takeprofit_2*Point,Digits); else TP=0;
if ( stoploss_2!=0) SL = NormalizeDouble(Price - stoploss_2*Point,Digits); else SL=0;
if (Lot_2>0) OPENORDER (OP_BUYSTOP,Price,Lot_2,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_3!=0) TP = NormalizeDouble(Price + takeprofit_3*Point,Digits); else TP=0;
if ( stoploss_3!=0) SL = NormalizeDouble(Price - stoploss_3*Point,Digits); else SL=0;
if (Lot_3>0) OPENORDER (OP_BUYSTOP,Price,Lot_3,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_4!=0) TP = NormalizeDouble(Price + takeprofit_4*Point,Digits); else TP=0;
if ( stoploss_4!=0) SL = NormalizeDouble(Price - stoploss_4*Point,Digits); else SL=0;
if (Lot_4>0) OPENORDER (OP_BUYSTOP,Price,Lot_4,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_5!=0) TP = NormalizeDouble(Price + takeprofit_5*Point,Digits); else TP=0;
if ( stoploss_5!=0) SL = NormalizeDouble(Price - stoploss_5*Point,Digits); else SL=0;
if (Lot_5>0) OPENORDER (OP_BUYSTOP,Price,Lot_5,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_6!=0) TP = NormalizeDouble(Price + takeprofit_6*Point,Digits); else TP=0;
if ( stoploss_6!=0) SL = NormalizeDouble(Price - stoploss_6*Point,Digits); else SL=0;
if (Lot_6>0) OPENORDER (OP_BUYSTOP,Price,Lot_6,SL,TP);Price = NormalizeDouble(Price+Delta*Point,Digits);
if (takeprofit_7!=0) TP = NormalizeDouble(Price + takeprofit_7*Point,Digits); else TP=0;
if ( stoploss_7!=0) SL = NormalizeDouble(Price - stoploss_7*Point,Digits); else SL=0;
if (Lot_7>0) OPENORDER (OP_BUYSTOP,Price,Lot_7,SL,TP);
}
if (Price<Bid)
{
if (takeprofit_1!=0) TP = NormalizeDouble(Price - takeprofit_1*Point,Digits); else TP=0;
if ( stoploss_1!=0) SL = NormalizeDouble(Price + stoploss_1*Point,Digits); else SL=0;
if (Lot_1>0) OPENORDER (OP_SELLSTOP,Price,Lot_1,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_2!=0) TP = NormalizeDouble(Price - takeprofit_2*Point,Digits); else TP=0;
if ( stoploss_2!=0) SL = NormalizeDouble(Price + stoploss_2*Point,Digits); else SL=0;
if (Lot_2>0) OPENORDER (OP_SELLSTOP,Price,Lot_2,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_3!=0) TP = NormalizeDouble(Price - takeprofit_3*Point,Digits); else TP=0;
if ( stoploss_3!=0) SL = NormalizeDouble(Price + stoploss_3*Point,Digits); else SL=0;
if (Lot_3>0) OPENORDER (OP_SELLSTOP,Price,Lot_3,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_4!=0) TP = NormalizeDouble(Price - takeprofit_4*Point,Digits); else TP=0;
if ( stoploss_4!=0) SL = NormalizeDouble(Price + stoploss_4*Point,Digits); else SL=0;
if (Lot_4>0) OPENORDER (OP_SELLSTOP,Price,Lot_4,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_5!=0) TP = NormalizeDouble(Price - takeprofit_5*Point,Digits); else TP=0;
if ( stoploss_5!=0) SL = NormalizeDouble(Price + stoploss_5*Point,Digits); else SL=0;
if (Lot_5>0) OPENORDER (OP_SELLSTOP,Price,Lot_5,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_6!=0) TP = NormalizeDouble(Price - takeprofit_6*Point,Digits); else TP=0;
if ( stoploss_6!=0) SL = NormalizeDouble(Price + stoploss_6*Point,Digits); else SL=0;
if (Lot_6>0) OPENORDER (OP_SELLSTOP,Price,Lot_6,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
if (takeprofit_7!=0) TP = NormalizeDouble(Price - takeprofit_7*Point,Digits); else TP=0;
if ( stoploss_7!=0) SL = NormalizeDouble(Price + stoploss_7*Point,Digits); else SL=0;
if (Lot_7>0) OPENORDER (OP_SELLSTOP,Price,Lot_7,SL,TP);Price = NormalizeDouble(Price-Delta*Point,Digits);
}
}
//--------------------------------------------------------------------
void OPENORDER(int ord, double Price, double Lot, double SL, double TP)
{
int error,err=0;
while (!IsStopped())
{
RefreshRates();
error=OrderSend(Symbol(),ord, Lot, Price,slippage,SL,TP,NULL,Magic,0,clrNONE);
if (error==-1)
{
err++;Sleep(1000);
}
if (error || err >10) return;
}
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
---