current profits on the same pair New comment gamma.albinos 2019.09.22 16:58 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 ? Can you please, help me? CTrade Ctrade - trade.sell New comment
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 ?