Please explain in more detail. Your explanation and code are insufficient for us the understand your issue and to provide help.
Use the "</>" icon or Alt+S, to add your code.
Please explain in more detail. Your explanation and code are insufficient for us the understand your issue and to provide help.
Use the "</>" icon or Alt+S, to add your code.
double TotalOpenProfit(int direction) { double result = 0; int total = OrdersTotal(); for(int i = 0; i < total; i++) { if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if(OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber) continue; if((direction < 0 && OrderType() == OP_BUY) || (direction > 0 && OrderType() == OP_SELL)) continue; result += OrderProfit(); } return(result); } // this is to reset profitmax to 0 if(TradesCount(OP_BUY) == 0 && TradesCount(OP_SELL) == 0) { profitMax = 0; } // this is to updating higher profitmax if(profitMax >= 0 && profitAll > profitMax ) { profitMax = profitAll; }
Please explain in more detail. Your explanation and code are insufficient for us the understand your issue and to provide help.
Use the "</>" icon or Alt+S, to add your code.
1 basically i wanted to update higher profit if price goes the right direction
by assigning profitall, total open profit, to profitmax using the condition, if profitmax is less than profitall
2 it updated higher profit alright but when profit reduced to be less than the last highest value it also assigned that value to profitmax
thus caused the profitmax value to reduce, which i don't understand why this happened.
3 i only open 1 position either long or short at a time
4 once there's no opened position i reset profitmax to 0
don't know why it's doing this?
- You posted a function and then a snippet of code. The snippet is without context. We don't know whether profitMax is static or global. Otherwise, you are not remembering anything.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem -
No need for the "profitMax >= 0 &&" as you set it to zero.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i'm trying to fix max profit value with the following code
but it kept changing according to new totalprofit or profitall, what's wrong with my code?
if ( (profitMax >= 0)
&& profitMax < profitAll )
{
profitMax = profitAll;
}
sorry can't find the src button in the menu here
beee