I hv written a EFS which will change the background color as follows:
i) green background when
- 10min 20EMA is up
- 30min 20EMA is up
- 30min 20LSMA is up
ii) red background when:
- 10min 20EMA is down
- 30min 20EMA is down
- 30min 20LSMA is down
The problem is that when I reload the chart, the chart doesn't look like the same as it was when run real-time. Would you pls advise why and how can I hv the charts to look the same? Pls note that I hv not set it to compute on close.
---------------------------------------------
var amLib=addLibrary("amStudies.efsLib");
var EMA_Interval_1 = 10;
var EMA_Interval_2 = 30;
var nMALength= 20;
....
function main()
{
....
vEMA1 = ema(nMALength, inv(EMA_Interval_1));
vEMA1_previous = ema(nMALength, inv(EMA_Interval_1),-1);
vLSMA1 = amLib.amLSMA(nMALength, inv(EMA_Interval_1));
vLSMA1_previous = amLib.amLSMA(nMALength, inv(EMA_Interval_1),-1);
vEMA2 = ema(nMALength, inv(EMA_Interval_2));
vLSMA2 = amLib.amLSMA(nMALength, inv(EMA_Interval_2));
vEMA2_previous = ema(nMALength, inv(EMA_Interval_2),-1);
vLSMA2_previous = amLib.amLSMA(nMALength, inv(EMA_Interval_2),-1);
if ( vEMA1>vEMA1_previous && vEMA2>vEMA2_previous && vLSMA2>vLSMA2_previous ) {
TrendBgColor = StrongUp_Bg_Color;
} else if ( vEMA1<vEMA1_previous && vEMA2<vEMA2_previous && vLSMA2<vLSMA2_previous ) {
TrendBgColor = StrongDown_Bg_Color;
} else {
TrendBgColor = NormalBgColor;
}
setDefaultBarBgColor(TrendBgColor);
.....
}
i) green background when
- 10min 20EMA is up
- 30min 20EMA is up
- 30min 20LSMA is up
ii) red background when:
- 10min 20EMA is down
- 30min 20EMA is down
- 30min 20LSMA is down
The problem is that when I reload the chart, the chart doesn't look like the same as it was when run real-time. Would you pls advise why and how can I hv the charts to look the same? Pls note that I hv not set it to compute on close.
---------------------------------------------
var amLib=addLibrary("amStudies.efsLib");
var EMA_Interval_1 = 10;
var EMA_Interval_2 = 30;
var nMALength= 20;
....
function main()
{
....
vEMA1 = ema(nMALength, inv(EMA_Interval_1));
vEMA1_previous = ema(nMALength, inv(EMA_Interval_1),-1);
vLSMA1 = amLib.amLSMA(nMALength, inv(EMA_Interval_1));
vLSMA1_previous = amLib.amLSMA(nMALength, inv(EMA_Interval_1),-1);
vEMA2 = ema(nMALength, inv(EMA_Interval_2));
vLSMA2 = amLib.amLSMA(nMALength, inv(EMA_Interval_2));
vEMA2_previous = ema(nMALength, inv(EMA_Interval_2),-1);
vLSMA2_previous = amLib.amLSMA(nMALength, inv(EMA_Interval_2),-1);
if ( vEMA1>vEMA1_previous && vEMA2>vEMA2_previous && vLSMA2>vLSMA2_previous ) {
TrendBgColor = StrongUp_Bg_Color;
} else if ( vEMA1<vEMA1_previous && vEMA2<vEMA2_previous && vLSMA2<vLSMA2_previous ) {
TrendBgColor = StrongDown_Bg_Color;
} else {
TrendBgColor = NormalBgColor;
}
setDefaultBarBgColor(TrendBgColor);
.....
}
Comment