shermilden5000: let's say 1st order has opened at 1.00005 and now it's on 1.00025, and second order has opened at 1.00015 and now at 1.00035, then I want a code to get the current total pips of both trades which is +40, how to do that?
-
Play videoPlease edit your post.
For large amounts of code, attach it.
- The first can't be on 1.00025 and the second on 1.00035. There is only one market price.
-
Compute Lots weighted average price OrderOpenPrice question . - MQL4 and MetaTrader 4 - MQL4 programming forum -
Compute what a pip is. www.mql5.com/en/forum/169828#comment_4075614 - Total pips is (market - LWAP) / PIP
whroeder1:
-
Please edit your post.
For large amounts of code, attach it.
- The first can't be on 1.00025 and the second on 1.00035. There is only one market price.
-
Compute Lots weighted average price OrderOpenPrice question . - MQL4 and MetaTrader 4 - MQL4 programming forum -
Compute what a pip is. www.mql5.com/en/forum/169828#comment_4075614 - Total pips is (market - LWAP) / PIP
1. Thank you for that "SRC" button
2. of course it can be, we're talking about two different trades ;) not the same one at the exact millisecond :P and market prices change with time ;)
3. Can you elaborate it a little bit?
4. Can you elaborate it a little bit?
5. Can you elaborate it a little bit?
Try following the links @whroeder1 gave.
If your orders are all the same lot size and/or you don't mind about the lot size...
Create a function to count up the pips of all the open orders:
double CountPips() { double pip_count = 0; double pnt2pip = _Digits%2==0 ? 1 : 10; for(int i=OrdersTotal()-1; i>=0; i--) // good habit to count down { if(!OrderSelect(i,SELECT_BY_POS)) continue; // select the order if(OrderSymbol() != _Symbol) continue; // optional check for same symbol if(OrderMagicNumber()!= magic_no) continue; // optional check for magic number int order_type = OrderType(); if(order_type > 1) continue; // 0 == OP_BUY and 1 == OP_SELL double pip = SymbolInfoDouble(OrderSymbol(),SYMBOL_POINT) * pnt2pip; if(order_type==OP_BUY) pip_count+=(OrderClosePrice()-OrderOpenPrice())/pip; else pip_count+=(OrderOpenPrice()-OrderClosePrice())/pip; } return(pip_count); }
Then run your check:
double pips = CountPips(); if(pips>=30) CloseAllOrders(); else if(pips<=-30) SendAlert();
All untested.
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
let's say 1st order has opened at 1.00005 and now it's on 1.00025, and second order has opened at 1.00015 and now at 1.00035, then I want a code to get the current total pips of both trades which is +40, how to do that?
I'm trying to close all open orders when total pips reaches let's say +30 pips. And alert me when it reaches -30 pips. All I have is the following code to close the orders.