Else Statement – MQL4 for Complete Beginners Tutorial Part 9

The Else statement complements the if statement, and together the two work hand-in-hand. Just like in the previous tutorial, in this video we will study the new bit of information through a real-life example. You will learn how easy it is to simulate trading decisions in a price channel using the if and else statements. Let’s do it!

Get the full course here: https://www.forexboat.com/learn-mql4

Code For This Tutorial

Tutorial9.mq4:
//+------------------------------------------------------------------+
//| Tutorial9.mq4 |
//| Copyright 2014, ForexBoat |
//| http://www.forexboat.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexBoat"
#property link "http://www.forexboat.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
double level = 1.36900;

Alert("Bid = " + string(Bid));

if(Bid < level)
{
Alert("The price is below " + string(level) + " -> SELL");
}
else
{
Alert("The price is above " + string(level) + " -> BUY");
}

/*
if(Bid > level)
{
Alert("The price is above " + string(level));
}
*/

}

 

What are you waiting for?

START LEARNING FOREX TODAY!

Tags:
share This:
Muhammad Awais

Leave a Reply

Your email address will not be published. Required fields are marked *

What are you waiting for?

START LEARNING FOREX TODAY!

as seen on: