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
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register