Curious about something...

 

Hello!

 I wrote a function to return the  takeprofit in price using the expected profit. The function worked well for symbols like EURUSD but failed in AUDJPY ( JPY pairs ) and Cryptocurrency. 

I believe this is because of the discrepancies in their _Digit values but even after accounting for it, I still don't know why it is not working exactly.

Most importantly I need to be able to return the value in $ per point of a symbol. 

I have attached the code below and if you can help with the problem highlighted above, please assist. 

Thank you!

double ret_tp_in_dollars(string order_type, double entry, double lotsize, string symb)
  {
   double i_tp = 0;
   double ret_reward  = 200; //Hoping to gain 200$ 
   double pui = ret_reward / lotsize;  //How can I correctly calculate the pips from the expected profit for all symbols?
   if(reward > 0)
     {
      if(order_type == "buy")
        {
         i_tp = entry + pui * SymbolInfoDouble(symb, SYMBOL_POINT) ;
        }
      if(order_type == "sell")
        {
         i_tp = entry - pui  * SymbolInfoDouble(symb, SYMBOL_POINT) ;
        }
     }
   return i_tp;
  }
 
Chioma Obunadike:
screpancies in their _Digit values but eve

1. Find correct digit for symbol

2. normalize using correct digit

 
Arpit T #:

1. Find correct digit for symbol

2. normalize using correct digit

doesn't work

 
Arpit T #:

1. Find correct digit for symbol

2. normalize using correct digit

this problem has nothing to do with the symbol _digit

 
Chioma Obunadike #:

this problem has nothing to do with the symbol _digit

for me it works on cryptocurrency chart tested on $SOL

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart() {
//---
Print(ret_tp_in_dollars("buy", 201, 0.585, _Symbol));
}
//+------------------------------------------------------------------+
double ret_tp_in_dollars(string order_type, double entry, double lotsize, string symb)
  {
   double i_tp = 0;
   double ret_reward  = 200; //Hoping to gain 200$ 
   double pui = ret_reward / lotsize;  //How can I correctly calculate the pips from the expected profit for all symbols?
   if(reward > 0)
     {
      if(order_type == "buy")
        {
         i_tp = entry + pui * SymbolInfoDouble(symb, SYMBOL_POINT) ;
        }
      if(order_type == "sell")
        {
         i_tp = entry - pui  * SymbolInfoDouble(symb, SYMBOL_POINT) ;
        }
     }
   return NormalizeDouble(i_tp,_Digits);
 

Hello mate. Thanks for the feedback. I tried but it still gives out wrong pip calculation to risk the amount ($200) in the symbol.

so instead I am getting the error


 
Chioma Obunadike #:

Hello mate. Thanks for the feedback. I tried but it still gives out wrong pip calculation to risk the amount ($200) in the symbol.

so instead I am getting the error


since i posted you screenshot as its working, i suspect there is problem could be in other part of your code which you have not posted here, another thing you must check 

SYMBOL_POINT

to make sure its correct. You can check it by clicking $ icon to open symbol information

 
Arpit T #:

since i posted you screenshot as its working, i suspect there is problem could be in other part of your code which you have not posted here, another thing you must check 

to make sure its correct. You can check it by clicking $ icon to open symbol information

Okay thanks! But I’m quite sure that’s not the cause of the problem. 

Do you know how I can return the $ value per pip?
 
For EURUSD, it is $1 
Reason: