Questions from Beginners MQL5 MT5 MetaTrader 5 - page 788

 

Can you please tell me how to make this construction

void OnStart()
  {
   int h=FileOpen("str.bin",FILE_READ|FILE_BIN);
   if(h==INVALID_HANDLE){
      Alert("Ошибка открытия файла");
      return;
   }
   int s=FileSize(h);
   string TXT=FileReadString(h,s);
   Print(TXT);
   FileClose(h);
  }

works in MT5 the same way as in MT4, i.e. ТХТ variable is readable, not as squares.

It seems to be something with encoding, but I don't know how to solve it.

 
Андрей:

Can you please tell me how to make this construction

void OnStart()
  {
   int h=FileOpen("str.bin",FILE_READ|FILE_BIN);
   if(h==INVALID_HANDLE){
      Alert("Ошибка открытия файла");
      return;
   }
   int s=FileSize(h);
   string TXT=FileReadString(h,s);
   Print(TXT);
   FileClose(h);
  }

works in MT5 the same way as in MT4, i.e. ТХТ variable is readable, not as squares.

It seems to be something with encoding, but I don't know how to solve it.

Try explicitly specifying an encoding. FILE_ANSI or unicode
 
Vladislav Andruschenko:
Try specifying the encoding explicitly. FILE_ANSI or unicode
If FILE_BIN is replaced by FILE_ANSI, then the entire string will remain only the initial, but readable fragment, while the rest will not be, with unicode you get a blank string. It turns out that if you use ANSI, you must read line by line up to separators, and then add all parts to get one string. Isn't there anything simpler, except of course to return to MT4?
 

No. You're not in place, you're together.

 int h=FileOpen("str.bin",FILE_READ|FILE_BIN|FILE_ANSI);
 
Vladislav Andruschenko:

No. You're not in place, you're together.

Thanks, some progress on that, but still the string gets cut down several times.
 

Can you please advise whether it is possible to call the MA indicator to the chart with a program to setthe colour of itsdrawing?

I don't know how to call the colour settings of the indicator...

h__ = iMA(_Symbol,0,20,0,MODE_LWMA,PRICE_CLOSE);
ChartIndicatorAdd(0,0,h__);
 
elmucon:

Can you please advise whether it is possible to call the MA indicator to the chart with a program to setthe colour of itsdrawing?

I don't know how to call it, but I don't know how to set its colour ...

You can, but to do it you will have to make a change in the custom indicator: add a colour to the input parameter
apply this colour in the indicator OnInit
call this changed indicator through iCustom

 
Vladimir Karputov:
You can, but you have to make a change in the custom indicator: add a colour to the input parameter
in the indicator's OnInit will apply this colour
call this modified indicator via iCustom


That's ok - thought maybe there's an easier way ... Thanks!

I think the developers could have added some more parameters for the handle ....

I didn't even see a colour change in the structures ...

like this

h__ = iMA(_Symbol,0,20,0,MODE_LWMA,PRICE_CLOSE,DRAW_LINE,clrRed);
 
elmucon:

I see - I thought there might be an easier way... Thanks!

I think the developers could have added a few more parameters for the handle ....

I didn't even see a colour change in the structures ...

like this

Then it's like this:

h__ = iMA(_Symbol,0,20,0,MODE_LWMA,PRICE_CLOSE);
ChartIndicatorAdd(0,0,h__,clrRed);
 
Vitaly Muzichenko:

Then it's like this:

I don't mind - it's a noramalek too ...

Reason: