Results 1 to 4 of 4
 0 Attachment(s)    

Thread: Problems with 'if' sentence

  1. #1

    Default Problems with 'if' sentence

    How should the line be if i want to say:
    If Bar1 >= 0 and Bar1 <= 0.0004 - just an example

    I have tried with this but it doesn't work. Compile error
    if (Bar1 > 0 || Bar1 == 0) && (Bar1 < 0.0004 || Bar1 == 0.0004)

    Have tried this as well but same problem. Compile error
    if Bar1 >= 0 && Bar1 <=0.0004

    What is it that i'm doing wrong?

  2. #2
    Junior Member
    Join Date
    Apr 2009
    Posts
    6

    Default

    You are near. If statement must be enclosed in parenthesis. Good syntax is:
    if ( (Bar1 > 0 || Bar1 == 0) && (Bar1 < 0.0004 || Bar1 == 0.0004) )

    Cheers
    Mart

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Posts
    14

    Default

    Quote Originally Posted by phover View Post
    You are near. If statement must be enclosed in parenthesis. Good syntax is:
    if ( (Bar1 > 0 || Bar1 == 0) && (Bar1 < 0.0004 || Bar1 == 0.0004) )

    Cheers
    Mart
    Instead of using (Bar1>0 || Bar1 ==0), you could do it more efficiently and easier by writing (Bar1>=0).

    Chris

  4. #4

    Default

    Ok I will use your version Chris,

    Thanks both of you.

Similar Threads

  1. Problems with Backtesting
    By exec in forum Expert advisors backtesting
    Replies: 1
    Last Post: 02-22-2011, 14:11
  2. Problems with programming EAs
    By bbbtrader in forum Ideas for expert advisors
    Replies: 0
    Last Post: 11-23-2010, 20:52
  3. Good indicator but has some problems, can anyone help?
    By Thexit in forum MQL programming
    Replies: 1
    Last Post: 09-20-2010, 04:33

Tags for this Thread

color

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •