Announcement

Collapse
No announcement yet.

Stoch-Multitimeframes (1, 5, 15, 60, 180) - one Indikator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stoch-Multitimeframes (1, 5, 15, 60, 180) - one Indikator

    Hello,
    I'm trying to integrate several time intervals in a stochastic indicator. The data are minute interval in the history are displayed in the right 1 and 180. The intervals of 3 -, 15 - and 60-minutes but too short. Can you help me to solve the problem, so that the history of the indicators will be displayed as long as possible, so that a back-testing and a reasonable adjustment of the indicators is that possible?
    Thank you very much!
    Sincerely Ike

    /************************************************** *******
    Ike Marcstone (c) 2013

    based on:

    Alexis C. Montenegro © July 2003
    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 vStoch = null
    var vPSAR = null;
    var fpArray = new Array();

    function preMain() {
    setStudyTitle("StoSigNew");
    setCursorLabelName("aStoch", 0);
    setCursorLabelName("aPara", 1);
    setCursorLabelName("bStoch", 2);
    setCursorLabelName("bPara", 3);
    setCursorLabelName("cStoch", 4);
    setCursorLabelName("cPara", 5);
    setCursorLabelName("dStoch", 6);
    setCursorLabelName("dPara", 7);
    setCursorLabelName("eStoch", 8);
    setCursorLabelName("ePara", 9);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarStyle(PS_SOLID, 3);
    setDefaultBarStyle(PS_SOLID, 4);
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarStyle(PS_SOLID, 6);
    setDefaultBarStyle(PS_SOLID, 7);
    setDefaultBarStyle(PS_SOLID, 8);
    setDefaultBarStyle(PS_SOLID, 9);
    setDefaultBarFgColor(Color.RGB(115,174,255), 0);
    setDefaultBarFgColor(Color.RGB(115,174,255), 1);
    setDefaultBarFgColor(Color.magenta, 2);
    setDefaultBarFgColor(Color.magenta, 3);
    setDefaultBarFgColor(Color.green, 4);
    setDefaultBarFgColor(Color.green, 5);
    setDefaultBarFgColor(Color.red, 6);
    setDefaultBarFgColor(Color.red, 7);
    setDefaultBarFgColor(Color.blue, 8);
    setDefaultBarFgColor(Color.blue, 9);
    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setDefaultBarThickness(1, 3);
    setDefaultBarThickness(1, 4);
    setDefaultBarThickness(1, 5);
    setDefaultBarThickness(1, 6);
    setDefaultBarThickness(1, 7);
    setDefaultBarThickness(1, 8);
    setDefaultBarThickness(1, 9);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_DOT, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    setPlotType(PLOTTYPE_DOT, 3);
    setPlotType(PLOTTYPE_LINE, 4);
    setPlotType(PLOTTYPE_DOT, 5);
    setPlotType(PLOTTYPE_LINE, 6);
    setPlotType(PLOTTYPE_DOT, 7);
    setPlotType(PLOTTYPE_LINE, 8);
    setPlotType(PLOTTYPE_DOT, 9);

    addBand( 90, PS_DASHDOTDOT, 1, Color.red,"Upper");
    addBand( 10, PS_DASHDOTDOT, 1, Color.green,"Lower");
    addBand( 95, PS_DASHDOTDOT, 1, Color.cyan,"Upper1");
    addBand( 5, PS_DASHDOTDOT, 1, Color.yellow,"Lower1");


    var x=0;
    fpArray[x] = new FunctionParameter("aK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("aFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("aSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Start", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.02); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Increment", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.02); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Max", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.2); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }}

    var bInit = false;
    var aStochK = null;
    var bStochK = null;
    var cStochK = null;
    var dStochK = null;
    var eStochK = null;


    function main(Upper, Lower, Start, Increment, Max, Params,
    aK, aFast, aSlow, aInterval,
    bK, bFast, bSlow, bInterval,
    cK, cFast, cSlow, cInterval,
    dK, dFast, dSlow, dInterval,
    eK, eFast, eSlow, eInterval
    )
    {

    //if(vStoch==null) vStoch = new StochStudy(K, Fast, Slow);
    addBand( Upper, PS_SOLID, 1, Color.red,2);
    addBand( Lower, PS_SOLID, 1, Color.green,3);

    if(bInit == false){
    //if(aSymbol == null)
    aSymbol = getSymbol();
    if(aInterval == null) aInterval = getInterval();
    var aSymbol = aSymbol+","+aInterval;
    //if(bSymbol == null)
    bSymbol = getSymbol();
    if(bInterval == null) bInterval = getInterval();
    var bSymbol = bSymbol+","+bInterval;
    //if(cSymbol == null)
    cSymbol = getSymbol();
    if(cInterval == null) cInterval = getInterval();
    var cSymbol = cSymbol+","+cInterval;
    //if(dSymbol == null)
    dSymbol = getSymbol();
    if(dInterval == null) dInterval = getInterval();
    var dSymbol = dSymbol+","+dInterval;
    //if(eSymbol == null)
    eSymbol = getSymbol();
    if(eInterval == null) eInterval = getInterval();
    var eSymbol = eSymbol+","+eInterval;


    aStochK = stochK(aK,aFast,aSlow,sym(aSymbol));
    bStochK = stochK(bK,bFast,bSlow,sym(bSymbol));
    cStochK = stochK(cK,cFast,cSlow,sym(cSymbol));
    dStochK = stochK(dK,dFast,dSlow,sym(dSymbol));
    eStochK = stochK(eK,eFast,eSlow,sym(eSymbol));


    setShowTitleParameters(eval(Params));
    bInit = true;
    }
    return new Array
    (getSeries(aStochK),sar( Start, Increment, Max, getSeries(aStochK)),
    getSeries(bStochK),sar( Start, Increment, Max, getSeries(bStochK)),
    getSeries(cStochK),sar( Start, Increment, Max, getSeries(cStochK)),
    getSeries(dStochK),sar( Start, Increment, Max, getSeries(dStochK)),
    getSeries(eStochK),sar( Start, Increment, Max, getSeries(eStochK)));
    }

  • #2
    Ike
    See the explanation and solution I provided in this post in reply to a similar issue
    As an aside you can improve the efficiency of your script by initializing all your studies inside the bInit routine as shown in the following image



    You will need to declare the additional variables ie aSAR, bSAR, etc as global variables.
    Once you have done that you can replace your return statement with the following



    Alex


    Originally posted by Sandra View Post
    Hello,
    I'm trying to integrate several time intervals in a stochastic indicator. The data are minute interval in the history are displayed in the right 1 and 180. The intervals of 3 -, 15 - and 60-minutes but too short. Can you help me to solve the problem, so that the history of the indicators will be displayed as long as possible, so that a back-testing and a reasonable adjustment of the indicators is that possible?
    Thank you very much!
    Sincerely Ike

    /************************************************** *******
    Ike Marcstone (c) 2013

    based on:

    Alexis C. Montenegro © July 2003
    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 vStoch = null
    var vPSAR = null;
    var fpArray = new Array();

    function preMain() {
    setStudyTitle("StoSigNew");
    setCursorLabelName("aStoch", 0);
    setCursorLabelName("aPara", 1);
    setCursorLabelName("bStoch", 2);
    setCursorLabelName("bPara", 3);
    setCursorLabelName("cStoch", 4);
    setCursorLabelName("cPara", 5);
    setCursorLabelName("dStoch", 6);
    setCursorLabelName("dPara", 7);
    setCursorLabelName("eStoch", 8);
    setCursorLabelName("ePara", 9);
    setDefaultBarStyle(PS_SOLID, 0);
    setDefaultBarStyle(PS_SOLID, 1);
    setDefaultBarStyle(PS_SOLID, 2);
    setDefaultBarStyle(PS_SOLID, 3);
    setDefaultBarStyle(PS_SOLID, 4);
    setDefaultBarStyle(PS_SOLID, 5);
    setDefaultBarStyle(PS_SOLID, 6);
    setDefaultBarStyle(PS_SOLID, 7);
    setDefaultBarStyle(PS_SOLID, 8);
    setDefaultBarStyle(PS_SOLID, 9);
    setDefaultBarFgColor(Color.RGB(115,174,255), 0);
    setDefaultBarFgColor(Color.RGB(115,174,255), 1);
    setDefaultBarFgColor(Color.magenta, 2);
    setDefaultBarFgColor(Color.magenta, 3);
    setDefaultBarFgColor(Color.green, 4);
    setDefaultBarFgColor(Color.green, 5);
    setDefaultBarFgColor(Color.red, 6);
    setDefaultBarFgColor(Color.red, 7);
    setDefaultBarFgColor(Color.blue, 8);
    setDefaultBarFgColor(Color.blue, 9);
    setDefaultBarThickness(1, 0);
    setDefaultBarThickness(1, 1);
    setDefaultBarThickness(1, 2);
    setDefaultBarThickness(1, 3);
    setDefaultBarThickness(1, 4);
    setDefaultBarThickness(1, 5);
    setDefaultBarThickness(1, 6);
    setDefaultBarThickness(1, 7);
    setDefaultBarThickness(1, 8);
    setDefaultBarThickness(1, 9);
    setPlotType(PLOTTYPE_LINE, 0);
    setPlotType(PLOTTYPE_DOT, 1);
    setPlotType(PLOTTYPE_LINE, 2);
    setPlotType(PLOTTYPE_DOT, 3);
    setPlotType(PLOTTYPE_LINE, 4);
    setPlotType(PLOTTYPE_DOT, 5);
    setPlotType(PLOTTYPE_LINE, 6);
    setPlotType(PLOTTYPE_DOT, 7);
    setPlotType(PLOTTYPE_LINE, 8);
    setPlotType(PLOTTYPE_DOT, 9);

    addBand( 90, PS_DASHDOTDOT, 1, Color.red,"Upper");
    addBand( 10, PS_DASHDOTDOT, 1, Color.green,"Lower");
    addBand( 95, PS_DASHDOTDOT, 1, Color.cyan,"Upper1");
    addBand( 5, PS_DASHDOTDOT, 1, Color.yellow,"Lower1");


    var x=0;
    fpArray[x] = new FunctionParameter("aK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("aFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("aSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("bSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("cSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("dSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eK", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(15); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eFast", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("eSlow", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(1);
    setDefault(3); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Start", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.02); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Increment", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.02); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Max", FunctionParameter.NUMBER);
    with(fpArray[x++]){
    setLowerLimit(0);
    setDefault(0.2); //Edit this value to set a new default
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
    with(fpArray[x++]){
    setName("Show Parameters");
    setDefault(false);
    }}

    var bInit = false;
    var aStochK = null;
    var bStochK = null;
    var cStochK = null;
    var dStochK = null;
    var eStochK = null;


    function main(Upper, Lower, Start, Increment, Max, Params,
    aK, aFast, aSlow, aInterval,
    bK, bFast, bSlow, bInterval,
    cK, cFast, cSlow, cInterval,
    dK, dFast, dSlow, dInterval,
    eK, eFast, eSlow, eInterval
    )
    {

    //if(vStoch==null) vStoch = new StochStudy(K, Fast, Slow);
    addBand( Upper, PS_SOLID, 1, Color.red,2);
    addBand( Lower, PS_SOLID, 1, Color.green,3);

    if(bInit == false){
    //if(aSymbol == null)
    aSymbol = getSymbol();
    if(aInterval == null) aInterval = getInterval();
    var aSymbol = aSymbol+","+aInterval;
    //if(bSymbol == null)
    bSymbol = getSymbol();
    if(bInterval == null) bInterval = getInterval();
    var bSymbol = bSymbol+","+bInterval;
    //if(cSymbol == null)
    cSymbol = getSymbol();
    if(cInterval == null) cInterval = getInterval();
    var cSymbol = cSymbol+","+cInterval;
    //if(dSymbol == null)
    dSymbol = getSymbol();
    if(dInterval == null) dInterval = getInterval();
    var dSymbol = dSymbol+","+dInterval;
    //if(eSymbol == null)
    eSymbol = getSymbol();
    if(eInterval == null) eInterval = getInterval();
    var eSymbol = eSymbol+","+eInterval;


    aStochK = stochK(aK,aFast,aSlow,sym(aSymbol));
    bStochK = stochK(bK,bFast,bSlow,sym(bSymbol));
    cStochK = stochK(cK,cFast,cSlow,sym(cSymbol));
    dStochK = stochK(dK,dFast,dSlow,sym(dSymbol));
    eStochK = stochK(eK,eFast,eSlow,sym(eSymbol));


    setShowTitleParameters(eval(Params));
    bInit = true;
    }
    return new Array
    (getSeries(aStochK),sar( Start, Increment, Max, getSeries(aStochK)),
    getSeries(bStochK),sar( Start, Increment, Max, getSeries(bStochK)),
    getSeries(cStochK),sar( Start, Increment, Max, getSeries(cStochK)),
    getSeries(dStochK),sar( Start, Increment, Max, getSeries(dStochK)),
    getSeries(eStochK),sar( Start, Increment, Max, getSeries(eStochK)));
    }

    Comment

    Working...
    X