Correct My Code

MQL5 Experts

Specification

Hi Devs, thanks for your good works.

I have a code that worked perfectly for me on mt4. I tried converting my code to mt5 but the kernel32.dll aspect of the code is not giving the same result.

Please help me check what I am doing wrong, make corrections tell me what i did wrong.

Budget is $30

Thanks



//+------------------------------------------------------------------+

//|                                                    K32dllmt5.mq5 |

//|                        Copyright 2021, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2021, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict



#import   "kernel32.dll"

int CreateFileW(string Filename,int AccessMode,int ShareMode,int PassAsZero,int CreationMode,int FlagsAndAttributes,int AlsoPassAsZero);

int GetFileSize(int FileHandle,int PassAsZero);

int SetFilePointer(int FileHandle,int Distance,int &PassAsZero[],int FromPosition);

int ReadFile(int FileHandle,uchar &BufferPtr[],int BufferLength,int  &BytesRead[],int PassAsZero);

int CloseHandle(int FileHandle);

#import





double data[][2];



int BytesToRead;

string    datapath;

string    result;



union Price

  {

   uchar             buffer[8];

   double            close;

  };

Price     m_price;

//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

    string account_server=AccountInfoString(3);

    datapath=TerminalInfoString(3)+"\\history\\"

               +account_server+"\\"+Symbol()+"240"+".hst";

    ReadFileHst(datapath);

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {



Comment("Bytes To Read: ", BytesToRead);





   

  }

//+------------------------------------------------------------------+



//+------------------------------------------------------------------+

void ReadFileHst(string FileName)

  {

   int       j=0;;

   string    strFileContents;

   int       Handle;

   int       LogFileSize;

   int       movehigh[1]= {0};

   uchar     buffer[];

   int       nNumberOfBytesToRead;

   int       read[1]= {0};

   int       i;

   double    mm;

//----- -----

   strFileContents="";

   Handle=CreateFileW(FileName,(int)0x80000000,3,0,3,0,0);

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

   if(Handle==-1)

     {

      Comment("");

      return;

     }

   LogFileSize=GetFileSize(Handle,0);

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

   if(LogFileSize<=0)

     {

      return;

     }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

   if((LogFileSize-148)/60==BytesToRead)

     {

      return;

     }

   SetFilePointer(Handle,148,movehigh,0);

   BytesToRead=(LogFileSize-148)/60;

   ArrayResize(data,BytesToRead,0);

   nNumberOfBytesToRead=60;

   ArrayResize(buffer,60,0);

   for(i=0; i<BytesToRead; i=i+1)

      //+------------------------------------------------------------------+

      //|                                                                  |

      //+------------------------------------------------------------------+

     {

      ReadFile(Handle,buffer,nNumberOfBytesToRead,read,NULL);

      if(read[0]==nNumberOfBytesToRead)

        {

         result=StringFormat("0x%02x%02x%02x%02x%02x%02x%02x%02x",buffer[7],buffer[6],buffer[5],buffer[4],buffer[3],buffer[2],buffer[1],buffer[0]);



         m_price.buffer[0] = buffer[32];

         m_price.buffer[1] = buffer[33];

         m_price.buffer[2] = buffer[34];

         m_price.buffer[3] = buffer[35];

         m_price.buffer[4] = buffer[36];

         m_price.buffer[5] = buffer[37];

         m_price.buffer[6] = buffer[38];

         m_price.buffer[7] = buffer[39];

         mm=m_price.close;

         data[j][0] = StringToDouble(result);

         data[j][1] = mm;

         j=j+1;

         strFileContents=TimeToString(StringToTime(result),3)+" "+DoubleToString(mm,8);

        }

      else

        {

         CloseHandle(Handle);

         return;

        }

     }

   CloseHandle(Handle);

   strFileContents=DoubleToString(data[j-1][0],3)+" "+DoubleToString(data[j-1][1],8)+" "+DoubleToString(data[j-2][1],3)+" "+DoubleToString(data[j-2][1],8);

   result=strFileContents;

  }

Files:

JPG
MT4.jpg
45.4 Kb
JPG
MT5.jpg
181.5 Kb

Responded

1
Developer 1
Rating
(131)
Projects
152
22%
Arbitration
5
0% / 60%
Overdue
4
3%
Loaded
2
Developer 2
Rating
(8)
Projects
18
17%
Arbitration
3
67% / 0%
Overdue
0
Free
3
Developer 3
Rating
(57)
Projects
72
22%
Arbitration
13
46% / 15%
Overdue
5
7%
Free
4
Developer 4
Rating
(42)
Projects
62
8%
Arbitration
12
58% / 42%
Overdue
1
2%
Free
Similar orders
I want a skillful and experience deverloper to apply for this job. The strategy for the EA is Two Exponential Moving Average CROSSOVER strategy. The EA should work on any Timeframe. I want the EA to trade the direction of the CROSSOVER, the EA should open a BUY or SELL trades automatic when the Two Exponential Moving Average crossover. *(10EMA) ABOVE (23EMA) = BUY Trades *(10EMA) BELOW (23EMA) = SELL Trades BUY
MACD EA 50+ USD
Hello Freelancers, I am seeking an experienced developer to create an Expert Advisor (EA) for MetaTrader 5 (MT5). The EA will be based on the MACD indicator and should adhere to the following specifications: EA Requirements: Trading Logic: 1. Long Trades: • Entry: Open a long trade when the MACD line crosses above the signal line below the zero level. • Exit: Close the long trade when the signal line crosses above
EA Configuration. FIBO ------------------------------------------------------------------- Magic: 123456 Stop: Real or Virtual Order: Pending / CLOSE / price== LOT Description: 0.01 ------------------------------------------------------------------- STOP: -0.25 ------------------------------------------------------------------- ENT_1: 1.00 Lot_1: 0.01 ENT_2: 0.50 Lot_2: 0.01 ENT_3: 1.00 Lot_3: 0.01
Hi I'm looking for a professional programmer to modify my EA the EA send signal alert to telegram and screen shot of the chart patterns my EA is dased to the harmonic pattern but I want to see on the screen shot the pattern of the harmonic pattern and on the chat as well
Hello I need create simple trend first candle session EA. Ea wait for first M5/M15/M30/H1 (all possible timeframes to choose) candle at asian, european and NYC session and open buy/sell stop order above (in long situation) or below (in short situation) x points from highest/lowest point of the first candle. + trailing stop loss stop loss take profit breakeven magic key
Hello Guys ! Looking for a developer to create a EA for my Buy and Sell No repaint indicator. I only have the EX4 indicator file and I want the EA to take trades according to the Buy and sells signals generated by the Indicator. Here are some inputs I want for the EA: - Trailing stop - TP and SL ( in pips ) - Entries, TP and SL ( based on opposite signals arrow ) - Daily target ( in Dollars $ or % ) - Trading hours -
I need a robot that copies the orders sent in the telegram group to MT4 or MT5 so that I can configure the parameters. I would like it to have functions so I can enter and exit negotiations according to my configuration parameters
i need to delegate this job. XAUUSD H4 MT4 i have an ea with source code with smc, fvg, orderblocks and fibonacci, i need to fix somethings and add some features for live markets, any new ideas are accepted, i need also a 4 years backtest report (of metatrader 4). if you have good price and feedbacks and you want work for me also for new jobs apply for this job it's not urgent i need only a good price
Hello, I hope you are well. I have an alert/s that I would like to provide buy and sell orders. The alerts are named *ENTRY* and *EXIT*, so the EA will know what to do. I would like the EA to have the following parameters: 1. Select the number of trades per currency pair 2. Time to trade: Time to start trading to time to end trading - I would like 4 different times to be able to be entered 3. Option to choose which
Order Manager 30 - 60 USD
I am looking for a programmer to develop an Expert Advisor (EA) for order management, which will be used alongside simpler EAs. This EA should include advanced functionalities for efficient and personalized management. **Key Features:** 1. **Comprehensive Information Panel:** - **Order Visualization:** Display all open orders by currency pair, including short and long positions. - **Font Resizing Option:** Allow

Project information

Budget
30+ USD
For the developer
27 USD