#include <Trade\Trade.mqh>
CTrade trade;
I am new to mql. I have seen the code above in this tutorial but there are parts I do not understand.
I understand the first line. We are importing the Trade header file from the Trade.mqh library.
What does the second line mean? Are we assigning the CTrade class to a variable named 'trade' ? And
where does the CTrade value come from. Is it from the first line? If so how does the CTrade gets its value from
the first line?
When we include a library in mql how do we get to access its functions and other values?
try this https://www.mql5.com/en/articles/481
- www.mql5.com
Example:
//+------------------------------------------------------------------+ //| Open Buy.mq5 | //| Copyright © 2018, Vladimir Karputov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2018, Vladimir Karputov" #property version "1.000" //--- #include <Trade\Trade.mqh> CTrade m_trade; // object of CTrade class //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart () { //--- m_trade.Buy( 1.0 ); // open Buy position, volume 1.0 lot } //+------------------------------------------------------------------+
We connect a trading class:
#include <Trade\Trade.mqh>
We declare the object ( m_trade ) of the trade class CTrade
CTrade m_trade; // object of CTrade class
after that, through the m_trade object , we get access to the public methods of the CTrade trading class (in the example below, we turn to the 1.0 Open BUY Position method)
m_trade.Buy( 1.0 ); // open Buy position, volume 1.0 lot
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
#include <Trade\Trade.mqh>
CTrade trade;
I am new to mql. I have seen the code above in *** but there are parts I do not understand.
I understand the first line. We are importing the Trade header file from the Trade.mqh library.
What does the second line mean? Are we assigning the CTrade class to a variable named 'trade' ? And
where does the CTrade value come from. Is it from the first line? If so how does the CTrade gets its value from
the first line?
When we include a library in mql how do we get to access its functions and other values?