EA31337/EA31337-classes

Class to hold indicator values

janckerchen opened this issue · 0 comments

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