how to add pips

Post Reply
unimak
Posts: 5
Joined: Wed Feb 08, 2012 4:11 pm

how to add pips

Post by unimak »

i want to add 20 pips to my pivot , how do i do that ,

every time i try to put it is not taking

extern int mytgt= 20 ;
int pivot ;
int tgt;

tgt = (pivot + mytgt );

damn tgt says 20 where what i would like it to display is 1.3160 ( pv 1.3140 + 20 pips )

please help, i am at my wits end.
garyfritz

Re: how to add pips

Post by garyfritz »

It's doing exactly what you told it to do. An "int" is an INTEGER, and it holds an integer value. It can't hold fractional values like 1.3160.

Furthermore you never set the pivot value to anything, so it has its default value of 0.
tgt = (pivot + mytgt) = (0 + 20) = 20.

For prices you need to use double variables. That's a different variable type that can hold fractional values. So you'd do something like:

extern double mytgt = 0.0020;
double pivot, tgt;
pivot = 1.3160;
tgt = (pivot + mytgt);

If you want to use pips as your input (e.g. extern double mytgt = 20), you will have to divide by the proper scaling factor. For non-JPY pairs that's 10000, for JPY pairs it's 100. So 20 / 10000 = 0.0020.

You're asking an incredibly basic question that suggests very little understanding of coding concepts. I recommend you go read some programming guides, e.g. the CodersGuru guide Steve posted here and/or http://book.mql4.com, to get a better understanding of what's going on. Understand the concepts before you jump in and try to write an EA.
unimak
Posts: 5
Joined: Wed Feb 08, 2012 4:11 pm

Re: how to add pips

Post by unimak »

many thanks, well i am not a coder , just wanted to try my hands on mql . since you have given me a link to codeguru , i shall go thru it .

Many thanks for your help .
User avatar
JulesvH
Trader
Posts: 50
Joined: Wed Nov 16, 2011 7:33 am

Re: how to add pips

Post by JulesvH »

Well, jump in and just try can also be a way to learn it. ;)

But thanks for the links
garyfritz

Re: how to add pips

Post by garyfritz »

And more power to you! I meant no offense -- everybody's got to start somewhere. But you wouldn't go into a literary forum and ask "what are these square-ish things with the funny little marks on the paper, anyway?" You'd learn to read first so you wouldn't have to ask very basic questions. Read through the CodersGuru guide and work through some examples, and then you'll be able to ask much more confusing questions. :lol:
User avatar
SteveHopwood
Owner
Posts: 9904
Joined: Tue Nov 15, 2011 8:43 am
Location: Misterton - an insignificant village in England. Very pleasant to live in.

Re: how to add pips

Post by SteveHopwood »

To back Gary up just in case you are feeling slightly wounded, he really meant no offence. Gary was genuinely trying to point you in the right direction.

unimak, really go for it.

This is my forum. I have attracted to it some of the brightest minds in the Forex trading world, yet only a few years ago, I was reading the CodersGuru stuff and saying to myself, "Ummmmmm, errrrrr." :lol: The idea that I would one day be running my own forum was so ludicrous that it would never have occurred to me.

I am no mega-brain. If I can learn to code then so can you.

Have fun. I do.

:D
Read the effing manual, ok?

Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.

I still suffer from OCCD. Good thing, really.

Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.

To see The Weekly Roundup of stuff you guys might have missed Click here

My special thanks to Thomas (tomele) for all the incredible work he does here.
Post Reply

Return to “Coders Hangout”