Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1235

 
Question, is there any way to determine programmatically that the tester is running in MT5 ?
 
Maksim Mihajlov:
Question, is there any way to determine programmatically that a tester is running in MT5 ?
Information about a running MQL5 program- properties of an mql5 program, which helps to further control its behavior;
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе
Документация по MQL5: Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе
  • www.mql5.com
Константы, перечисления и структуры / Состояние окружения / Информация о запущенной MQL5-программе - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Hello. Not sure who to ask, where to write. Is it possible to trade via MT5 with Interactive Brokers? I asked them a question, but they threw a link in the reply to contact https://www.metaquotes.net/ru/company/contacts, so it's a form for a legal entity. There seems to be some kind of software bridge between MT5 and TWS, can you tell me anything about that? If there is a possibility to buy quotes from American stock exchanges with MT5 broadcasting in order to see the chart of a certain instrument and use MT5 indicators, but make transactions through TWS. If this is not the right question, please tell me where to write and ask.
Контакты представительств компании MetaQuotes
Контакты представительств компании MetaQuotes
  • www.metaquotes.net
По вопросам приобретения торговой платформы MetaTrader 5 вы можете обратиться к нашим представителям:
 
akarustam:

Tired of understanding the reason for the constant difference in the optimisation of a good EA in MT5... On the same currency pair, with the same EA, with the same optimization parameters, there is a difference in optimization results... I.e., I always use the same EA and expected the same results, but in fact they are different...

Enlighten pliz, to whom is familiar with this kind of confusion ?

THANK YOU.

Mostly uninitialized forced variables or reference to global variables (those in the terminal)

 

Help, candlestick indicator

#property tester_everytick_calculate
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   1
//--- plot newCandles
#property indicator_label1  "newCandles"
#property indicator_type1   DRAW_CANDLES
#property indicator_color1  clrWhite
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double   newCandles_Open[];
double   newCandles_High[];
double   newCandles_Low[];
double   newCandles_Close[];
int      newCandles_index  = 0;
//--- цены формирующейся свечи
double   candle_Open    = -1.0;
double   candle_High    = -1.0;
double   candle_Low     = -1.0;
double   candle_Close   = -1.0;

int OnInit()
{
//--- indicator buffers mapping
   SetIndexBuffer(0, newCandles_Open,  INDICATOR_DATA);
   SetIndexBuffer(1, newCandles_High,  INDICATOR_DATA);
   SetIndexBuffer(2, newCandles_Low,   INDICATOR_DATA);
   SetIndexBuffer(3, newCandles_Close, INDICATOR_DATA);
//+---------------------
   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, 0.0);
//+---------------------
   PlotIndexSetString(0,PLOT_LABEL,"newCandles("+IntegerToString(in_Candle_Size_Point)+", "+TimeToString(in_Start_Time,TIME_DATE)+")");
   IndicatorSetString(INDICATOR_SHORTNAME,"newCandles("+IntegerToString(in_Candle_Size_Point)+", "+TimeToString(in_Start_Time,TIME_DATE)+")");
//+---------------------
   ArrayInitialize(newCandles_Open,0.0);
   ArrayInitialize(newCandles_High,0.0);
   ArrayInitialize(newCandles_Low,0.0);
   ArrayInitialize(newCandles_Close,0.0);

//+---------------------
   return(INIT_SUCCEEDED);
}

OnCalculate performs the calculation and fills the buffers INDICATOR_DATA when the conditions are fulfilled

      newCandles_Open[newCandles_index]      = candle_Open;
      newCandles_High[newCandles_index]      = candle_High;
      newCandles_Low[newCandles_index]       = candle_Low;
      newCandles_Close[newCandles_index++]   = candle_Close;

I thought that when these buffers are filled the candlestick should be drawn. But it is not. Why?

 
Сергей Таболин:

Help, candlestick indicator

OnCalculate performs the calculation and fills the buffers INDICATOR_DATA when the conditions are fulfilled

I thought that when these buffers are filled the candlestick should be drawn. But it is not. Why?

Where is the full code? It is not clear, what exactly you do in OnCalculate. As an example, use theDRAW_CANDLES help.

And what is this candle with negative prices?
 
Vladimir Karputov:

Where is the full code? It's not clear what exactly you are doing in OnCalculate. As an example, use theDRAW_CANDLES help.

And what is this candle with negative prices?

Forum on trading, automated trading systems & strategy testing

MQ5::Question on candlestick indicator.

Sergey Tabolin, 2020.08.05 18:17

Edgar, thank you, but it is clear to me. What is not clear is why there are no ticks before 2019?


Now the main question is.

Why are the candles not drawn in the indicator? Where am I wrong?

Public domain source ))))

This is just an initialisation to start the countdown. The prices are counting correctly.
Files:
newCandles.mq5  21 kb
 
Сергей Таболин:
This is simply an initialisation to start the countdown. The prices are counted correctly.

In debugging, go through and check in which cases will your condition be met?


 
Vladimir Karputov:

In debugging, go through and check in which cases your condition will be met?


I realise that this may not be correct. But!

It works. The condition is fulfilled when the indicator starts. Once. The prices are printed. Then the ticks are calculated. They are also printed.

2020.08.06 14:27:31.101 newCandles (USDJPY,H1)  2020.08.05 21:31:16 >>> Свеча 03623 >> open = 105.638 hihg = 105.675 low = 105.473 close = 105.473 > Сформирована за 07539 тиков.
2020.08.06 14:27:31.101 newCandles (USDJPY,H1)  2020.08.06 03:14:33 >>> Свеча 03624 >> open = 105.473 hihg = 105.635 low = 105.395 close = 105.635 > Сформирована за 19034 тика.
2020.08.06 14:27:31.102 newCandles (USDJPY,H1)  2020.08.06 10:54:42 >>> Свеча 03625 >> open = 105.635 hihg = 105.695 low = 105.471 close = 105.471 > Сформирована за 08861 тик.
2020.08.06 14:27:31.102 newCandles (USDJPY,H1)  ~~~~ Предварительный расчёт индикатора закончен.
2020.08.06 14:27:31.102 newCandles (USDJPY,H1)  Расчёт на тике 00872 Бар 03626
2020.08.06 14:27:31.102 newCandles (USDJPY,H1)  Расчёт на тике 00873 Бар 03626
2020.08.06 14:27:31.102 newCandles (USDJPY,H1)  Расчёт на тике 00874 Бар 03626

But I want to know why no candlesticks are printed.

 
Сергей Таболин:

I realise that this may not be the right thing to do. But!

It works. The condition is met when the indicator starts. Once. The prices are printed. Then the ticks are calculated. They are also printed.

But I want to know why no candlestick is drawn.

First, learn to build the indicator based on DRAW_CANDLES. At the same time you have to think what a '0' candlestick is.

That is, until you get even close to the ticks.


To draw a candlestick, you have to fill ALL four buffers. You don't do that - you skip both newCandles_Close and ....

Reason: