Finding VALID POINT

 
I've posted it in 7bit's "5 digits detection" and I found myself delving into another problem altogether.
What I'm after :
- How do I make a function of this simple trade operation. And to be able to be used on all types of symbols and/or brokers (pip or sub-pip)
- I know that if we go from pip broker to sub-pip broker a pip will 'miss' by nine per tenth what it supposed to be
- as Jjc pointed out 1 pip can have fixed value if the deposit currency match the base currency
- how do we use this knowledge so we can trade using simple input parameter in pips. On all symbols on all digit-type broker.

int start()
  {
   double validPoint = validPoint(Point);
   int SL = Ask - 25 * validPoint;
   int TP = Ask + 25 * validPoint;
   
   int ticket = OrderSend(Symbol(),OP_BUY,1,Ask,3,SL,TP,"My order",1234,0,Green);
   Print("ticket = ", ticket);

   return(0);
  }
  
double  validPoint(double p){

   int digitPoint = 0; int dP = 0; double vP = 0.0;
   double anchor_value; 
   
   for(double i=1.0; i>p; i/=10){
         digitPoint ++;
         if(i * MarketInfo(Symbol(),MODE_TICKVALUE) > anchor_value)
         {vP = i; dP = digitPoint; }
   }
   return(vP);
}
If anyone has already done this or has the answer please share or give me a hint. the solution will be for everyone's benefit. Many thanks in advance...
 

Personally, I don't see the whole "5 digits detection" debate as an issue at all; I am not of the school of thought that everything should be 'automatic' and don't see any problem with having the user declare the pip size via an extern. Actually, I prefer it, since I think it's the most reliable method.

Anyway, I agree with what has already been said a few times - that a 'Pip' is a convention, something we all agree on. It is not a mathematical property of the symbol. It is not a property of the MT4 server. Unless MQ invents some kind of MarketInfo() property u can read that tells u the intended number of digits for a 'Pip' (per symbol), then there is no foolproof way of doing it. I am sure there could be a way that would work >99% of the cases, but for me that's just not good enough. Hence I prefer the manual way.

 
gordon:

Personally, I don't see the whole "5 digits detection" debate as an issue at all; I am not of the school of thought that everything should be 'automatic' and don't see any problem with having the user declare the pip size via an extern. Actually, I prefer it, since I think it's the most reliable method.

Anyway, I agree with what has already been said a few times - that a 'Pip' is a convention, something we all agree on. It is not a mathematical property of the symbol. It is not a property of the MT4 server. Unless MQ invents some kind of MarketInfo() property u can read that tells u the intended number of digits for a 'Pip' (per symbol), then there is no foolproof way of doing it. I am sure there could be a way that would work >99% of the cases, but for me that's just not good enough. Hence I prefer the manual way.

gordon, many thanks for your reply...

to avoid discussions with me having different concept than yours - hopefully this will not lead to me chasing 'much ado about nothing' :)) - please allow me to describe some thoughts :

- I suppose I'm more concerned/viewed it as a risk management tools

- the pip/tick value is only significant as it serves as a tell-sign whether our parameters are on the right multiplication level (10, in this case)

- imagine you encountered a new 'XXXYYY' symbol and do not know how much (in your deposit currency) its pip worth. and with US$ 1000 worth of balance with 1:100 leverage,
you want to set a market order with an SL & TP 25 pips away.. min lot is 0.1 how do you know how much money you'll lose if your SL is hit? do you multiply your simple 25pip with the predefined Point times 10 or divided by 10? now imagine having other broker platform at subpip opened... and another symbol to check... do you use demo first than observe how much you lose/gain and then proceed with real trade... (imagine doing that with 150 plus symbols, manually)

- would it not be simpler to have for instance a lot size or an amount of money in mind, then let the function tell us if the simple 25 pips we want to set is within our range in mind or not....

thanks

 
gordon:

.... don't see any problem with having the user declare the pip size via an extern. Actually, I prefer it, since I think it's the most reliable method.

I've re-read your reply... I don't either, the thing is, that is what I'm trying to solve without the risk of sending an SL/TP 10 times away with an EA and got hit/doesn't got hit.
Via an extern you still would have to check Digits and adjust Point accordingly. why not let a function do that and curb your risk at the same time...
 
cameofx:
- imagine you encountered a new 'XXXYYY' symbol and do not know how much (in your deposit currency) its pip worth.

I don't see this situation as relevant to my experts. It might be relevant to people who write general experts that can be attached to just about any chart, but personally I don't think experts should be designed this way. There is nothing wrong with designing experts that should be used only under certain conditions and that might require some input from the user (vie externs). Hence, if u design experts like that, u would never encounter "a new 'XXXYYY' symbol and do not know how much (in your deposit currency) its pip worth". Anyway that's just IMHO.

 
gordon:

I don't see this situation as relevant to my experts. It might be relevant to people who write general experts that can be attached to just about any chart, but personally I don't think experts should be designed this way. There is nothing wrong with designing experts that should be used only under certain conditions and that might require some input from the user (vie externs). Hence, if u design experts like that, u would never encounter "a new 'XXXYYY' symbol and do not know how much (in your deposit currency) its pip worth". Anyway that's just IMHO.

Thank you for your views gordon, much appreciated.. (sorry for the delayed reply).

Reason: