Forum

return with or without parentheses

According to https://www.mql5.com/en/docs/basis/operators/return,&nbsp ; we should enclose the value or expression to be returned in parentheses, for example: int CalcSum( int x, int y) { return (x+y); } But the following does also work: int CalcSum( int x, int y) { return x+y; } Is

Is an intermediate array with INDICATOR_CALCULATIONS required?

I've created an indicator that calls an internal function. This function uses an array internally for intermediate calculations . So far, everything works. The indicator is displayed in the indicator chart. However, I'm wondering if I should define and use this indicator globally and register it to

CExpert:Init : adjust period and symbol

According to the CExpert class (of StandardLib), we must always use the current symbol (_Symbol) or period (_Period): // See line 240 //+------------------------------------------------------------------+ //| Initialization and checking for input parameters |

passing index to CopyBuffer/GetData

I have an array-based index (i.e., the index comes not from a time series based array). Now I want to use this index : double high[]; m_high.GetData( index , numberOfBars, high); // Method from Indicator.GetData() with calls common CopyBuffer()-method However, since buffer access is series-based

ArrayResize needed when using dynamic array with CopyBuffer?

According to https://www.mql5.com/en/docs/series/copybuffer , we can simple use double indicatorArr[]; CopyBuffer (m_indicator.Handle(), 0 , 0 , 10 , indicatorArr); // puts the latest 10 indicator values into array But why do I see many examples where it is used like this: double indicatorArr[];

Refresh() with GetData() and CopyBuffer()

According to https://www.mql5.com/en/docs/standardlibrary/technicalindicators/cindicators/cindicator/cindicatorrefresh, it is recommended to always call Refresh() when retrieving data with GetData(). However, looking at the standard lib code (e.g., ExpertBase.mqh ),it does not follow this pattern

check pointer by "!"

Is this if (pointerObj == NULL || CheckPointer (pointerObj)== POINTER_INVALID ){..} the same as this: if (!pointerObj){..} As it is said in https://www.mql5.com/en/docs/basis/types/object_pointers ; > To quickly validate the pointer, you can also use operator "!" ( LNOT ) which checks it via an

Missing compiler error for undefined struct methods

I have something like this, which works as usual: struct TradeSettings{ string msg; void toString() const ; } // method implementation defined outside of struct body TradeSettings::toString(){ return msg; } However, if I have something like this, I would expect

CustomIndicator.Create: second param with INT does not work..

I have a custom indicator with the following inputs (in the following order): input int period = 10 ; // first position in the indicator settings input bool Bold = true ; // second position in the indicator settings and register the custom indicator within a new class with a property: CiCustom

CExpertSignal: get signal results from specified bar index

How can I test or use classes derived from CExpertSignal without using the StrategyTester? For example, I have CSignalMA (a child from CExpertSignal, located in Expert/Signal) . I want to have something like this: 1. go to the last 200 bars 2. show entry, exit signals derived by CSignalMA in