[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Convert esignal formula(Bresserts' DSS) into .ela?



PureBytes Links

Trading Reference Links

I'd like to ask for some help converting this Double Smoothed Stochastic
formula(Bressert) from the eSignal language to easy language(.ela).  Here it
is in eSignal format:









                                Oscillators > DSS Bressert (Double Smoothed
Stochastic) [eSignal EFS Indicators]


                                Download: dss_bressert.efs

                                Category: Indicator > Oscillators

                                Description:

                                Double Smoothed Stochastics (DSS) is
designed by William Blaw. It attempts to combine moving average methods with
oscillator principles.







                                Inputs:

                                pds - number of bars to calculate trigger
                                slw - number of bars to calculate trigger
                                triggerLen - trigger`s length
                                emalen - number of bars to calculate EMA

                                EFS Code:



/*******************************************************************
                                Description	: This Indicator plots DSS
Bressert
                                Provided By	: Developed by TS Support, LLC
for eSignal. (c) Copyright 2002

********************************************************************/

                                function preMain()
                                {
                                    setStudyTitle("DSS Bressert");
                                    setCursorLabelName("DSS", 0);
                                    setCursorLabelName("Trigger", 1);
                                    setDefaultBarFgColor(Color.brown, 0);
                                    setDefaultBarFgColor(Color.red, 1);
                                    addBand(20, PS_SOLID, 1, Color.black);
                                    addBand(80, PS_SOLID, 1, Color.black);
                                }

                                var EMA_1 = 0;
                                var EMA1_1 = 0;
                                var EMA2_1 = 0;
                                vAA = new Array();

                                function main(pds,slw,triggerLen,emalen){
                                	if (pds == null)
                                		pds = 10;
                                	if (slw == null)
                                		slw = 3;
                                	if (triggerLen == null)
                                		triggerLen = 5;
                                	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 - K2) * EMA2_1;
                                	if (getBarState() == BARSTATE_NEWBAR)
                                		EMA2_1 = EMA2;
                                	return new Array(dss,EMA2);
                                }

/*******************************************************************/

                                John









Attachment: Description: ""

Attachment: Description: ""