Orders Execution
Miscellaneous
0
Views
0
Downloads
0
Favorites
close_orders_in_profits
ÿþ#property copyright " 5.00 USD Free No-Deposit Bonus"
#property link "https://agea.trading/?=51115"
#property strict
double harvester_pips ;
//+------------------------------------------------------------------+
//| to close some of the orders which has profits over certain pips
//| |
//+------------------------------------------------------------------+
int start()
{
for(int k=OrdersTotal()-1;k>=0;k--)
{
if(!OrderSelect(k,SELECT_BY_POS,MODE_TRADES))
continue;
if(OrderSymbol()!=Symbol())
continue;
if(OrderType()==OP_BUY && (((MarketInfo(Symbol(),MODE_BID) - OrderOpenPrice()) /Point/10))> harvester_pips )
{
bool orderclose_long = OrderClose(OrderTicket(),OrderLots(),Bid, 3);
if ( orderclose_long==true)
{
Alert("Collected USD:",OrderProfit()-OrderCommission(),",Pips:", (((MarketInfo(Symbol(),MODE_BID) - OrderOpenPrice()) /Point/10)) );
}
// Alert(OrderProfit()-OrderCommission());
// Alert(OrderTicket(),"---", (((MarketInfo(Symbol(),MODE_ASK) - OrderOpenPrice()) /Point/10)) );
}
if(OrderType()==OP_SELL && ((( OrderOpenPrice() - (MarketInfo(Symbol(),MODE_ASK) ))/Point/10))> harvester_pips )
{
int orderclose_short = OrderClose(OrderTicket(),OrderLots(),Ask, 3);
if (orderclose_short==true)
{
Alert("Collected USD:",OrderProfit()-OrderCommission(),",Pips", ((( OrderOpenPrice() - (MarketInfo(Symbol(),MODE_ASK) ))/Point/10)) );
}
}
}
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
---