MQL4/5 Prev_calculated similar alternatives for cAlgo
Created at 16 Mar 2021, 04:52
MQL4/5 Prev_calculated similar alternatives for cAlgo
16 Mar 2021, 04:52
Some mql4/mql5 codes in my opinion are pretty hard to convert to cAlgo because of this function. How can i get a similar alternative to prev_calculated (for mql5) or IndicatorCounted (for mql4)? Thanks in advance.
See the example below: ( in mql4)
int counted_bars=IndicatorCounted();
int i,j,k,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-1,MathMax(Bars-counted_bars,HalfLength));
//
//
//
//
//
for (i=counted_bars; i>=0; i--)
{
// code example
}
amusleh
16 Mar 2021, 11:11
RE:
andurei said:
Hi,
Its very easy to convert other platforms code to cTrader Automate C# code, you just have to know the API.
There is no IndicatorCounted equivalent function in Automate API, and the indicator is refreshed and reinitialized whenever the chart data is updated or indicator parameters change, you can't access the previous indicator instance data.
So basically you don't need this function in cTrader automate as it works differently in comparison to MT 4/5, cTrader is not new version of MetaTrader and they work differently.
If you want to have access to previous indicator instance data you can save the current instance data in a file and when the indicator reinitialized you can read from that file your data and fill the indicator data series outputs with it instead of recalculating.
@amusleh