Questions from Beginners MQL5 MT5 MetaTrader 5 - page 680

 
Vladimir Karputov:

This is not the way to do it:

bool TimeFlag,FLG;
int TimeScale=50,TimeInMemory,TimeNow;

or rather, after such a declaration, you must explicitly initialise(assign values to) these variables in OnInit().

The Sell method must also be surrounded by checks, such as

trade.ResultRetcode(),
            " (",trade.ResultRetcodeDescription(),")");

And there may be one more catch - in the morning, at the opening of trading, the auction does not start immediately, not from the first second - at this point, errors may occur

I have not run it on real or demo account yet, only in tester mode. And there is an error with Invalid order type
 
post_ek:
I haven't run it on a real or demo account yet, only in tester mode. And there is an error with Invalid order type
I tried it in tester, there was no such error. Describe how you tested: tick generation mode, deposit, leverage, period and provide the tester log. Also please give us the build you are using. I was testing with 1486.
 
Vladimir Karputov:
I ran it in the tester - no such error. Describe how you tested: tick generation mode, deposit, leverage, period and provide tester log. Also please state which build you are using - I was testing with 1486.

build 1485



Files:
Zhurnal.txt  52 kb
 
post_ek:

build 1485

Please show the specification of the SBER contract - is it a futures?, the name of the trading server you are logging into and the tester log.
 
Vladimir Karputov:
Please show the specification of the SBER contract - is it a futures?, the name of the trading server you are logging into and the tester's log.

Trading server - Open-Broker

Files:
Zhurnal.txt  52 kb
 
post_ek:

Trading server - Open-Broker

Is it already possible to trade shares? Replace Buy with BuyLimit and Sell with SellLimit.
 
Vladimir Karputov:
Is it already possible to trade a stock? Replace Buy with BuyLimit and Sell with SellLimit.

Aren't shares traded on the stock exchange?

If I replace Buy with BuyLimit, how will I buy shares at the market price?

 
Vladimir Karputov:
Is it already possible to trade stocks? Replace Buy with BuyLimit and Sell with SellLimit.
Almost like a year on MT5 in Otkritie.
 
Vladimir Karputov:

This is not the way to do it:

bool TimeFlag,FLG;
int TimeScale=50,TimeInMemory,TimeNow;

or rather, after such a declaration, you must explicitly initialise(assign values to) these variables in OnInit().

The Sell method must also be surrounded by checks, such as

trade.ResultRetcode(),
            " (",trade.ResultRetcodeDescription(),")");

And there may be one catch - in the morning, at the opening of trading, trading does not start immediately, not from the first second - that's when errors are possible.

Vladimir, don't confuse the man!

From the documentation:

The scope of global variables is the entire program, global variables are available from all functions defined in the program. They are initialized with zero, unless another initial value is explicitly specified. A global variable can be initialized only with a constant or a constant expression corresponding to its type.

Global variables are initialized only once after a program is loaded into the client terminal memory and before the firstInit event isprocessed.For global variables that are objects of classes the corresponding constructors are called during initialization. In scripts, global variables are initialized before theStart event is handled.

https://www.mql5.com/ru/docs/basis/variables/global
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
Документация по MQL5: Основы языка / Переменные / Глобальные переменные
  • www.mql5.com
Основы языка / Переменные / Глобальные переменные - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Kozitsyn:
Almost like a year on MT5 at Otkritie.
So is it possible to trade MT5 shares in Otkritie or not?