Home | MQL4 Tutorial For Dummies | Blogs | EA Builder Blogs
Memberships Login | MQL4 Course | Community | Contact Us

How to Use More Than, Lesser Than, Equal, Not Equal in Forex Trading Strategy

How to use more than , lesser than, equal or not equal in Forex Trading Strategy

 As a part of how to design your forex trading strategy,  you need to know what is the condition that you could check for ? In general, you know you could compare the price, buw how to compare the price? For example, you want to check

  • Whether the price has moved more than the 5 moving average price ?
  • Whether the price has moved lesser than the 5 moving average price?

This post is going to reveal the type of mathematic condition that you could use to check your criteria, they are known as relational operators. This knowledge will help you when

  • you're designing your condition
  • using the EA builder to design your condition for custom indicator
  • custom EA.

What you'll learn in this post

  • What does relational operators do?

  • More than  > 

  • Lesser than < 

  • Equal ==

  • More or equal than >= 

  • Lesser or equal than <=

  • Not equal !=

These are the relational operators that are commonly used when you want to design your trading strategy.


What does relational operator do?

From the example below, I am using two variables to make comparison  A and B .

A and B can either be

  • a price Ask, Bid, Open Price, High Price, Low price, or Close price
  • an indicator price (i.e. Moving average price , Bollinger band price)
  • Time
  • Volume
  • or etc

A reminder, the comparison will ONLY give you TWO results in

  • True / Matched / Condition passed
  • False / Mismatched / Condition failed

For both of the results, you could decide to do the actions that you want. For example, if the condition checking is passed, then you do a buy trade, on the other hand, if the condition checking is failed, then you do a sell trade.

On both results, whether is true or fail, you could decide to do something on each of the result, or  you could just do nothing.
For example,

  • I only want to execute sell trade when the result is fail. I will do nothing if the checking is true.
  • I only want to close the trade when the condition checking is true.



More than  > 

This operator more than > is to check whether A  is more than B.

For example,

 Examples  Condition Check IF   Result  Graph Examples
 

A = 102.00

B = 101.00

A > B Condition Matched.  A = Blue Line
B = Red Line
 

A = 101.00

B = 102.00

 A  > B  Condition Failed.   A = Blue Line
B = Red Line

Lesser than < 

This operator lesser than < is to check whether A lesser more than B.

For example,

 Examples  Condition Check IF  Result  Graph Examples
 

A = 102.00

B = 101.99

A < B Condition Failed.  A = Blue Line
B = Red Line
 

A = 101.99

B = 102.00

 A  < B  Condition Matched.   A = Blue Line
B = Red Line



Equal ==

This equal operator is to check the whether A is exactly the same with B.

For example,

 Examples  Condition Check IF  Result  Graph Examples
 

A = 70.00

B = 70.00

A == B Condition Matched.  A = Blue Line
B = Red Line
 

A = 70

B = 71.01

 A  == B  Condition Failed.   A = Blue Line
B = Red Line
 

A = 70

B = 69.99

 A  == B  Condition Failed.   A = Blue Line
B = Red Line

 


More or Equal than >=

More or equal than operator is to check whether the price is more than OR equal with. Unlike the more than > comparison, if the price is exactly the same, it is still not true. However, in this comparison, the result is true when the price is exactly the same.

 

For example,

 Examples  Condition Check IF  Result  Graph Examples
 

A = 70.00

B = 70.00

A >= B Condition Matched.  A = Blue Line
B = Red Line
 

A = 70

B = 71.01

 A  >= B  Condition Matched.   A = Blue Line
B = Red Line
 

A = 70

B = 69.99

 A  >= B  Condition Failed.   A = Blue Line
B = Red Line

 


Lesser or Equal than <=

This is the opposite of the more or equal than operator. It is to check if the price is lesser or equal than . The condition is true when the price is exact the same or lesser.

For example,

 Examples  Condition Check IF  Result  Graph Examples
 

A = 70.00

B = 70.00

A <= B Condition Matched.  A = Blue Line
B = Red Line
 

A = 70

B = 71.01

 A  <= B  Condition Failed.   A = Blue Line
B = Red Line
 

A = 70

B = 69.99

 A  <= B  Condition Matched.   A = Blue Line
B = Red Line

 




Not Equal !=

Not equal is the opposite sign of equal. Anything that is not equal then will result in true.

For example,

 Examples  Condition Check IF  Result  Graph Examples
 

A = 70.00

B = 70.00

A != B Condition Failed.  A = Blue Line
B = Red Line
 

A = 70

B = 71.01

 A  != B  Condition Matched.   A = Blue Line
B = Red Line
 

A = 70

B = 69.99

 A  != B  Condition Matched.   A = Blue Line
B = Red Line

 


So summary, in this post, you should have learned how to use the relational operator to make your comparison.

You should know the basic relational operator like > more than, < lesser than, >= more or equal than, <= lesser or equal than, == equal operator, != not equal operator.

With this, you should able to create your own trading strategy.

Nevertheless, in this post, it only mentions how to create a single criteria check. How about you want to combine 2 criteria check?

For example, I want to check both

  • 5 moving average is > 13 moving average
  • RSI price is < 70

 

You will learn this in next post.

Stay tune.

I wish you happy learning and success in creating your EA robot.

Leave a Reply

Your email address will not be published.


*