Sign Up

Have an account? Sign In Now

Sign In

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

First independent community of traders

First independent community of traders Logo First independent community of traders Logo

First independent community of traders Navigation

  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • Buy Theme
  • Home
  • About Us
  • Blog
  • Contact Us

Share your knowledge in the forex community!

Our community is a completely independent place for communication between forex traders and software developers for trading platforms Metatrader 4 and Metatrader 5

Create A New Account
Home/ Questions/Q 730
In Process
traderchik
traderchik

traderchik

  • 1 Question
  • 4 Answers
  • 0 Best Answers
  • 20 Points
View Profile
  • 0
traderchik
Asked: December 18, 20202020-12-18T09:43:48+00:00 2020-12-18T09:43:48+00:00

program file Experts….THE PATH TO THE EXPERT..CandlePatterns.ex5 read error

  • 0

 Why you may receive an error with this content?
2020.06.10 18:14:59.111 program file ExpertsmyBots oTradepatternsTradingmyIndicatorsPACandlePatterns.ex5 read error Here are 2 functions that explain the question:
//==================================================================================================================================================================================================
// Creates a handle of the candlepatterns indicator on the specified index. ===================================================================================================================================
int Signal :: createCandlePatternsHandle(const int bufferIndex, const int shift, ENUM_TIMEFRAMES tf = PERIOD_CURRENT) {
  int handle = iCustom(_Symbol, _Period, "CandlePatterns", true, true, true, 30);
  Print("_LastError = " + _LastError);
  Print("handle = " + handle);
//  return (handle != INVALID_HANDLE) ? true : false;
  return handle;
}
//==================================================================================================================================================================================================
// Returns the values of the candlepatterns indicator at the specified index. ==============================================================================================================================
double Signal :: getCandlePatternsValue(const int bufferIndex, const int shift, ENUM_TIMEFRAMES tf = PERIOD_CURRENT) {
  double havingPattern[];
  ArrayResize(havingPattern, 1);
  int handle = createCandlePatternsHandle(bufferIndex, shift, tf);
  ResetLastError();
  int res = CopyBuffer(handle, bufferIndex, shift, 1, havingPattern);
  Print("res = " + res);
  return havingPattern[0];
}
All parameters of the indicator are used by default. Accordingly, in mqlparam, I put only the name of the indicator in the first index of the array. Nothing else. After creating the indicator handle, I set a breakpoint to find out the cause of the error. I attach the screen.
In the debugger window, you can see that the indicator handle is 1. Accordingly, the handle is created without errors because there is no -1 error.
The types of all passed variables correspond to those required by the signature of the copybuffer function()
The buffer number was set to 0..
How IS IT that some kind of reading error occurs? After all, the indicator is working. The handle is created. The error is related to the copybuffer () function, as I understand it. But how can this be? How to check it?

  • 9 9 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    9 Answers

    • Voted
    • Oldest
    • Recent
    1. traderchik

      traderchik

      • 1 Question
      • 4 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      traderchik
      2020-12-18T09:44:50+00:00Added an answer on December 18, 2020 at 9:44 am

      Aleksey Mavrin:

      Already interesting) you would make a delay so that the calculations are all accurate, and the error is output at each iteration. I’ll check later.

      Still confuses that in an array exact 0.0 though it is not initialized by it, and it not 4-ka, there it seems as usually garbage.

      in general, i came up with a slightly different test. to make it easier to check just what i threw a script with the following content:

      //+------------------------------------------------------------------+
      //|                                                      forOnce.mq5 |
      //|                                                              hoz |
      //|                                                                  |
      //+------------------------------------------------------------------+
      #property copyright "hoz"
      #property link      ""
      #property version   "1.00"

      int       candlePatternsHandle = -1;
      int       copied;
      double    havingPattern[1];

      //+------------------------------------------------------------------+
      //| Script program start function                                    |
      //+------------------------------------------------------------------+
      void OnStart() {
        candlePatternsHandle = iCustom(_Symbol, _Period, "CandlePatterns");
        Print(__FUNCTION__ + ":: _candlePatternsHandle = " + candlePatternsHandle);
        while (candlePatternsHandle < 0) {
          Print(__FUNCTION__ + ":: candlePatternsHandle = " + candlePatternsHandle);
          Sleep(5000);
        }
        
        for (int i = 0; i < 5; i++) {
        copied = CopyBuffer(candlePatternsHandle, 1, i, 1, havingPattern);
        Print(__FUNCTION__ + ":: copied = " + copied);
      //    Print(__FUNCTION__ + ":: havingPattern[" + i + "] = " + havingPattern[0] + " ; i = " + i);
          if (havingPattern[0] != EMPTY_VALUE) {
      //      Print(__FUNCTION__ + ":: havingPattern[0] != EMPTY_VALUE");
      //      Print(__FUNCTION__ + ":: havingPattern[", + i + "] = " + DoubleToString(havingPattern[0]));
          }
        }

      }

      in this case, i want to get the value of the 1st buffer of the indicator using the copybuffer () function. It doesn’t work. In the log I see:

      2020.06.12 20:53:58.161 forOnce (GBPUSD,W1)     OnStart:: _candlePatternsHandle = 10
      2020.06.12 20:53:58.261 forOnce (GBPUSD,W1)     OnStart:: copied = -1
      2020.06.12 20:53:58.261 forOnce (GBPUSD,W1)     OnStart:: copied = -1
      2020.06.12 20:53:58.261 forOnce (GBPUSD,W1)     OnStart:: copied = -1
      2020.06.12 20:53:58.261 forOnce (GBPUSD,W1)     OnStart:: copied = -1
      2020.06.12 20:53:58.261 forOnce (GBPUSD,W1)     OnStart:: copied = -1

      If I change 1 to 0, i.e. I want to get the value of the 0th buffer, then everything turns out:

      2020.06.12 20:56:48.967 forOnce (GBPUSD,W1)     OnStart:: _candlePatternsHandle = 10
      2020.06.12 20:56:49.068 forOnce (GBPUSD,W1)     OnStart:: copied = 1
      2020.06.12 20:56:49.068 forOnce (GBPUSD,W1)     OnStart:: copied = 1
      2020.06.12 20:56:49.068 forOnce (GBPUSD,W1)     OnStart:: copied = 1
      2020.06.12 20:56:49.068 forOnce (GBPUSD,W1)     OnStart:: copied = 1
      2020.06.12 20:56:49.068 forOnce (GBPUSD,W1)     OnStart:: copied = 1

      By the way, when I get data from the 0th buffer, everything is clear. The desired bar is located, with a pattern that displays the indicator. The opening price of this bar is printed (if I comment out the line for this in the script). In fact, all thoughts converged on the fact that something is wrong only with the copybuffer () function, or with the indicator. With the function copybuffer (), it is unlikely that something is wrong because it is used by everyone and not for the first year. It means something with a turkey.

       But it is interesting that both buffers, in fact, are written almost by copy-paste from one another with a change in only one condition. That’s what’s interesting. How to check this point is very interesting..

      The script and the indicator, which turned off the rendering and threw all the inclusions into it, I attach. If it is more convenient, I can attach it to libraries. They are compact. But the code is then read more conveniently because there is no excess in the context of logic.

      In fact, I have laid out an indicator and a script that can read data from the bfers of this indicator. But data is read only from 1 buffer (0th index). the other buffer is not read. That’s really interesting. It seems that the terminal drives. I have it running portably. The code has already been broken not once.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. alexeyvik

      alexeyvik

      • 1 Question
      • 75 Answers
      • 0 Best Answers
      • 182 Points
      View Profile
      alexeyvik
      2020-12-18T09:44:41+00:00Added an answer on December 18, 2020 at 9:44 am

      Victor demikhov:

      @Aleksey Mavrin you are right about this. I’ll take it into account. But, in general, the transfer of initialization to OnInit() did not give anything to the current situation. I wrote a test bot to test how data is read from my turkey. Here it is:

      Well. Nothing is copied from the indicator buffer. Neither from the 1st nor from the 1st index. Here for the first one I gave the code above. In the log I see the following:

      Is there something wrong with the indicator? What can influence this? The indicator is elementary..

      And how do you want to change in this cycle

        for (int i = 0; i < 119; i++) {
          copied = CopyBuffer(candlePatternsHandle, 1, i, 1, havingPattern);
          Print(__FUNCTION__ + ":: copied = " + copied);
          if (havingPattern[0] != EMPTY_VALUE) {
            Print(__FUNCTION__ + ":: havingPattern[0] != EMPTY_VALUE");
            Print(__FUNCTION__ + ":: havingPattern[", + i + "] = " + DoubleToString(havingPattern[0]));
          }

      the value of the array in the null index???

      ps; sorry, not to change, but to read a different value than it is there.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    3. alex_all

      alex_all

      • 0 Questions
      • 15 Answers
      • 0 Best Answers
      • 50 Points
      View Profile
      alex_all
      2020-12-22T07:01:27+00:00Added an answer on December 22, 2020 at 7:01 am

      Victor demikhov:

      @Aleksey Mavrin you are right about this. I’ll take it into account. But, in general, the transfer of initialization to OnInit() did not give anything to the current situation. I wrote a test bot to test how data is read from my turkey. Here it is:

      Well. Nothing is copied from the indicator buffer. Neither from the 1st nor from the 1st index. Here for the first one I gave the code above. In the log I see the following:

      Is there something wrong with the indicator? What can influence this? The indicator is elementary..

      Already interesting) you would make a delay so that the calculations are all accurate, and the error is output at each iteration. I’ll check later.

      Still confuses that in an array exact 0.0 though it is not initialized by it, and it not 4-ka, there it seems as usually garbage.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    4. traderchik

      traderchik

      • 1 Question
      • 4 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      traderchik
      2020-12-18T09:44:32+00:00Added an answer on December 18, 2020 at 9:44 am

      Ihor Herasko:

      THIS Happens if the buffer index is specified incorrectly. Check the bufferindex value passed to getcandlepatternsvalue and see if the indicator has a buffer with this index. It’s clearly not there.

      No. The indicator has only 2 buffers now. The buffer indexes are 0 and 1. Of course, they are present in the indicator. This can be seen with the naked eye in the attached file (indicator)

      Ihor Herasko:

      PS And why is the topic in the section for MQL4? I think we should move it to the section for MQL5.

      I also thought about it today. But I didn’t want to pull the moderators for this.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    5. scriptong

      scriptong

      • 2 Questions
      • 38 Answers
      • 0 Best Answers
      • 96 Points
      View Profile
      scriptong
      2020-12-18T09:44:24+00:00Added an answer on December 18, 2020 at 9:44 am

      Victor demikhov:
       So I ask how it can be that there is no way to get data. 

      THIS Happens if the buffer index is specified incorrectly. Check the bufferindex value passed to getcandlepatternsvalue and see if the indicator has a buffer with this index. It’s clearly not there.

      PS And why is the topic in the section for MQL4? I think we should move it to the section for MQL5.

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    6. alex_all

      alex_all

      • 0 Questions
      • 15 Answers
      • 0 Best Answers
      • 50 Points
      View Profile
      alex_all
      2020-12-22T07:01:27+00:00Added an answer on December 22, 2020 at 7:01 am

      Victor demikhov:

      How do I check it? I see that there is an error. The types of parameters are correct. Why the error is a question..

      getlasterror to start

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    7. traderchik

      traderchik

      • 1 Question
      • 4 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      traderchik
      2020-12-18T09:44:12+00:00Added an answer on December 18, 2020 at 9:44 am

      Aleksey Mavrin:

      did you check the error after issuing -1 ?

      How do I check it? I see that there is an error. The types of parameters are correct. Why the error is a question..

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    8. alex_all

      alex_all

      • 0 Questions
      • 15 Answers
      • 0 Best Answers
      • 50 Points
      View Profile
      alex_all
      2020-12-22T07:01:27+00:00Added an answer on December 22, 2020 at 7:01 am

      Victor demikhov:

      They’re lying there. I understood the first moment. For some reason, if the indicator is not in the Indicators folder itself, but deeper in the hierarchy, then an error occurs when reading the indicator. In my case, the path was like this:

      I move the indicator to the root because there are not many options and the reading error no longer appears. But there is still one more point.

      All the same, the data from the indicator buffer is not read by the copybuffer () function. copybuffer () returns -1 permanently. Although, the indicator handle is 10 and there are no errors at all when creating the indicator handle..

      the slash must be double in file paths  \

      why do you constantly create an indicator? the handle should be saved once.

      otherwise, the code is incomplete to suggest. getcandlepatternsvalue with which pairs you call.

      And maybe there’s a mistake in the turkey

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    9. traderchik

      traderchik

      • 1 Question
      • 4 Answers
      • 0 Best Answers
      • 20 Points
      View Profile
      traderchik
      2020-12-18T09:43:56+00:00Added an answer on December 18, 2020 at 9:43 am

      Aleksey Mavrin:
      Indicators should be in the Indicators folder, not Experts

      They’re lying there. I understood the first moment. For some reason, if the indicator is not in the Indicators folder itself, but deeper in the hierarchy, then an error occurs when reading the indicator. In my case, the path was like this:

      Indicators/myIndicators/PA

      I move the indicator to the root because there are not many options and the reading error no longer appears. But there is still one more point.

      All the same, the data from the indicator buffer is not read by the copybuffer () function. copybuffer () returns -1 permanently. Although, the indicator handle is 10 and there are no errors at all when creating the indicator handle..

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    Leave an answer

    Leave an answer
    Cancel reply

    Browse

    Sidebar

    Ask A Question

    Stats

    • Questions 514
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 921
    • Popular
    • Answers
    • Tags
      • On: December 18, 2020
      • Answers: 16

      How to allow trading at certain times

      • On: December 29, 2020
      • Answers: 16

      Example of implementing the OOP pattern Abstract Factory using MQL5 ...

      • On: December 18, 2020
      • Answers: 15

      EMA with a different formula

      • On: December 29, 2020
      • Answers: 15

      Invitation for algo traders.

      • On: December 29, 2020
      • Answers: 14

      Dear Programmers, do not pass by, help fix the error!

    • atma1
      atma1 added an answer Added activation. Thanks. April 8, 2021 at 6:54 am
    • iks_
      iks_ added an answer Atma1: Good day, dear colleagues. Yesterday I updated VMware to… April 8, 2021 at 6:54 am
    • renat
      renat added an answer Atma1: Good day, dear colleagues. Yesterday I updated VMware to… April 8, 2021 at 6:54 am
    • mvs
      mvs added an answer Renat Fatkhullin: You can not immediately send the received data,… April 8, 2021 at 6:53 am
    • anton_m
      anton_m added an answer Renat Fatkhullin: How much data do you read? You can… April 8, 2021 at 6:53 am
    analytics british company computer developers django employee employer english facebook french google interview javascript language life php proforexea programmer programs pro vsa salary university

    Users

    atma1

    atma1

    • 1 Question
    • 1 Answer
    s22aa

    s22aa

    • 1 Question
    • 1 Answer
    areedbreen

    areedbreen

    • 1 Question
    • 1 Answer

    Footer

    First independent community of traders

    About

    An independent community of forex traders. This is where traders communicate. You can ask your questions and you will receive an answer to your question.
    • Terms of Use
    • Privacy Policy
    • Cookie Policy
    • Knowledge Base
    • Support

    © 2021 Forexcommunity.net. All Rights Reserved