Shin Joo Young: Can I define these fuctions in mql4 or mql5?
No but you can come close.
- If the data types are unique, overloaded function names and/or default arguments
bool SetBuffer(INDEX i,PRICE& b[], Wingding ac,string lab,PRICE ev=EMPTY_VALUE){ SetIndexArrow(i,ac); return SetBuffer(i, b, lab, ev); } bool SetBuffer(INDEX i,PRICE& b[], Wingding ac, PRICE ev=EMPTY_VALUE){ SetIndexArrow(i,ac); return SetBuffer(i, b, ev); } bool SetBuffer(INDEX i,PRICE& b[], ENUM_DRAW_TYPE dt, ENUM_LINE_STYLE ls, COUNT wid, string lab,PRICE ev=EMPTY_VALUE){ SetIndexStyle(i, dt, ls, wid); return SetBuffer(i, b, lab, ev); } bool SetBuffer(INDEX i,PRICE& b[], ENUM_DRAW_TYPE dt, ENUM_LINE_STYLE ls=EMPTY, COUNT wid=EMPTY, PRICE ev=EMPTY_VALUE){ SetIndexStyle(i, dt, ls, wid); return SetBuffer(i, b, ev); } bool SetBuffer(INDEX i,PRICE& b[], ENUM_DRAW_TYPE dt, ENUM_LINE_STYLE ls, string lab,PRICE ev=EMPTY_VALUE){ SetIndexStyle(i, dt, ls); return SetBuffer(i, b, lab, ev); } bool SetBuffer(INDEX i,PRICE& b[], ENUM_DRAW_TYPE dt, COUNT wid, string lab,PRICE ev=EMPTY_VALUE){ SetIndexStyle(i, dt, EMPTY, wid); return SetBuffer(i, b, lab, ev); } bool SetBuffer(INDEX i,PRICE& b[], string lab,PRICE ev=EMPTY_VALUE){ SetIndexLabel(i, lab); return SetBuffer(i, b, ev); } bool SetBuffer(INDEX i,PRICE& b[], PRICE ev=EMPTY_VALUE){ SetIndexEmptyValue(i, ev); return SetIndexBuffer(i, b) && ArraySetAsSeries(b, true); } : PRICE bNL[]; #define INDICATOR_LABEL1 StringFormat("CBL%i", BarsBack) #define INDICATOR_BUFFER1 bNL,INDICATOR_LABEL1 PRICE bNLupE[]; #property indicator_type4 DRAW_LINE // Bug 1090 must set. #property indicator_color4 Aqua #define EMPTY_VALUE_UP_E PRICE_MIN #define INDICATOR_BUFFER4 bNLupE,LN_STY_E,NO_DATA,EMPTY_VALUE_UP_E : if(!SetBuffer(1-1,INDICATOR_BUFFER1) ){ if(!SetBuffer(4-1,INDICATOR_BUFFER4) ){
- With OOP, Method cascading - Wikipedia
class T{public: T* set(string s){ ... return &this; } T* set(int i}{ ... return &this; } ...}; T t; t.set("value").set(2);
whroeder1:
No but you can come close.
- If the data types are unique, overloaded function names and/or default arguments
- With OOP, Method cascading - Wikipedia
whroeder nailed it. The easiest way is to use method chaining.
class String { string m_string; public: String* concat(string str) { m_string+=str; return &this; } string Str() { return m_string; } }; void OnStart() { String s; s.concat("Hello ").concat("world, ").concat("this is ").concat("an example."); Print(s.Str()); }
nicholish en:
Too much code for simple functionality. I have a better one, which I'll post here once it's complete. https://www.mql5.com/en/forum/352694#comment_18592787
whroeder nailed it. The easiest way is to use method chaining.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can We define functions that like
Print("Hello","World"," !");
http://www.equestionanswers.com/c/variadic-function.php
Can I define these fuctions in mql4 or mql5?