Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
Tral
//+------------------------------------------------------------------+
//| Trailing Stop "ðàçíîêàëèáåðíûé" |
//+------------------------------------------------------------------+
extern int StopLoss = 50; //
extern int Trailing = 50; //êîë-âî ïóíêòîâ äëÿ òðàëà
extern int SafeMoney = 20; //êîë-âî ïóíêòîâ äëÿ áåçóáûòêà
int init () { return(0); }
int deinit() { return(0); }
int start()
{
double SLoss;
for(int cnt=0; cnt<OrdersTotal(); cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
if(SafeMoney!=0 && Bid>OrderOpenPrice()+SafeMoney*Point && (OrderStopLoss()<=OrderOpenPrice() || OrderStopLoss()==0))
{ OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+Point,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
if(Trailing!=0)
{
SLoss=Bid-Trailing*Point;
if(SLoss>OrderOpenPrice() && SLoss>OrderStopLoss()+Point)
{ OrderModify(OrderTicket(),OrderOpenPrice(),SLoss,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
}
}
if(OrderType()==OP_SELL)
{
if(SafeMoney!=0 && Ask<OrderOpenPrice()-SafeMoney*Point && (OrderStopLoss()>=OrderOpenPrice() || OrderStopLoss()==0))
{ OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); return(0); }
if(Trailing!=0)
{
SLoss=Ask+Trailing*Point;
if(SLoss<OrderOpenPrice() && SLoss<OrderStopLoss()-Point)
{ OrderModify(OrderTicket(),OrderOpenPrice(),SLoss,OrderTakeProfit(),0,CLR_NONE); PlaySound("expert.wav"); 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
---