mmm33: hello every one I failed to write code that enables me to close all opening orders and pending after achieving a specific profit on a specific symbol and need to make that profit as a variable
Breakout Strategy with Prop Firm Helper Functions
Anh Quan Duong, 2024.05.11 03:45
This is an update of the "Simple Yet Effective Breakout Strategy". In this code, I have added some helper functions for prop firm challenges.this is how I think about it
void OnTick() { if(profitTargetCheck(targetInput){ DeleteOrders(); } } bool profitTargetCheck(double profitTarget){ for (int i = PositionsTotal() - 1; i >= 0; i--){ ulong posTicket = PositionGetTicket(i); double posProfit = PositionGetDouble(POSITION_PROFIT); if(posTicket > 0 && posProfit >= profitTarget){ trade.PositionClose(posTicket); return (posProfit >= profitTarget); // returning true } } return false; } void DeleteOrders(){ for(int i = 0; i < OrdersTotal(); i++){ ulong order = OrderGetTicket(i); if(order > 0){ trade.OrderDelete(order); } } }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
hello every one
I failed to write code that enables me to close all opening orders and pending after achieving a specific profit on a specific symbol and need to make that profit as a variable