Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class to hold indicator values #23

Closed
janckerchen opened this issue May 2, 2017 · 0 comments · Fixed by #50
Closed

Class to hold indicator values #23

janckerchen opened this issue May 2, 2017 · 0 comments · Fixed by #50

Comments

@janckerchen
Copy link
Contributor

janckerchen commented May 2, 2017

I try to complete your jobs, it's very useful to hold indicator values in object-oriented style rather than MT4 indicator buffers.

But I have a differend idea for under data structure, I prefer the linked list rather than dynamic array because performance issue.

my ideas:

  1. class IndicatorBuffer is an abstract for data buffer implemented by double linked list. Implementation with Dynamic array (with ArrayResize) has performance issue. EA slow down rapidly as data grows because ArraySetAsSeries +ArrayResize will move data in memory.

  2. IndicatorBuffer always keep the list sorted according to bar time, the newer value insert to head. so there is a head pointer.

  3. when IndicatorBuffer grows to max_size, the limit of buffer capacity, IndicatorBuffer discard oldest value, so there is a tail pointer and double linked way.

  4. class Indicator is an abstract for multi-buffer indicator. It has a array of IndicatorBuffer and the length of array is determined by second parameter to constructor.

  5. Add(double) and Add(int) adaptive to data type and store in corresponding field of MqlParam. GetDouble(mode) and GetInt(mode) search list from head pointer and return right value and proper type.

  6. Passing indicator name as string to constructor, not enum defined in Indicator class, will keep flexibility and isolated.

  7. ToString() display last n values in buffers, default n=3.

Indicator.mq4 is a demo to demonstrate how to use the base class to implement a customize indicator, and show the value on MT4 chart. Place Indicator.mq4 in Indicators directory manually.
screenshot of parallels desktop 2017 5 2 18 07

pull request #22

@janckerchen janckerchen changed the title Hold indicator value in EA31337 class, I have implement it and create a pull request. Hold indicator value in EA31337 class, I have implemented it and create a pull request. May 2, 2017
@kenorb kenorb changed the title Hold indicator value in EA31337 class, I have implemented it and create a pull request. Class to hold indicator values Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants