Guys I really really need your help, I need to make a function to add another trade if the current trade is –ve 20 pips, so I made a function to count the pips, that give me the number of pips as “PipsOpenPL”
Then I made an if statement to compare between the loss of pips and the user input which is
Double EUR_DD=20.0 ; and place a buy order if the statement is true
This is the if statement “ if ((PipsOpenPL) < (-EUR_DD*Point) ); { ..... buy etc .... }
And this is my function :
//+------------------------------------------------------------------+
//| COUNT THE PIPS IN LOSS |
//+------------------------------------------------------------------+
double LossPips (int mgc, string curr )
//double LossPips (int mgc) // function will count the open pips & return LossPips
{
for(nCnt = 0; nCnt < OrdersTotal(); nCnt++)
{ curr = Symbol();
int PipsOpenPL=0;
OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == mgc)
{
if (OrderType()==OP_BUY)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderClosePrice()-OrderOpenPrice())/MarketInfo(Symbol(),MODE_POINT));
}
if (OrderType()==OP_SELL)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderOpenPrice()-OrderClosePrice())/MarketInfo(Symbol(),MODE_POINT));
}
}
}
return(PipsOpenPL);
}
//============================================
Still something is wrong and the function doesn’t work or it as it should, can someone tell me what’s the problem, where did I made the mistake
Then I made an if statement to compare between the loss of pips and the user input which is
Double EUR_DD=20.0 ; and place a buy order if the statement is true
This is the if statement “ if ((PipsOpenPL) < (-EUR_DD*Point) ); { ..... buy etc .... }
And this is my function :
//+------------------------------------------------------------------+
//| COUNT THE PIPS IN LOSS |
//+------------------------------------------------------------------+
double LossPips (int mgc, string curr )
//double LossPips (int mgc) // function will count the open pips & return LossPips
{
for(nCnt = 0; nCnt < OrdersTotal(); nCnt++)
{ curr = Symbol();
int PipsOpenPL=0;
OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == mgc)
{
if (OrderType()==OP_BUY)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderClosePrice()-OrderOpenPrice())/MarketInfo(Symbol(),MODE_POINT));
}
if (OrderType()==OP_SELL)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderOpenPrice()-OrderClosePrice())/MarketInfo(Symbol(),MODE_POINT));
}
}
}
return(PipsOpenPL);
}
//============================================
Still something is wrong and the function doesn’t work or it as it should, can someone tell me what’s the problem, where did I made the mistake
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
if (OrderType()==OP_BUY)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderClosePrice()-OrderOpenPrice())/MarketInfo(Symbol(),MODE_POINT));
}
if (OrderType()==OP_SELL)
{
PipsOpenPL=PipsOpenPL+MathRound((OrderOpenPrice()-OrderClosePrice())/MarketInfo(Symbol(),MODE_POINT));
Now my question will this retun a -ve number in case i have the position in loss ?