Announcement

Collapse
No announcement yet.

FunctionParameter

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

  • FunctionParameter

    If I backtest a study that takes a string parameter e.g.

    var fp5 = new FunctionParameter("nParm5", FunctionParameter.STRING);

    and then re-backtest on the same chart using a different study that takes a number parameter e.g.

    var fp5 = new FunctionParameter("nParm5", FunctionParameter.NUMBER);

    I get the string options appearing in the backtest parameter box from the first study.

    Apologies for not providing an example but a little short on time.
    Paul Williams
    Strategy & Applications
    www.futurenets.co.uk

  • #2
    Paul
    I tried the following two efs(s) and the parameters seem to switch accordingly. I also tried adding function parameters (up to three) and swapping them as in the enclosed examples with the same results.
    You may want to post a sample of what you are using
    Alex

    PHP Code:
    var vMA null;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("String");
            
        var 
    fp1 = new FunctionParameter("Param1"FunctionParameter.STRING);
        
    fp1.addOption("High");
        
    fp1.addOption("Low");
        
    fp1.addOption("Close");
        
    fp1.addOption("Open");
        
    fp1.setDefault("Close");
    }
    function 
    main(Param1) {
        
        if (
    vMA == nullvMA = new MAStudy(100Param1MAStudy.SIMPLE);
        
        if(
    Strategy.isLong()==false&&close(-1)<vMA.getValue(MAStudy.MA,-1)&&close()>vMA.getValue(MAStudy.MA))
        
    Strategy.doLong("Long",Strategy.CLOSE,Strategy.THISBAR);
        if(
    Strategy.isLong()==true&&close(-1)>vMA.getValue(MAStudy.MA,-1)&&close()<vMA.getValue(MAStudy.MA))
        
    Strategy.doSell("Sell",Strategy.CLOSE,Strategy.THISBAR);

    return 
    vMA.getValue(MAStudy.MA);

    PHP Code:
    var vMA null;

    function 
    preMain() {

        
    setStudyTitle("Number");
        
        var 
    fp1 = new FunctionParameter("Param1"FunctionParameter.NUMBER);
        
    fp1.addOption(5);
        
    fp1.addOption(10);
        
    fp1.addOption(20);
        
    fp1.setDefault(10);
    }
    function 
    main(Param1) {
        
        if (
    vMA == nullvMA = new MAStudy(Param10"Close"MAStudy.SIMPLE);
        
        if(
    Strategy.isLong()==false&&close(-1)<vMA.getValue(MAStudy.MA,-1)&&close()>vMA.getValue(MAStudy.MA))
        
    Strategy.doLong("Long",Strategy.CLOSE,Strategy.THISBAR);
        if(
    Strategy.isLong()==true&&close(-1)>vMA.getValue(MAStudy.MA,-1)&&close()<vMA.getValue(MAStudy.MA))
        
    Strategy.doSell("Sell",Strategy.CLOSE,Strategy.THISBAR);

    return 
    vMA;

    Comment


    • #3
      thanks Alexis

      The study has 8 or so functionparameters.

      I'm a little under pressure at the moment with another project but will try and setup an example.
      Paul Williams
      Strategy & Applications
      www.futurenets.co.uk

      Comment

      Working...
      X