recalculate()

ICE Data Services -

recalculate() Utility Functions

Executes a callback function on the specified number of bars back.
Syntax
recalculate( [NumberBars,] CallbackFn )
Parameters
Parameter: Description: Default:
NumberBars [Optional]  An integer representing the number of bars ago on which a callback function will be executed.

 

Downloaded the number of bars in chart/grid CallbackFn Function to execute for each bar. Has no input parameters.

 

n/a
Notes
Only available in versions 11.8 or later.
Code Examples
Using of an anonymous function:
setPriceStudy(true);var bInit = false;var xClose = null;var i = 0;function main(){    if (!bInit){        xClose = close();        bInit = true;    };    var nLastClose = xClose.getValue(0);        if (isLastBarOnChart()){        clearShape();        //checks and displays bars whose close is higher        //than the current price using an anonymous function        recalculate(function(){             var nClose = xClose.getValue(0);                                   if (nClose > nLastClose)                drawShapeRelative(0,AboveBar1,Shape.CIRCLE,null,                Color.lime,Shape.PRESET|Shape.CENTER,i++);            });    };}
Using of a named function:
setPriceStudy(true);var bInit = false;var xClose = null;var i = 0;function main(){    if (!bInit){        xClose = close();        bInit = true;    };    var nLastClose = xClose.getValue(0);        function Draw(){        var nClose = xClose.getValue(0);                               if (nClose > nLastClose)            drawShapeRelative(0,AboveBar1,Shape.CIRCLE,null,            Color.lime,Shape.PRESET|Shape.CENTER,i++);        };        if (isLastBarOnChart()){        clearShape();        //checks 10 bars back and displays bars whose close is higher        //than the current price using a named function "Draw"        recalculate(10, Draw);    };}
See Also
for