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
Home/ Questions/Q 621
In Process
viktorternovskiy
viktorternovskiy

viktorternovskiy

  • 3 Questions
  • 6 Answers
  • 0 Best Answers
  • 22 Points
View Profile
  • 0
viktorternovskiy
Asked: December 18, 20202020-12-18T09:19:41+00:00 2020-12-18T09:19:41+00:00

i can’t shift the array. Help.

  • 0

hello mql5 guru. I have such a kind of not the most difficult task but I have been fighting for a long time and do not want to go skiing)). there is an array with bid prices of a certain size. When you get the price, you need to write the new price to the beginning of the array, and move the previous values with the removal of the last ones while maintaining the size of the array. Tried and through arraycopy although it seems to be a bad method and through the loop I try to overwrite the values with an offset in the loop and does not work, knocks out the error: “Array out of range”. 
Here is one of the options as I try to do. Please advise what to correct or how to do it normally in a different way to solve the problem.
for(int i = BufferSize - 1; i > 0; i--) {

Buffer[i] = Buffer[i-1];
}

Buffer[0] = NewBidPrice;

  • 3 3 Answers
  • 0 Followers
  • 0
Answer
Share
  • Facebook

    3 Answers

    • Voted
    • Oldest
    • Recent
    1. viktorternovskiy

      viktorternovskiy

      • 3 Questions
      • 6 Answers
      • 0 Best Answers
      • 22 Points
      View Profile
      viktorternovskiy
      2020-12-18T09:19:54+00:00Added an answer on December 18, 2020 at 9:19 am

      Vladimir M.:

                 You can use arraycopy…

      It worked, thank you)) Although before that I also tried, but apparently I messed up somewhere. Later, I will probably rewrite it in a ring array, it will be more correct as far as I understand.

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

      rosomah

      • 0 Questions
      • 5 Answers
      • 0 Best Answers
      • 30 Points
      View Profile
      rosomah
      2020-12-22T07:03:20+00:00Added an answer on December 22, 2020 at 7:03 am

      Viktor Ternovskiy:

      hello mql5 guru. I have such a kind of not the most difficult task but I have been fighting for a long time and do not want to go skiing)). there is an array with bid prices of a certain size. When you get the price, you need to write the new price to the beginning of the array, and move the previous values with the removal of the last ones while maintaining the size of the array. Tried and through arraycopy although it seems to be a bad method and through the loop I try to overwrite the values with an offset in the loop and does not work, knocks out the error: “Array out of range”. 

      Here is one of the options as I try to do. Please advise what to correct or how to do it normally in a different way to solve the problem.

                 You can use arraycopy…
      ArrayCopy(
      Buffer, / / where to copy
      Buffer, / / from where we copy
      1, / / from which index we write to the receiver
      0, / / from which index we copy from the source
      bufferSize-1 // how many elements
      );
      Buffer[0]=NewBidPrice;

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

      nektomk

      • 2 Questions
      • 37 Answers
      • 0 Best Answers
      • 90 Points
      View Profile
      nektomk
      2020-12-18T09:19:45+00:00Added an answer on December 18, 2020 at 9:19 am

      Viktor Ternovskiy:

      hello mql5 guru. I have such a kind of not the most difficult task but I have been fighting for a long time and do not want to go skiing)). there is an array with bid prices of a certain size. When you get the price, you need to write the new price to the beginning of the array, and move the previous values with the removal of the last ones while maintaining the size of the array. Tried and through arraycopy although it seems to be a bad method and through the loop I try to overwrite the values with an offset in the loop and does not work, knocks out the error: “Array out of range”. 

      Here is one of the options as I try to do. Please advise what to correct or how to do it normally in a different way to solve the problem.

      use a cyclic buffer and you won’t need to copy anything

      • 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 504
    • Answers 2k
    • Posts 5
    • Comments 0
    • Best Answers 0
    • Users 676
    • Popular
    • Comments
    • Tags
    • forexcommunity

      Highlighting what’s important about questions & Answers on Discy Community!

      • 0 Comments
    • forexcommunity

      Introducing Keyboard Shortcuts, our first Labs feature

      • 0 Comments
    • forexcommunity

      Defining quality on Discy Engine — what a helpful answer ...

      • 0 Comments
    • forexcommunity

      Organizational and company accounts on Discy Engine the next step

      • 0 Comments
    • forexcommunity

      Hello world!

      • 0 Comments

    Users

    Geraldimaky

    Geraldimaky

    • 0 Questions
    • 0 Answers
    Jeffreytix

    Jeffreytix

    • 0 Questions
    • 0 Answers
    RobertFoeta

    RobertFoeta

    • 0 Questions
    • 0 Answers

    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