How to empty a buffer, or at least restrict its length
Results 1 to 3 of 3

Thread: How to empty a buffer, or at least restrict its length

  1. #1
    I am writing a multi time frame indior which shows dots placed in a lineup in a separate window. I would like to restrict the number of dots to 3 ( for displaying a 15 min bars on a 5 min chart)

    The appropriate section of code I am using is that.

    Int start()
    {
    int I,limit;


    restrict = (TimeFrame1/Period())-1;
    for (I=limitation; igt;= 0; I--)

    etc

    However, what happens is that following another 5 min moves, the number of bars now extends up to 4 months, and increases after each 5 mins.
    What is the procedure for restricting the number of bars to the 3?

  2. #2
    I can only presume your naming conventions you did not post your codes.

    Assuming you called your buffer as buffer1[]
    and assuming that you did not change the buffer's empty worth to another person.

    All you've got to do is add another line to the end of your start function.
    Inserted Code buffer1#91;3 #93; = EMPTY_VALUE; this way it always have just buffer1[0], buffer1[1] and buffer1[2] using worth.

    Believe about it. Every time a new candle has been opened, buffer1[two] will become buffer1[3] along with also the stated code will give a worth of nothing removing the square to it since it's expired.

    To be even stronger, you can have '3' as a configurable value by incorporating another extern variable.
    Inserted Code extern int Max_Dots_Num = 3; and at the end of your start function, use the following code
    Inserted Code buffer1#91;Max_Dots_Num#93; = EMPTY_VALUE; hope this helps.

    regards,
    Zen

  3. #3
    Hi Zen,
    Thanks for coming back to me. I am gradually teaching myself programming that is MT4by asking my questions, and trying to invent the answer in code. Moving forward with a process of trial and error.

    Slightly More information. I've adapted a MACD_CCI time period indior to reveal TRIX phases. This mimics a colour macd histogram, with buffers containing values such as positive and rising, positive and falling, falling and negative and rising and negative.

    So far so great. It is the nature of time period indiors the last bar on the higher time frame repaints on the time frame that is lower before the higher time frame pub is closed. This is known. So I want to change the buffer mapping so the arrow buffers show a pub in advance and once the higher time frame pub is done, and the chart moves the bars are shown by the squares. (The change from positive to negative is shown by the color change anyhow, so I'm just currently dupliing that with arrows.)

    And this is where I'm stuck. Can you get me? As a film says more than a million words (allegedly) I've done a bit Photoshop job to show what I mean.


    Edit added afterwards:
    All fixed now. The answer came to me while I do something. Funny old world...
    https://www.nigeriaforextrading.com/...3606601257.mq4
    https://www.nigeriaforextrading.com/...5533851138.ex4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.