• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 11:28pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:28pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Restrict recalculate on semafor dots 0 replies

Close at stop - how to avoid/restrict?! 0 replies

Help - How do I restrict indy to lower TF? 9 replies

At Least: 30~60 PIPS Daily / Pair At Least * All Pairs 20 replies

Draw a certain-length line 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 4
Attachments: How to empty a buffer, or at least restrict its length
Exit Attachments
Tags: How to empty a buffer, or at least restrict its length
Cancel

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

  • Post #1
  • Quote
  • First Post: Aug 20, 2009 6:31am Aug 20, 2009 6:31am
  •  Royston
  • | Joined Nov 2008 | Status: Member | 280 Posts
I am writing a multi time frame indicator which shows dots placed in a line in a separate window. I want to restrict the number of dots to 3 ( for displaying a 15 min bars on a 5 min chart)

The relevant section of code I am using is this.

int start()
{
int i,limit;


limit = (TimeFrame1/Period())-1;
for (i=limit; i>= 0; i--)

etc etc

However, what happens is that after another 5 min passes, the number of bars now goes up to 4, and increases after each 5 mins.
What is the process for restricting the number of bars to the original 3?
Attached Image (click to enlarge)
Click to Enlarge

Name: 0908201127 restricting 5 min squares.jpg
Size: 52 KB
  • Post #2
  • Quote
  • Aug 20, 2009 7:35am Aug 20, 2009 7:35am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
you didn't post your codes so I can only assume your naming conventions.

assuming you named your buffer as buffer1[]
and assuming you did not change the buffer's empty value to something else.

all you have to do is add the following line to the end of your start function.
Inserted Code
buffer1[3] = EMPTY_VALUE;
that way it constantly have only buffer1[0], buffer1[1] and buffer1[2] having values.

think about it. when a new candle is opened, buffer1[2] will become buffer1[3] and the above stated code will give it a value of nothing thereby removing the square since it has "expired".

to be even more robust, you can have '3' as a configurable value by adding 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[Max_Dots_Num] = EMPTY_VALUE;
hope this helps.

regards,
Zen
Programming for a better future.
 
 
  • Post #3
  • Quote
  • Last Post: Edited Aug 21, 2009 6:09am Aug 20, 2009 12:37pm | Edited Aug 21, 2009 6:09am
  •  Royston
  • | Joined Nov 2008 | Status: Member | 280 Posts
Hi Zen,
Thanks for coming back to me. I am gradually teaching myself MT4 programming, mainly by asking myself questions, and then trying to formulate the answer in code. Moving forward by a process of trial and error.

A little more information. I have adapted a MACD_CCI multi time frame indicator to show me TRIX phases. This mimics a multi colour macd histogram, with buffers containing values for positive and rising, positive and falling, negative and rising and negative and falling.

So far so good. It is the nature of multi time frame indicators that the last bar on the higher time frame always repaints on the lower time frame until the higher time frame bar is closed. This is understood. So I now want to alter the buffer mapping so that the arrow buffers show a "bar in progress" and then, once the higher time frame bar is complete, and the chart moves forward, the completed bars are shown by the squares. (The change from positive to negative is shown by the colour change anyway, so I am only currently duplicating that with arrows.)

And this is where I am stuck. Can you get me any further? As a picture says more than a thousand words (allegedly) I have done a little Photoshop job to show what I mean.


Edit added later:
All fixed now. The answer came to me in a flash while I was doing something completely different. Funny old world...
Attached Image (click to enlarge)
Click to Enlarge

Name: 0908201726 higher time frame change.jpg
Size: 60 KB
Attached File(s)
File Type: mq4 Trix MTF meter roy 01.mq4   4 KB | 164 downloads
File Type: ex4 smSuper TRIX_v1.ex4   11 KB | 141 downloads
 
 
  • Platform Tech
  • /
  • How to empty a buffer, or at least restrict its length
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023