Download MetaTrader 5

how can I easily look at a value

To add comments, please log in or register
Jens89
32
Jens89  

Hi,

I would like to know how I can easily check a value of a function / variable in my program.


let's say I Have the following variable


double TODAY_OPEN = iOpen(NULL,1440,0);


is it possible to display the value somewhere so I can have  a look at which amount the variable is showing.


thanks

whroeder1
17097
whroeder1  
Jens89: is it possible to display the value somewhere so I can have  a look at which amount the variable is showing.
Perhaps you should read the manual. Of course it's possible. The following comes to mind:
Comment
Text object
Alert
Print (to the journal)
Jens89
32
Jens89  
whroeder1:
Perhaps you should read the manual. Of course it's possible. The following comes to mind:
Comment
Text object
Alert
Print (to the journal)


thanks for your reply.

I have read the manual but I'm still struggling. I'm new to MQL4. 


what I tried for example was (I am creating a custom indicator):


void Comment(string test= "test");

When I put it out of the special functions it doesn't work.

I then tried to put it within int OnInit() 

then I got:


'Comment' - function can be declared only in the global scope


whroeder1
17097
whroeder1  
Jens89:

void Comment(string = "test");


'Comment' - function can be declared only in the global scope

You should read the manual. Starting with the basics and then functions.
  1. The prototype of a function is returnType FunctionName( ArgType1 argName1, ArgType2 ...)
    void  Comment(
       argument,     // first value
       ...           // next values
       );
    Comment takes any type so they don't list any.

  2. So the call is
       Comment(
          argument,     // first value
          ...           // next values
          );
    It returns nothing, so there is nothing to the left.

  3. string var;               // You can declare a variable
    var = "something";        // you can assign to a variable.
    string var = "something"; // Or both
    What you wrote is babel no variable name.
    string = "test"

  4. What you wrote is babel. It looks like you are defining a function which you can't do inside another function.
    void Comment(...

x
nicholishen
1537
nicholishen  
Jens89:

Hi,

I would like to know how I can easily check a value of a function / variable in my program.


let's say I Have the following variable


double TODAY_OPEN = iOpen(NULL,1440,0);


is it possible to display the value somewhere so I can have  a look at which amount the variable is showing.


thanks


I think this is what you want.


https://www.metatrader5.com/en/metaeditor/help/development/debug#watch

To add comments, please log in or register