Would you help a poor wannabe coder?
  #1 (permalink)  
Old 06-10-2010, 11:03 AM
Currency Trader
 
Join Date: Jun 2010
Posts: 3
Davietrader is on a distinguished road
Default Would you help a poor wannabe coder?

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!!
Reply With Quote
  #2 (permalink)  
Old 06-10-2010, 09:41 PM
Forex Warrior
 
Join Date: Jul 2005
Posts: 274
zupcon is on a distinguished road
Default

Quote:
Originally Posted by Davietrader View Post



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.
Reply With Quote
  #3 (permalink)  
Old 06-10-2010, 11:48 PM
Currency Trader
 
Join Date: Jun 2010
Posts: 3
Davietrader is on a distinguished road
Default

Quote:
Originally Posted by zupcon View Post
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!!

Last edited by Davietrader; 06-10-2010 at 11:52 PM.
Reply With Quote
  #4 (permalink)  
Old 06-12-2010, 12:50 AM
Forex Warrior
 
Join Date: Jul 2005
Posts: 274
zupcon is on a distinguished road
Default

Quote:
Originally Posted by Davietrader View Post

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
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looking for EA coder forexweb System Coding 5 09-04-2012 03:30 PM
Looking for a MT4 Coder? KaMpeR Classified Ads 1 05-18-2006 03:00 AM


All times are GMT. The time now is 11:28 PM.

Registered members gain free access to online FOREX currency trading tools, foreign exchange software, Metatrader MT4/MT5 expert advisors, MT4 indicators and EAs. Register now