Thanks that is perfect...
Announcement
Collapse
No announcement yet.
StochasticOf_Montage.efs
Collapse
X
-
Hello Mike,
Make a copy of the formula with a new name and then replace lines 603-608 with the following.
PHP Code:if(MAType=="Exponential"){
if(aValue[LengthD-1] != null) vEMA = EMA(LengthD, aValue);
if (sum > vEMA) setBarBgColor(Color.green);
else setBarBgColor(Color.grey);
return new Array (sum,vEMA);
}else{
if (sum > vSMA) setBarBgColor(Color.green);
else setBarBgColor(Color.grey);
return new Array (sum,vSMA);
}
Note that I used grey instead of red since that conflicts with the defaults. Feel free to change it. Also, I assumed that by up you meant %K above %D and that it was the color of the background you wanted to change. If not, please give me more details for what you had in mind.Jason K.
Project Manager
eSignal - an Interactive Data company
EFS KnowledgeBase
JavaScript for EFS Video Series
EFS Beginner Tutorial Series
EFS Glossary
Custom EFS Development Policy
New User Orientation
Comment
-
Mike
Replace the same section of code indicated by Jason with the following
Note that the setBarFgColor() commands with 0 color the %K plot while those with 1 color %D. If you only wish to color one of the plots remove or comment out the commands for the other.
Alex
PHP Code:if(MAType=="Exponential"){
if(aValue[LengthD-1] != null) vEMA = EMA(LengthD, aValue);
if (sum > vEMA) {
setBarFgColor(Color.lime,0);
setBarFgColor(Color.green,1);
}else{
setBarFgColor(Color.red,0);
setBarFgColor(Color.magenta,1);
}
return new Array (sum,vEMA);
}else{
if (sum > vSMA) {
setBarFgColor(Color.lime,0);
setBarFgColor(Color.green,1);
}else{
setBarFgColor(Color.red,0);
setBarFgColor(Color.magenta,1);
}
return new Array (sum,vSMA);
}
Comment
-
Alex,
Thank you! But I guess I should say sorry again.
I try to make my question more clear.
I want to modify this wonderful code to two separate EFS. So I need plot the signal line with different color when it goes up/down. Just like below:
PHP Code:if ( vADXDM.getValue(ADXDMStudy.ADX) > vADXDM.getValue(ADXDMStudy.ADX, -1)
setBarFgColor(Color.lime);
}else{
setBarFgColor(Color.red);
}
if (sum > sum1)...
if (vSMA > vSMA1)...
if (vEMA > vEMA1)...
Mike
Comment
-
Mike
I think I now understand what you want.
First thing remove var from var vSMA = nSum/LengthD; in line 600 of the efs.
Then declare the following Global variables
var SMA = null;
var SMA1 = null;
At the very beginning of main() add the following
if(getBarState()==BARSTATE_NEWBAR){
vSMA1 = vSMA;
}
Lastly replace the section of code indicated by Jason with the following
Alex
PHP Code:if(MAType=="Exponential"){
if(aValue[LengthD-1] != null) vEMA = EMA(LengthD, aValue);
if (aValue[0] > aValue[1]) {
setBarFgColor(Color.lime,0);
}else{
setBarFgColor(Color.red,0);
}
if(vEMA>vEMA1){
setBarFgColor(Color.green,1);
}else{
setBarFgColor(Color.magenta,1);
}
return new Array (sum,vEMA);
}else{
if (aValue[0] > aValue[1]) {
setBarFgColor(Color.lime,0);
}else{
setBarFgColor(Color.red,0);
}
if(vSMA>vSMA1){
setBarFgColor(Color.green,1);
}else{
setBarFgColor(Color.magenta,1);
}
return new Array (sum,vSMA);
}
Comment
Comment