one line of EA code to check

 
hi all,

i am a newbie at EA programming and eager to become proficient and a contributing member.
i've read your posts and am most impressed with the comradery here.

was wondering if anyone could tell me what i am doing wrong in this line of code:
if (PRICE_OPEN==iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))

-what i am testing: if current opening price equals the lower 20 bollinger band from the previous bar... then... next statemtent...

thanks in advance.

ps. please feel free to let me know of any post protocal errors. ..
 
not use equals , since it is not sure for double digital.

use last > and next <
or last < and next >
 
Yes, what DxdCn says: You cannot use == on two doubles - it doesn't work due to the way doubles are stored on a computer. Use this:

if (MathAbs(PRICE_OPEN-iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))<Point)
This checks if the distance (MathAbs(A-B)) is smaller than one point, e.g. they are the same.
 
PRICE_OPEN is a symbolic constant which is equal to 1 (see price constants in metaeditor). To get opening price use Open[0] or Open[1] for previous open.

if (Open[0]==iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))

This will almost never happen since open hardly ever falls exactly on the band. to get open within couple of pips of band use

if (MathAbs(Open[1]-iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))<Point*3)
as suggested above.
 
irusoh1:
PRICE_OPEN is a symbolic constant which is equal to 1 (see price constants in metaeditor). To get opening price use Open[0] or Open[1] for previous open.

if (Open[0]==iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))

This will almost never happen since open hardly ever falls exactly on the band. to get open within couple of pips of band use

if (MathAbs(Open[1]-iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,1))<Point*3)
as suggested above.


thanks for all your responses... DxdCn, Thomas, and irusoh1.

didn't realize Price_Open is a symbolic constant equal to 1. So will try Open[0] for current bar's opening price.

Question: what about the use of Bid? got a tip that Bid will give current Bid price (not open but tick by tick).

thanks again!

 
Yes it does. You can find it in the manual, by using the search on this site.

Sorry about not correcting the PRICE_OPEN mistake - didn't check that part, just copied it.
 
ThomasB:
Yes it does. You can find it in the manual, by using the search on this site.

Sorry about not correcting the PRICE_OPEN mistake - didn't check that part, just copied it.



Thanks Thomas.
Reason: