Questions from Beginners MQL5 MT5 MetaTrader 5 - page 994

 
Kolya32:
Thank you too. That works too)

I want to thank you too :)))

This one

double Candle = (iClose(_Symbol,PERIOD_H1,1) - iOpen(_Symbol,PERIOD_H1,1)) / _Point;
if(Candle < 0){Candle = Candle * -1;}
string Candle2 =  DoubleToString(Candle, 0);
int Candle3 = StringToInteger(Candle2);

can be replaced with this and it will work the same.

int Candle = (int)fabs((iClose(_Symbol,PERIOD_H1,1) - iOpen(_Symbol,PERIOD_H1,1)) / _Point);
Документация по MQL5: Математические функции / MathAbs
Документация по MQL5: Математические функции / MathAbs
  • www.mql5.com
Математические функции / MathAbs - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 


Good day. Question. How may I associate tick data with timeframe bars? Below is a part of the code. It switches the colour of the buffer. Figured it out

with colours, but it's not clear how to link here...? I have some thoughts about MqlRates structure, but it's not clear which value to take...? I've seen how it works (example in documentation), but the value jumps and it's not clear why

//--- Подготовка данных
   int count=(limit>1 ? rates_total : 2),copied=0;
   copied=CopyBuffer(handle_ma,0,0,count,BufferPrice);
   if(copied!=count) return 0;
//----   
   for(int i=limit; i>=0 && !IsStopped(); i--)
     {
      bp=NormalizeDouble(BufferPrice[i],_Digits);
//--- High signal
   if(bp>iOpen(NULL,PERIOD_CURRENT,i) && bp<iClose(NULL,PERIOD_CURRENT,i))
     {
      ExtOpenBuffer[i]=open[i];
      ExtHighBuffer[i]=high[i];
      ExtLowBuffer[i]=low[i];
      ExtCloseBuffer[i]=close[i];
      ExtColorsBuffer[i]=1;   / уфер изменения цвета
     }
//--- Low signal
   if(bp<iOpen(NULL,PERIOD_CURRENT,i) && bp>iClose(NULL,PERIOD_CURRENT,i))
     {
      ExtOpenBuffer[i]=open[i];
      ExtHighBuffer[i]=high[i];
      ExtLowBuffer[i]=low[i];
      ExtCloseBuffer[i]=close[i];
      ExtColorsBuffer[i]=2;
     }
     }
 
Alexey Viktorov:

I want to thank you too :)))

int Candle = (int)fabs((iClose(_Symbol,PERIOD_H1,1) - iOpen(_Symbol,PERIOD_H1,1)) / _Point);
Thank you too. Haven't tried this design, but take my word for it, it works)
 
Kolya32:
Thank you too. I haven't tried this design, but I take your word for it that it works.)

You shouldn't have tried it. It was a joke about thank you, but the code is serious. Why convert double to int via string when there is an absolute value function...

 
kopeyka2:


Good day. A question has arisen. How to link tick data to timeframe bars. Below is a part of the code. It is switching the colour of the buffer. Figured it out

with colours, but it's not clear how to link here...? I have some thoughts about MqlRates structure, but it's not clear which value to take...? I saw how it works (example in documentation), but value of it jumps and i don't understand why.

You don't check what is received in

if(bp>iOpen(NULL,PERIOD_CURRENT,i) && bp<iClose(NULL,PERIOD_CURRENT,i))
if(bp<iOpen(NULL,PERIOD_CURRENT,i) && bp>iClose(NULL,PERIOD_CURRENT,i))

Functions return 0 in case of error. Your logic will also work in case of erroneous data from iOpen() in the first case and iClose() in the second.

For receiving tick data in mql5 there's structure MqlTick and function CopyTicks(), in which you can get the data of the necessary number of last ticks in the structure. Then, in order to link it with a bar of the timeframe, you need to get the bar number by tick time. iBarShift() and the tick.time structure field

 
Artyom Trishkin:

You do not check what is received in

Functions return 0 in case of error. Your logic will also work in case of error data from iOpen() in first case and iClose() in second case.

To get the tick data in mql5, there is a structure MqlTick and function CopyTicks(), in which you can get the data for the necessary number of last ticks in the structure. Then, in order to link it with a bar of the timeframe, you need to get the bar number by tick time. iBarShift() and the tick.time structure field

Thanks. The difficulty here (in my question) is that candlesticks are shaded by ticks. It's easier by the bar of the timeframe. But... And that's why I'm here again))))
 
kopeyka2:
Thank you. The difficulty here (in my question) is that candles are painted with ticks. It's easier by the bar of the timeframe. But... And that's why I'm here again))))

Please. There (in your question) I don't understand anything...

 
Artyom Trishkin:

Please. I don't understand anything here (in your question)...

I think I found a similar 3LineBreak https://www.mql5.com/ru/code/485
 
Gentlemen, I can't understand where the parameter continuous number of losing trades is in the mt5 tester or do I have to prescribe it to the robot? mt4 has it. I can't find how to implement it.
Files:
l9rnznuztu.jpg  73 kb
 
freelancerAntonyan:
Gentlemen, I can't understand where the parameter continuous number of losing trades is in the mt5 tester or does it need to be prescribed in the robot? mt4 has it. I can't find how to implement it.

You can do the math yourself, choose in the custom criteria.

Reason: