straken 469 posts msg #95302 - Ignore straken |
7/31/2010 7:51:12 PM
For esignal and stockfinder users:
//Bressert Double Stochtastic//
function preMain()
{
setStudyTitle("DSS Bressert");
setCursorLabelName("DSS", 0);
setCursorLabelName("Trigger", 1);
setCursorLabelName("Overbought", 2);
setCursorLabelName("Oversold", 3);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setDefaultBarFgColor(Color.grey, 2);
setDefaultBarFgColor(Color.grey, 3);
}
var EMA_1 = 0;
var EMA1_1 = 0;
var EMA2_1 = 0;
vAA = new Array();
function main(pds,slw,triggerLen,overbought,oversold,emalen){
if (pds == null)
pds = 10;
if (slw == null)
slw = 3;
if (triggerLen == null)
triggerLen = 5;
if (overbought == null)
overbought = 80;
if (oversold == null)
oversold = 20;
if (emalen == null)
emalen = 9;
var vHigh = getValue("High",0,-pds);
var vLow = getValue("Low",0,-pds);
var dClose = getValue("Close");
var K = 2 / (emalen + 1);
var K2 = 2 / (triggerLen + 1);
var aa = 0;
var dss = 0;
var High = 0;
var Low = getValue("Low");
var aHigh = 0;
var aLow = 10000000;
var EMA1 = 0;
var EMA = 0;
for (i = 0; i < pds; i++){
if (High < vHigh[i])
High = vHigh[i];
if (Low > vLow[i])
Low = vLow[i];
}
if((High - Low) != 0)
EMA = K * ( (dClose - Low) / (High - Low) ) + (1 - K) * EMA_1;
else
EMA = EMA_1;
if (getBarState() == BARSTATE_NEWBAR)
EMA_1 = EMA;
aa = EMA * 100;
for(i = pds - 1; i > 0; i--)
vAA[i] = vAA[i - 1];
vAA[0] = aa;
for (i = 0; i < pds; i++){
if (aHigh < vAA[i])
aHigh = vAA[i];
if (aLow > vAA[i])
aLow = vAA[i];
}
if (aHigh - aLow != 0)
EMA1 = K * ( (aa - aLow) / (aHigh - aLow) ) + (1 - K) * EMA1_1;
else
EMA1 = EMA1_1;
if (getBarState() == BARSTATE_NEWBAR)
EMA1_1 = EMA1;
dss = EMA1 * 100;
var EMA2 = K2 * dss + (1 - K) * EMA2_1;
if (getBarState() == BARSTATE_NEWBAR)
EMA2_1 = EMA2;
return new Array(dss,EMA2,overbought,oversold);
}
|