Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
FXG_sStopLossOrders
//+------------------------------------------------------------------+
//| FXG_sStopLossOrders.mq4 |
//| FXGeneral,© 2010 |
//| http://www.fxgeneral.com/ |
//+------------------------------------------------------------------+
#property copyright "FXGeneral,© 2010"
#property link "http://www.fxgeneral.com/"
#property show_inputs
extern int lot_multiplier=1;
extern int orders=5;
extern int step=21;
extern int TakeProfit=21;
extern int StopLoss=21;
extern int slippage=3;
double fPointX()
{
double PointX = 0;
if(Digits==5 || Digits==3)
{
PointX = Point * 10;
}
if(Digits==4 || Digits==2)
{
PointX = Point;
}
return(PointX);
}
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
int cnt,limit,ticket,type;
double stop,lot;
limit=OrdersTotal();
for(cnt=0;cnt<limit;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY || OrderType()==OP_SELL)
{
stop=OrderStopLoss();
type=OrderType();
lot=OrderLots();
}
}
}
if(stop==0) Alert("Îòñóòñòâóåò StopLoss ó îðäåðà #"+OrderTicket()+"");
for(int z = 0;z<orders;z++)
{
if(type==0)
{
ticket=OrderSend(Symbol(),OP_SELLSTOP,lot*lot_multiplier,
NormalizeDouble(stop-z*step*fPointX(),Digits),slippage,
NormalizeDouble(stop-z*step*fPointX()+StopLoss*fPointX(),Digits),
NormalizeDouble(stop-z*step*fPointX()-TakeProfit*fPointX(),Digits),
"FXG_sStopLossOrders Order# "+z+"",0,0,CLR_NONE);
if(ticket<0)
{
Print(z," Îøèáêà îòêðûòèÿ îðäåðà #",GetLastError());
return(0);
}
}
if(type==1)
{
ticket=OrderSend(Symbol(),OP_BUYSTOP,lot*lot_multiplier,
NormalizeDouble(stop+z*step*fPointX(),Digits),slippage,
NormalizeDouble(stop+z*step*fPointX()-StopLoss*fPointX(),Digits),
NormalizeDouble(stop+z*step*fPointX()+TakeProfit*fPointX(),Digits),"FXG_sStopLossOrders Order# "+z+"",0,0,CLR_NONE);
if(ticket<0)
{
Print(z," Îøèáêà îòêðûòèÿ îðäåðà #",GetLastError());
return(0);
}
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
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
---