Learning the code syntax

 

Hello what does it mean this expression?...I'm confused with ? : etc.


double price = (type == OP_SELL) ? Ask : Bid;
 

Easiest and fastest way:

  1. mark the ?
  2. press F1
  3. start reading!
 

cant find anything in that way...

 
  1. florenceale: what does it mean this expression?...I'm confused with ? : etc.

    Ternary Operator ?: - Operators - Language Basics - MQL4 Reference

  2. florenceale: cant find anything in that way...
    Why not? Press F1 (help)


 

yes thanks i had found it but by google. It means either or.

 
florenceale: Hello what does it mean this expression?...I'm confused with ? : etc.
// Concise version
double price = (type == OP_SELL) ? Ask : Bid;

// Verbose version
double price;
if (type == OP_SELL)
   price = Ask;
else
   price = Bid;

// Yet another version
double price = Bid;
if (type == OP_SELL) price = Ask;
 
Comments that do not relate to this topic, have been moved to "Need help with Custom Indicator code — the separate window is empty".
Reason: