have you tried _Period
have you tried _Period
I have previously had _Period (from mt4) but in MQL5 it returns an integer while Period() returns an enum.
Are you sure about that ?
Maybe
double calcPrice(ENUM_TIMEFRAMES per=PERIOD_CURRENT, int calc=0) { .. } ... ENUM_TIMEFRAMES timeframe = Period(); double chckPrice() { ... double v = calcPrice(timeframe,k); // it's line 3457, at 37 is the P of Period() ... }
![Documentation on MQL5: Standard Library / Graphic Objects / Control Objects / CChartObjectSubChart / Period Documentation on MQL5: Standard Library / Graphic Objects / Control Objects / CChartObjectSubChart / Period](https://c.mql5.com/36/19/documentation-on-mql5-standard__3.png)
- www.mql5.com
That's what my reference to mql5 tells me:
double v = calcPrice((ENUM_TIMEFRAME)Period(),k); // it's line 3457, at 37 is the P of Period()
or
double v = calcPrice(PERIOD_CURRENT,k); // it's line 3457, at 37 is the P of Period()
try these ones.
or
try these ones.
I tried the last one and that satisfies the compiler - could have thought of that myself :(
Yeah err ... your snippets returns the ENUM as an integer ; apparently indicators strictly need it as a ENUM.
It clearly states:
Period (Get Method)
Gets the value of "Period" property.
Return Value
Value of "Period" property of the object assigned to the class instance. If there is no object assigned, it returns 0.
Hmm - the reference of the editor for mql5 b. 1870 26 June 1028 tell something different:
Period Gibt den Wert von Timeframe des laufenden Charts zurück. ENUM_TIMEFRAMES Period(); Rückgabewert Inhalt der Variable _Period, in Timeframewert des laufenden Charts aufbewahren wird. Wert kann einer der Enumerationswerte ENUM_TIMEFRAMES sein. Sehen Sie auch PeriodSeconds, Chartperioden, Datum und Zeit, Objektsichtbarkeit
I can't add any image... :(
Hmm - the reference of the editor for mql5 b. 1870 26 June 1028 tell something different:
I can't add any image... :(
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a huge include File that now compiles for MQL5 with no Error.
Within I have two functions
NOW - if I compile an indicator that loads myDefs.mqh but does not call any of these two functions I get this compiler error:
Both the first variable of the function (per) and the function Period() are define as ENUM_TIMEFRAMES - why it has to be converted, and why it fails?
Anyone with a little light in my darkness?