Davietrader:
Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_UPPER, 0); Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_LOWER, 0); if(Bid > Upperline) PlaySound("upperline.wav"); if (Bid < Lowerline) PlaySound( "lowerline.wav"); return(0); } The upperline wave sound is triggered doesn't matter where price is. Any help will be really appreciated!!
Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_UPPER, 0); Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_LOWER, 0); if(Bid > Upperline) PlaySound("upperline.wav"); if (Bid < Lowerline) PlaySound( "lowerline.wav"); return(0); } The upperline wave sound is triggered doesn't matter where price is. Any help will be really appreciated!!

Your not setting a value for the upperline variable, therefore it defaults to 0, and the bid is always higher than 0.
zupcon:
Your not setting a value for the upperline variable, therefore it defaults to 0, and the bid is always higher than 0.
Your not setting a value for the upperline variable, therefore it defaults to 0, and the bid is always higher than 0.
Hey ZUP thank you very much....your observation was spot on!!
First I made a stupid mistake writing lowerline twice....!!
But after reading your post I realized that I was actually stating "Bid" as a variable value and as a price reference for my "if" making it a worthless conditional.
I changed the iENVELOPES "Bid" to CLOSE_PRICE and guess what? It works!!
Thanks gain for the help!!
Davietrader:
But after reading your post I realized that I was actually stating "Bid" as a variable value and as a price reference for my "if" making it a worthless conditional.
But after reading your post I realized that I was actually stating "Bid" as a variable value and as a price reference for my "if" making it a worthless conditional.
Well spotted, glad you got it sorted out

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys
I'm trying to learn how to code and so far being able to change some code already written with some success.
Now I'm trying to write something from scratch. I'm starting with something simple but the darn code seems to be wrong and I'm stuck
here is the code
int init()
{
return(0);
}
int start()
{
double Lowerline;
double Upperline;
Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_UPPER, 0);
Lowerline = iEnvelopes(NULL,0,8,MODE_SMA, 0,Bid,0.1,MODE_LOWER, 0);
if(Bid > Upperline) PlaySound("upperline.wav");
if (Bid < Lowerline) PlaySound( "lowerline.wav");
return(0);
}
My goal is to have the playsound triggered when price crosses the upperline
of the envelope and stop when it goes back below the upperline
Same thing with the lowerline, playsound triggered when it is below the lowerline on envelope and stop when it goes above
It is my understanding that the "if" on my code would do it but it is not hapenning. The upperline wave sound is triggered doesn't matter where price is.
Any help will be really appreciated!!