I have a few Buy orders and Sell orders
What I want do is :
- Exit all the trades " Basket" at 5 pips more than the breakeven price of the open trades " including the swap"
What I am trying to do in the first for loop is find the value of open trades + swap and convert it to pips, and this is the part where I am getting stuck
I have tried few ideas but I have reached a dead end, I know the problem is in the first for statement but I can't solve it, any help is highly appropriated
here is the code
In the last loop, if you want to close orders you have to do it with the market prices, ASK and BID. Try this:
//--- Close when the open trades are 5 pips more than the breakeven price if (count>1 && profits>MinPro ) { for(i = OrdersTotal()-1; i >=0; i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if (OrderSymbol() == Symbol()&& OrderMagicNumber()==MagicNumber ) { if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Plum); if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Plum); } } }
Thanks abstract_mind but the problem is not in the order close, its in calculating the swap along with the profit and convert that into pips
I have a special function to close orders
what i want to do is use " OrdLots " and "Equity" to find how many pips the open trades represents then add to that number 5 pips to close all the open trades
the problem is in the first loop and I am not able to find the solution for it
Thanks abstract_mind but the problem is not in the order close, its in calculating the swap along with the profit and convert that into pips
I have a special function to close orders
what i want to do is use " OrdLots " and "Equity" to find how many pips the open trades represents then add to that number 5 pips to close all the open trades
the problem is in the first loop and I am not able to find the solution for it
I assume your basket of trades has all kinds of currency pairs; calculating the $ and pips for them are different for majors (eurusd, gbpusd), crosses (eurjpy, gbpjpy) and for usdchf, usdjpy
- 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 have a few Buy orders and Sell orders
What I want do is :
- Exit all the trades " Basket" at 5 pips more than the breakeven price of the open trades " including the swap"
What I am trying to do in the first for loop is find the value of open trades + swap and convert it to pips, and this is the part where I am getting stuck
I have tried few ideas but I have reached a dead end, I know the problem is in the first for statement but I can't solve it, any help is highly appropriated
here is the code