Re: Already Converted TradingView Indicators to MT4 Indicators
Posted: Sat Feb 18, 2023 8:29 pm
is there a way in mt5 and mt4 to have array.push and array.shift like in tradingview ?
I want to convert this function
I want to convert this function
Code: Select all
// @function Sums values of `src` when `cond` is true, over a moving window of length `ms` milliseconds.
// @param src (series int/float) The source of the values to be summed.
// @param ms (simple int) The time duration in milliseconds defining the size of the moving window.
// @param cond (series bool) The condition determining which values are included. Optional.
// @param minBars (simple int) The minimum number of values to keep in the moving window. Optional.
// @returns (float) The sum of `src` when `cond` is true in the moving window.
export totalForTimeWhen(series float src, simple int ms, series bool cond = true, simple int minBars = 1) =>
var float[] sources = array.new_float(0)
var int[] times = array.new_int(0)
if cond
array.push(sources, src)
array.push(times, time)
if array.size(sources) > 0
while time - array.get(times, 0) >= ms and array.size(sources) > minBars
array.shift(sources)
array.shift(times)
float result = array.sum(sources)