Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1387

 
I am Atamurat Abdukayimov, last year when I installed the mt5 app I got a call from the number +998339667671 to my old number +998975221951 which is now discontinued, can I communicate with her?
 

Afternoon.

I am redoing a standard MACD:

//+------------------------------------------------------------------+
//|                                                         MACD.mq5 |
//|                   Copyright 2009-2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009-2020, MetaQuotes Software Corp."
#property link        "http://www.mql5.com"
#property description "Moving Average Convergence/Divergence"
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_plots   2
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_type2   DRAW_LINE
#property indicator_color1  Silver
#property indicator_color2  Red
#property indicator_width1  2
#property indicator_width2  1
#property indicator_label1  "MACD"
#property indicator_label2  "Signal"
//--- input parameters
input int                InpFastEMA=12;               // Fast EMA period
input int                InpSlowEMA=26;               // Slow EMA period
input int                InpSignalSMA=9;              // Signal SMA period
input ENUM_APPLIED_PRICE InpAppliedPrice=PRICE_CLOSE; // Applied price
//--- indicator buffers
double ExtMacdBuffer[];
double ExtSignalBuffer[];
double ExtFastMaBuffer[];
double ExtSlowMaBuffer[];

int    ExtFastMaHandle;
int    ExtSlowMaHandle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtSignalBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtFastMaBuffer,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtSlowMaBuffer,INDICATOR_CALCULATIONS);
//--- sets first bar from what index will be drawn
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpSignalSMA-1);
//--- name for indicator subwindow label
   string short_name=StringFormat("MACD(%d,%d,%d)",InpFastEMA,InpSlowEMA,InpSignalSMA);
   IndicatorSetString(INDICATOR_SHORTNAME,short_name);
//--- get MA handles
   ExtFastMaHandle=iMA(NULL,0,InpFastEMA,0,MODE_EMA,InpAppliedPrice);
   ExtSlowMaHandle=iMA(NULL,0,InpSlowEMA,0,MODE_EMA,InpAppliedPrice);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   if(rates_total<InpSignalSMA)
      return(0);
//--- not all data may be calculated
   int calculated=BarsCalculated(ExtFastMaHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtFastMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
   calculated=BarsCalculated(ExtSlowMaHandle);
   if(calculated<rates_total)
     {
      Print("Not all data of ExtSlowMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }
//--- we can copy not all data
   int to_copy;
   if(prev_calculated>rates_total || prev_calculated<0)
      to_copy=rates_total;
   else
     {
      to_copy=rates_total-prev_calculated;
      if(prev_calculated>0)
         to_copy++;
     }
//--- get Fast EMA buffer
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtFastMaHandle,0,0,to_copy,ExtFastMaBuffer)<=0)
     {
      Print("Getting fast EMA is failed! Error ",GetLastError());
      return(0);
     }
//--- get SlowSMA buffer
   if(IsStopped()) // checking for stop flag
      return(0);
   if(CopyBuffer(ExtSlowMaHandle,0,0,to_copy,ExtSlowMaBuffer)<=0)
     {
      Print("Getting slow SMA is failed! Error ",GetLastError());
      return(0);
     }
//---
   int start;
   if(prev_calculated==0)
      start=0;
   else
      start=prev_calculated-1;
//--- calculate MACD
   for(int i=start; i<rates_total && !IsStopped(); i++)
      ExtMacdBuffer[i]=ExtFastMaBuffer[i]-ExtSlowMaBuffer[i];
//--- calculate Signal
   SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+

Adding a symbol variable:

Symbol1

Changing

   ExtFastMaHandle=iMA(NULL,0,InpFastEMA,0,MODE_EMA,InpAppliedPrice);
   ExtSlowMaHandle=iMA(NULL,0,InpSlowEMA,0,MODE_EMA,InpAppliedPrice);

To:

   ExtFastMaHandle=iMA(Symbol1,0,InpFastEMA,0,MODE_EMA,InpAppliedPrice);
   ExtSlowMaHandle=iMA(Symbol1,0,InpSlowEMA,0,MODE_EMA,InpAppliedPrice);

The result is an error in the log: Not all data of ExtFastMaHandle is calculated (20057 bars). Error 4806

And it won't render indicator. I tried to remove check and return(0) from the code:

   if(calculated<rates_total)
     {
      Print("Not all data of ExtFastMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }

и

   if(calculated<rates_total)
     {
      Print("Not all data of ExtSlowMaHandle is calculated (",calculated," bars). Error ",GetLastError());
      return(0);
     }

I get in my logs:

Getting fast EMA is failed! Error 4807

Is it because of different number of bars on the chart with attached indicator and chart ima gets data from?

How to change the code optimally, MACD is calculated for the selected symbol, not for the symbol to which it is attached to the chart?

 
Sergey #:

Afternoon.

I am redoing a standard MACD:

Adding a symbol variable:

Changing

To:

The result is an error in the log: Not all data of ExtFastMaHandle is calculated (20057 bars). Error 4806

And it won't render indicator. I tried to remove check and return(0) from the code:

и

I get in my logs:

Getting fast EMA is failed! Error 4807

Is it because of different number of bars on the chart with attached indicator and chart ima gets data from?

How to change the code for the MACD to calculate the MACD for the selected symbol, not for the symbol to which it is attached to the chart?

Use help example: iMACD

 
Vladimir Karputov #:

Use the reference example: iMACD

Thank you!

 

Hi all!

I opened an account with FXCM, MT5 has no symbols for currency pairs and no charts, the link https://www.metatrader5.com/ru/news/1372 says that MT5 is customized with FXCM quotes

. Can you tell me where to start or tell me which broker uses FXCM quotes?


If I want to trade with FXCM I should download the brochure and make it as here.



Thanks in advance for the reply...

 

How to get code from WinAPI function 'GetLastError'? I want to delete a non-existing file with the WinAPI function DeleteFileW.

According toDeleteFileW' s help, if

... приложение пытается удалить несуществующий файл, функция DeleteFile завершается с ошибкой ERROR_FILE_NOT_FOUND. Если файл доступен только для чтения, функция завершается с ошибкой ERROR_ACCESS_DENIED

Code description 'ERROR_FILE_NOT_FOUND

ERROR_FILE_NOT_FOUND

2 (0x2)

The system cannot find the file specified.


That is, I should get a '2' when trying to delete a file that doesn't exist - but I get a '0'.


My script code:

//+------------------------------------------------------------------+
//|                                                   DeleteFile.mq5 |
//|                              Copyright © 2022, Vladimir Karputov |
//|                      https://www.mql5.com/en/users/barabashkakvn |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2022, Vladimir Karputov"
#property link      "https://www.mql5.com/en/users/barabashkakvn"
#property version   "1.00"
#property script_show_inputs
#include <WinAPI\errhandlingapi.mqh>
#include <WinAPI\fileapi.mqh>
//--- input parameters
input string   InpFileName="C:\\123.txt";
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   ResetLastError();
   int result=DeleteFileW(InpFileName);
   uint res=GetLastError();
   if(result==0)
      PrintFormat("DeleteFile failed (%d)",res);
   else
      PrintFormat("DeleteFile OK (%d)",res);
  }
//+------------------------------------------------------------------+

Execution result:

DeleteFile failed (0)
Files:
 
Good afternoon advise got caught up in the tricks of fraudsters passed registration at their direction on MT5 on me an account was registered at *** deposited the money, gave a little earning now can not withdraw, the site of the broker I did not pass registration, but wrote a letter to support, what do I do, how to withdraw their money advise please
 
val511 #:
Hello, advise me, I have fallen for the tricks of swindlers. I have registered at MT5 as they instructed, but I have registered the account at ***, I have made some money, and now I can not withdraw the money. I have not registered at the broker website, but I have sent an email to the support, what should I do, how to withdraw my money please advise me

MQL5.com has nothing to do with any brokers. MQL5.com support can only reply if you have deposited money into your MQL5 account(val511) here on the website.

 
I see, maybe you can give me some advice. I would really appreciate it.
 
val511 #:
I see, if you can give me any advice for me, I would be very grateful.

Write a statement to the police.