거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Basic List - MetaTrader 5용 라이브러리

조회수:
3024
평가:
(13)
게시됨:
2020.06.20 06:54
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
/****************************************************************
BasicList
The List class template provides a basic container for storing an ordered list
 of basic data type objects.
For convenience, List also provides synonyms for stack operations,
 which make code that uses List for stacks more explicit without defining another class.
/**/


template<typename T>class BasicList
  {
public:
   //construction, destruction, initialization, and assignment
                     BasicList() {}
                     BasicList(BasicList&src) {Copy(items,src.items);}
                    ~BasicList() {}
   BasicList         operator=(BasicList&);
   //accessing
   T                 operator[](int i) {return Get(i);}
   T                 Get(int at) {int c=Count(); if(c>0&&at>=0&&at<c) {return items[at];} return NULL;}
   T                 First() {int c=Count(); if(c>0) {return items[0];} return NULL;}
   T                 Last() {int c=Count(); if(c>0) {return items[c-1];} return NULL;}
   //
   int               Count() {return ArraySize(items);}
   int               Find(T item) {int c=Count(); for(int i=0; i<c; i++) {if(item==items[i]) {return i;}} return -1;}
   void              Print() {int c=ArraySize(items); for(int i=0; i<c; i++) {PrintFormat("%d:%s",i,(string)items[i]);}}
   //adding
   void              operator+=(T item) {Append(item);}
   void              operator^=(T item) {Prepend(item);}
   void              Append(T item) {int c=ArraySize(items); IncreaseAt(c); items[c]=item;}
   void              Prepend(T item) {IncreaseAt(0); items[0]=item;}
   //removing
   void              operator-=(T item) {Remove(item);}
   void              operator~() {RemoveAll();}
   void              Remove(T item) {int f=Find(item); if(f>-1) {ReduceAt(f);}}
   void              RemoveLast() {ReduceAt(ArraySize(items)-1);}
   void              RemoveFirst() {ReduceAt(0);}
   void              RemoveAll() {ArrayFree(items);}
   //stack interface
   T                 Top() {return Last();}
   void              Push(T item) {Append(item);}
   T                 Pop() {T top=Top(); RemoveLast(); return top;}
protected:
   T                 items[];
   //service
   void              ReduceAt(int);
   void              IncreaseAt(int);
   void              Copy(T&dst[],T&src[]) {int c=ArraySize(src); ArrayResize(dst,c); for(int i=0; i<c; i++) {dst[i]=src[i];}}
  };


/****************************************************************
Mql does not allow to manipulate pointers and basic types in one template,
 so one generic list with pointer control is impossible for all built-in types and user types.
   This is why I made an independent template List for basic types.
Available operators:
   [index] Get,         eg. T var=list[3];
   += Append,           eg. list+=var;
   ^= Prepend,          eg. list^=var;
   -= Remove,           eg. list-=var;
   ~ RemoveAll,         eg. ~list;
   = Copy list,         eg. T listA=listB; //A-new,B-existing
/**/


/****************************************************************
Example of BasicList usage
/****************************************************************/
void OnStart()
  {
   BasicList<string>list;
   /**/
   list+="worry";                //append
   list+="be happy";             //append
   list.Print();                 //see output
   /**/
     {string s; for(int i=0; i<10; i++) {s+="-";} Print(s);}
   /**/
   list^="don't";                //remove
   BasicList<string>list2=list;  //copy list
   list2.Print();                //see output
   /**/
     {string s; for(int i=0; i<10; i++) {s+="-";} Print(s);}
   /**/
   ~list;                        //clean list
   Print(list2.Pop());           //pop
   /**/
     {string s; for(int i=0; i<10; i++) {s+="-";} Print(s);}
   /**/
   list2.Print();                //see output
  }
/****************************************************************
Output:
/**
   0:worry
   1:be happy
   ----------
   0:don't
   1:worry
   2:be happy
   ----------
   be happy
   ----------
   0:don't
   1:worry
/**/



    Object List Object List

    A basic container for storing an ordered list of objects.

    M1MA indicator M1MA indicator

    M1-based Moving Average. It gives more adequate estimation of average price per bar compared to any standard price type (close, open, median, typical, weighted, etc).

    custom trail-stop by MA - update 4 custom trail-stop by MA - update 4

    this is my first try at creating an EA from ground up - update 4

    Pan PrizMA CD Phase Sin leverage 72 Pan PrizMA CD Phase Sin leverage 72

    Calculates the phase and amplitude of the expected wave