5 digits detection - page 5

 
jjc:
 ...If you are building a system for other people to use, not just for yourself, then the ability to enter values in pips is a major ease-of-use consideration. The average punter knows what they mean by 50 pips, but has to think quite a lot, and double-check, whether they mean a value of 0.005 rather than 0.0005 or 0.05 or whatever....

Yeah, that's what I said "The definition would seem important for a developer who want to program a commercial standard program and want the user to have the flexibility of imputing exactly how much dollars whey want to risk". I beg to differ about the average punter knowing what they mean by 50 pips. IMO people like to think in Dollars or standard units of Their base currency. I would list my personal experience of how I've gone back and forth on the definition of a pip/point but that could get lengthy.

 

If you're not a SUPER programmer with YEARS of Forex experience under your belt, there's no point in trying to code a universal applicable Commercial program for end users. When someone purchases a EA, they expect above all else that it's going to be Profitable. Then secondly, they expect the program to be Flexible beyond belief. Like command to close all orders b4 weekends and Let me specify how much money I wanna risk etc. As we all know it hard enough to program any Profitable EA without making it static to one Time-frame or Currency etc.

 

But here you are trying to program an Commercial EA for Average Joe's who heard about 2% risk and "don't trade over weekends". And want to specify exactly 20$ loss on GBP/JPY while their base currency is in USD. The system was designed to uses a percentage of ATR whatever pip/points or dollars that may be. Now the entire system is Broken as it will not meet end user expectation #1 profitable. If someone is however making a tool for end users to play with, thats a different story.

 

IMO, If me/myself/personally was gonna make a system I wanted my Auntie or Lil Brother to trade. I'd make it as un-flexable as possible as the only thing they may specify would be the Risk% and any other perimeter the program is not designed to work with would be rejected i.e you specify the wrong time frame or currency. True as it may be, that most commercial systems out there let users specify in Pips. The programmer cannot be held responsible if the end user makes mistakes like "oh I only wanted $100 risk but ended up with $1000". He's entered 100 pip stops but leveraged at 1000:1. Unless you're gonna Alert every twist turn and warning within your programming, it's hopeless.

 
andydcoles:

The only thing that MQL4 uses Pips for is in coding Spread value in Order requests. Everything else is specified in terms of rate. One alternative to consider is to use currency rate differences as Input Parameters for T/P, S/L etc. For example, specify 0.0050 for a 50 Pip S/L. This works regardless of Digits, and only needs scaling by 100 when detecting "JPY" in Symbol() as the quote currency. This is viable for all the 21 major pairs (all USD, EUR, GBP, JPY, CHF, CAD, AUD combinations) and likely for minor pairs too (which few trade due to higher spreads). If you are really worried about "bullet proofing", you could supply a currency string and multiplier as Input Parameters (like JPY and 100). This can be extended for exotics too with different brokers.

I really think this is largely a mute point with most MQL4 coders; when they successfully implement and debug a profitable trading algorithm, they will use it on their own Live account. Few will want to sell it or give it away because the market will likely adjust to counteract the algorithm.

Thanks for your reply Andy. But I have the functions solved now. Looking back on my last posts I know I was kinda obsessed bout the dam thing at that time :). I guess I was looking more for the underlying calculation of Point, TickSize, etc rather than 'bullet proofing' my code. 7bit started the thread looking for a way to detect 5 digits price programmatically. And consequently it grew to find/explore the definitions of MarketInfo-s' predefined variables. Again thanks for your input.
~cameo

 

If you are building a system for other people to use, not just for yourself, then the ability to enter values in pips is a major ease-of-use consideration. The average punter knows what they mean by 50 pips, but has to think quite a lot, and double-check, whether they mean a value of 0.005 rather than 0.0005 or 0.05 or whatever. The ability to enter parameters in pips matches how most end-users think in the forex world, and reduces errors. It also offers the prospect of being able to use the same parameter values on 2/3 and 4/5 digit symbols. I don't have much exposure to the mass-market commercial EAs, but I've never seen one where such parameters were entered as a price differential rather than a pip value.

@Jjc : I'm glad someone's on the same page with me on this :). I'd go with ease-of-use & reducing errors any time of day :)

This. Personally I don't work in pips, I work in points. All the price data is given in points. The difference between two price values is in points. My stoploss and my exit point are all in points...they are a specific market price. The notion of pips is an interesting one but as most here can attest to once you try and bridge the notion of pips to that of points you lose rigor and robustness, and for what? [...]

@Phil : I can appreciate yours & others different ways of calculating price parameters. We have our own preferences why change it if we don't feel we need to... My aim as you may well know, is to explore the MarketInfo's underlying calculations to be used in different instruments & brokers. Your method of using price is certainly a viable robust way.

If you're not a SUPER programmer with YEARS of Forex experience under your belt, there's no point in trying to code a universal applicable Commercial program for end users. When someone purchases a EA, they expect above all else that it's going to be Profitable. Then secondly, they expect the program to be Flexible beyond belief. Like command to close all orders b4 weekends and Let me specify how much money I wanna risk etc. As we all know it hard enough to program any Profitable EA without making it static to one Time-frame or Currency etc.

@Ubzen : Lols! You don't need to be a 'SUPER programmer'. Trust me. And although it's a possibility, for me the solution wasn't to be used for a commercial program or to be 'flexible beyond belief'. I just want to test my strategies on different platforms & instruments without the need to adjust & double check the parameters.

On pips versus dollar, can I offer an analogy you're likely to familiar with:

Let say I wanna gamble at a new casino. I brought along $5000 of capital & I'm willing to risk 2 percent of my capital. But the house provides chips in Points! The dollars at stake is converted to Points chips, they're denominated in 0.0001, 0.0005, 0.001 etc. Not only that, the next table require 10x the amount of chips denominated at a tenth of the previous table, And add to that the chips color is not so easy to made out! Ok... I'm exaggerating a bit :)) but you get my point (pun unintended). Dollars or base currency is not universal IMO while pips are. Pips are easier coz it's not a fraction & looking at any type of charts & instruments if we see x pips of gain / loss we quickly IMHO can assess & compare them.

PS : I edited & added this post a lot.... why do re-reading some of my post sometimes felt crappy?

 

I use below functions now, and it's usable across different brokers & instruments.

double vPoint; 
if(Digits == 2 || Digits == 4) vPoint = Point; else
if(Digits == 3 || Digits == 5) vPoint = Point*10; // I use this for my indies; call once on init() & use where Point supposed to be used in start() 

double Poin() 
{ 
   int d = Digits;
   switch(d){
   case 2 : {return(Point); break;}
   case 4 : {return(Point); break; }
   case 3 : {return(Point*10); break;}
   case 5 : {return(Point*10); break:}
   default : return;
} // I just come up with this. Untested but should be ok/robust. To be used to replace Point for trade parameters calculations. 

cheers, ~ cameo

 

recently i needed this so i coded it. here is my solution:

//my observation is that 1% of the underlying is about 100 pips.

//a 'Point' is the smallest unit incremental.

//so, i just calculate the number of points that is of power of 10 for 1% of the underlying.

//that amount of points is 100 pips.

double AmountPer100Pips()

{

int k=3;

while (MathRound((Bid*0.01)/(Point*MathPow(10, k)))==0)

{

k--;

}

//Comment("1%=", DoubleToStr(Bid*0.01, 5), "-", DoubleToStr(Point*MathPow(10, k), 5), " per 100 pips");

return(Point*MathPow(10, k));

}

 
ubzen:

...Average Joe's who heard about "2% risk" and "don't trade over weekends"...


You forgot "the trend is your friend" - try fitting that into a ranging strategy...!

You're quite right, the add-ons or (perceived) 'nice to have' functions may not help and often will harm the strategy the EA needs to follow to make money

-BB-

 
jesuscheung:

recently i needed this so i coded it...


This code does actually work only for currencies quoted smaller than 0.01 Ticks. Putting in Dow (TickSize 1) or Ger30 (TickSize 0.5) does not work.
 

cameofx: Let say I wanna gamble at a new casino. I brought along $5000 of capital & I'm willing to risk 2 percent of my capital. But the house provides chips in Points! The dollars at stake is converted to Points chips, they're denominated in 0.0001, 0.0005, 0.001 etc. Not only that, the next table require 10x the amount of chips denominated at a tenth of the previous table, And add to that the chips color is not so easy to made out! Ok... I'm exaggerating a bit :)) but you get my point (pun unintended). Dollars or base currency is not universal IMO while pips are. Pips are easier coz it's not a fraction & looking at any type of charts & instruments if we see x pips of gain / loss we quickly IMHO can assess & compare them.

 

Woah, a casino analogy. I'd totally missed that one lol. Ok, I can dig it. Lets say Average Joe walks into a new casino, instead of $5000 lets make the math simple and say $100. He hands the gorgeous dealer $100 Benjamin Franklin and the lovely dealer politely asks him "Sir, how would you like that back?, In Red, Greens, or Half-n-Half? Average Joe is totally confused. His next question to her is "how much is Red's, Greens and what to you mean by Half-n-Half. This is where she smiles, toss her hair side-ways and drops her shoulders with a sigh because she knows she's dealing with a noob. If I'm sitting next to Average Joe, I'm looking around for the cock-tail waitresses. She starts to reach into the tray and lift a chip up proclaiming "this is a Red chip, it's worth 0.0001 points".....(what!! hold-up is this a real casino, but lets go along with it).... Average Joe is still confused, and I would be too. He exclaims, "Yeah, but how much is it in Dollars". And she replies, "it's $5 Dollars Sir" "and the Greens are $25" and "Half-n-Half means 2-Greens and 10-Reds".

 

Now points totally goes out the window, Average Joe is fixated on Colors. This is how the house gets you, even a monkey can distinguish Colors. Average Joe wanting to sound cool says "Well... give me half-n-half then... pretty mamma". Me next to this guy, I have the brightest smile to keep from busting out laughing. Anyways, It's time to bet and Average Joe is thinking 2% he wants to stay at this table for as long as possible. O_o, he needs $2, so he asks the dealer "are there any 2$ chips" and she says "yes, the White ones are 1$ and the Pink ones are 2.50$ would you like some". He says "Yes". She says hand me 2-Reds and I'll give you 10 Whites (she's not about to give you all the white's in her tray... she need those to convert... but she's hoping you're gonna start tipping).

 

Ok!!, we back to betting again. At which point Average Joe put 2-White chips on the table. This causes the dealer to freeze. She looks at him, twist the sign to a visible angle and says "it's a $5 minimum table Sir". "The minimum table we offer at this casino is the 3-Dollars table where" she continues "it's right over there where the Buff guy is dealing". Average Joe thinks about it for a second, (2$ vs 3$....Gorgeous vs Fabillio over there) "nah, lets play some cards, he exclaims" pulls back his 2-whites and toss 2-Reds in there.

 

If this had been a Japanese Casino, the format would have still been the same, except it would have toke longer to explain how much a point is worth.  

 
1005phillip:

This. Personally I don't work in pips, I work in points. All the price data is given in points.

That means each time you change brokers, (or if the broker suddenly changes like IBFX did several month ago) you have to remember to change all your EA's parameters accordingly. Like slippage, 3 or 30 points.

And how much will you loose if you forget one or worse change it the wrong way.

Much easier to define non-percentage type parameters in pips and convert to points or doubles where necessary.

 
WHRoeder:

That means each time you change brokers, (or if the broker suddenly changes like IBFX did several month ago) you have to remember to change all your EA's parameters accordingly. Like slippage, 3 or 30 points.

And how much will you loose if you forget one or worse change it the wrong way.

Much easier to define non-percentage type parameters in pips and convert to points or doubles where necessary.


Actually it is the exact opposite. My EA's are coded to be general enough that I can drop them onto basically any MT4 broker with any combo of digits, etc, and the mechanics of the trading and strategy are agnostic to the underlying broker-specific parameters. Its when you start programming with ill-defined parameters such as "pips" that you open the door for trouble.

What I find interesting is that if you already have a strategy that relies on indicators or some mathematical compuation involving market prices for the determination of stoploss and take profit - be it ATR or RSI or resistance levels, etc - basically anything other than the trivial "I want a fixed 30 pip trailing stop" then you have absolutely no need to be working with pips in the first place.

Doing things with fixed-pips - e.g. 25 pip takeprofit or 50 pip stoploss - to me just silly because the market simply doesn't work/function that way so you can't really expect to be profitable trying to take money from it by operating a trade strategy that way. It is all above percentage moves, resistance levels, etc. Things that are defined by price, not pips.

Just my opinion, could be totally flawed.

(PS - your example of IBFX changes is perfect case in point, my EA's didn't care that IBFX made their changes. Another is FXDD which recently this summer changed to 5-digit on one of their demo servers, I didn't even realize this or know it happened until I was reviewing quarterly numbers and noticed the price feeds had changed)

Reason: