for (int k=0; k<size; k++) { if (Sym[k] == OrderSymbol()) { Equity[k] += OrderProfit() + OrderCommission() + OrderSwap(); if (type == OP_BUY) Lots[k] += OrderLots(); if (type == OP_SELL) Lots[k] -= OrderLots(); found = true; break; } }
In this loop the Equity is added for BUY orders and substracted for SELL orders. Based on that, the breakeven is calculated in this caseelse { int dig = MarketInfo(Sym[i], MODE_DIGITS); double point = MarketInfo(Sym[i], MODE_POINT); double COP = Lots[i]*MarketInfo(Sym[i], MODE_TICKVALUE); double val = MarketInfo(Sym[i], MODE_BID) - point*Equity[i]/COP; level0 = DoubleToStr(val, dig); }and the corresponding Object is created hereif (DrawBreakeven==true){ ObjectCreate(prefix+"breakevenline",OBJ_HLINE,0,0,StrToDouble(level0));so you have to calculate the equity for BUY and SELL seperatly and Create another Object HLINE.btw: the code is awkward, no comments and what is that typecasting thingies for? I think its not from you? Its also based on very old mt5 version and is not compatible to actual builds. My Advice, throw it away, read some tutorials on indicators and do it on your own
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
Hi everyone. I'm not good at programming
I have code Break Even but it only show oneline with case all buy sell with every pair.
How to fix it bring two line , one break even for sell , one break for buy. (every pair)
From case when i close All Buy Sell Order (one line break even)
To case i only close only Sell Order, i only closs only Buy Order. (two Line break even , one for buy , one for sell)
if u understand pls let me know, thank dude.