onTakeProfit
I want to execute code every time a take profit is triggered, how can i do that ?
- OnTakeProfit & OnStopLoss
- How to code?
- OnTakeProfit & OnStopLoss instead of OnTradeTransaction()
Try something like this ... Not sure 100% about the code because not tested it ... but it must work in such way ...
void LastClosedTrade(){ int cnt, total; total = OrdersHistoryTotal(); for(cnt=0;cnt<total; cnt++){ OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY); if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderClosePrice() == OrderTakeProfit()){ ClosedOnTP = true; } } }
Good luck ...
O. Shaban
Osama Shaban:
Your code will not work on a real account. The close price is most of the time different from the take profit, even if the close was initiated by TP.
Try something like this ... Not sure 100% about the code because not tested it ... but it must work in such way ...
Good luck ...
O. Shaban