Hi,
I'm trying to make an Stochastic-Indikator which is calculated on 2 Timeframes. That means I have e.g. 1 Stochastic-Value from 1min and a second Stochastic-Value from 2min. This I have already done.
I want then finally have the average of this 2 values above. I don't know how.
Here is my modified code from customStochastic that give the values for a stochastic-Indicator from 2 timeframes. But I don't know how to calculate the average.
I think its not that complicated but I'm new to EFS. Maybe someone could help?
Thank you!
I'm trying to make an Stochastic-Indikator which is calculated on 2 Timeframes. That means I have e.g. 1 Stochastic-Value from 1min and a second Stochastic-Value from 2min. This I have already done.
I want then finally have the average of this 2 values above. I don't know how.
Here is my modified code from customStochastic that give the values for a stochastic-Indicator from 2 timeframes. But I don't know how to calculate the average.
/************************************************** *******
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("StochasticAverage");
setCursorLabelName("%K",0);
setCursorLabelName("%K2",1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
askForInput();
var average = 0;
var x=0;
fpArray[x] = new FunctionParameter("KLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%K");
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("KSmoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%KSmooth");
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("DLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%D");
setLowerLimit(1);
setDefault(3);
}
fpArray[x] = new FunctionParameter("Interval1", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName( "Interval 2" );
setLowerLimit(1);
setDefault(2);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(80);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xStochK = null;
var xStochD = null;
function main(KLength,KSmoothing,DLength,Symbol,Interval,In terval1,Upper,Lower,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
var vSymbol1 = Symbol+","+Interval1;
//var average = 0;
xStochK = stochK(KLength,KSmoothing,DLength,sym(vSymbol));
xStochK1 = stochK(KLength,KSmoothing,DLength,sym(vSymbol1));
//xStochD = stochD(KLength,KSmoothing,DLength,sym(vSymbol));
average = (xStochK + xStochK1)/2;
addBand( Upper, PS_SOLID, 1, Color.black,"Upper");
addBand( Lower, PS_SOLID, 1, Color.black,"Lower");
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array (getSeries(xStochK),getSeries(xStochK1));//,getSeries(average));
}
By Alexis C. Montenegro for eSignal © December 2004
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a
description of any changes you make.
************************************************** ********/
var fpArray = new Array();
function preMain() {
setPriceStudy(false);
setStudyTitle("StochasticAverage");
setCursorLabelName("%K",0);
setCursorLabelName("%K2",1);
setDefaultBarFgColor(Color.blue, 0);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE,0);
setPlotType(PLOTTYPE_LINE,1);
setDefaultBarThickness(1,0);
setDefaultBarThickness(1,1);
askForInput();
var average = 0;
var x=0;
fpArray[x] = new FunctionParameter("KLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%K");
setLowerLimit(1);
setDefault(14);
}
fpArray[x] = new FunctionParameter("KSmoothing", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%KSmooth");
setLowerLimit(1);
setDefault(1);
}
fpArray[x] = new FunctionParameter("DLength", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("%D");
setLowerLimit(1);
setDefault(3);
}
fpArray[x] = new FunctionParameter("Interval1", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName( "Interval 2" );
setLowerLimit(1);
setDefault(2);
}
fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
with(fpArray[x++]){
setDefault();
}
fpArray[x] = new FunctionParameter("Upper", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(80);
}
fpArray[x] = new FunctionParameter("Lower", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(0);
setDefault(20);
}
fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Show Parameters");
setDefault(false);
}
}
var bInit = false;
var xStochK = null;
var xStochD = null;
function main(KLength,KSmoothing,DLength,Symbol,Interval,In terval1,Upper,Lower,Params) {
if(bInit == false){
if(Symbol == null) Symbol = getSymbol();
if(Interval == null) Interval = getInterval();
var vSymbol = Symbol+","+Interval;
var vSymbol1 = Symbol+","+Interval1;
//var average = 0;
xStochK = stochK(KLength,KSmoothing,DLength,sym(vSymbol));
xStochK1 = stochK(KLength,KSmoothing,DLength,sym(vSymbol1));
//xStochD = stochD(KLength,KSmoothing,DLength,sym(vSymbol));
average = (xStochK + xStochK1)/2;
addBand( Upper, PS_SOLID, 1, Color.black,"Upper");
addBand( Lower, PS_SOLID, 1, Color.black,"Lower");
setShowTitleParameters(eval(Params));
bInit = true;
}
return new Array (getSeries(xStochK),getSeries(xStochK1));//,getSeries(average));
}
Thank you!
Comment