
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,
I want to get current profits on positions on the same pair.
#include<Trade\Trade.mqh>
CTrade trade;
void OnTick()
{
double Profit_1, Profit_2;
double Ask_EURGBP=NormalizeDouble(SymbolInfoDouble("EURGBP", SYMBOL_ASK), _Digits);
double Bid_EURGBP=NormalizeDouble(SymbolInfoDouble("EURGBP", SYMBOL_BID), _Digits);
if(PositionsTotal()<2)
{
trade.Buy(0.01,"EURGBP",Ask_EURGBP,NULL,NULL,NULL);
trade.Sell(0.01,"EURGBP",Bid_EURGBP,NULL,NULL,NULL);
}
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
if(PositionSelect("EURGBP")){Profit_1=PositionGetDouble(POSITION_PROFIT);}
if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
if(PositionSelect("EURGBP")){Profit_2=PositionGetDouble(POSITION_PROFIT);}
Comment(Profit_1+"\n"+Profit_2);
}
Profit_1 works but Profit_2 doesn't work and why ?