Announcement

Collapse
No announcement yet.

Help on backtesting of new system

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

  • Help on backtesting of new system

    Hi
    I'm not a great backtester. Could anyone help me create a backtest of this strategy?!


    var lastrawtime = 0;
    var BarCount = 0;
    var vLastAlert = -1;
    var vFlag0 = 1;
    var vFlag1 = 0;

    function preMain() {

    setPriceStudy(true);
    setStudyTitle("Long/Short");
    setShowCursorLabel(false);

    }

    function main() {

    if(lastrawtime != getValue("rawtime", 0)){
    BarCount += 1;
    lastrawtime = getValue("rawtime", 0);
    }

    if(getBarState()==BARSTATE_NEWBAR){
    vFlag1 = vFlag0;
    }

    if(vFlag0==-1&&open()<low(-2)&&close()>=low(-2)||vFlag0==-1&&low()>=low(-2)&&close()>high(-1)){
    if(vLastAlert!=1)drawShapeRelative(0, low(0), Shape.UPTRIANGLE, "", Color.blue,null,"Up"+ BarCount);
    }else{
    removeShape("Up"+BarCount);
    }
    if(vFlag0==1&&open()>high(-2)&&close()<=high(-2)||vFlag0==1&&high()<=high(-2)&&close()<low(-1)){
    if(vLastAlert!=2)drawShapeRelative(0, high(0), Shape.DOWNTRIANGLE, "", Color.red,null,"Dn"+ BarCount);
    }else{
    removeShape("Dn"+BarCount);
    }

    if(getBarState()==BARSTATE_NEWBAR){
    if(vFlag1==-1&&open(-1)<low(-3)&&close(-1)>=low(-3)||vFlag1==-1&&low(-1)>=low(-3)&&close(-1)>high(-2)){
    drawShapeRelative(-1, low(-1), Shape.UPTRIANGLE, "", Color.blue,null,"Up"+ BarCount);
    Alert.playSound("long.wav");
    //Alert.addToList(getSymbol()+" "+getInterval(),"LongStop",Color.black,Color.green );
    vFlag0 = 1;
    vLastAlert = 1;
    }
    if(vFlag1==1&&open(-1)>high(-3)&&close(-1)<=high(-3)||vFlag1==1&&high(-1)<=high(-3)&&close(-1)<low(-2)){
    drawShapeRelative(-1, high(-1), Shape.DOWNTRIANGLE, "", Color.red,null,"Dn"+ BarCount);
    Alert.playSound("short.wav");
    //Alert.addToList(getSymbol()+" "+getInterval(),"ShortStop",Color.black,Color.red) ;
    vFlag0 = -1;
    vLastAlert = 2;
    }
    }

    return null;

  • #2
    jonti
    If I am not mistaken I wrote the efs you posted (the original script is available here)
    The attached revision adds Buy/Sell commands for use in back testing based on the signals generated by the script. Also, when long it paints the bars in lime and when short in red
    Alex

    PS. When posting an efs created by someone else please preserve also all annotations included in the original script.

    Attached Files

    Comment


    • #3
      backtesting with buy and sell signals

      I am very interested on how i can configure my e sgainl charts to plot a blue arrow for a buy and a red arrow for a sell just like u have on the actual e siganl chart once its meets my personal criteria

      but i an not a computer person.

      can u help me

      Comment


      • #4
        ggutierrez
        See my reply to your other post asking the same question
        Alex

        Comment


        • #5
          I am so sorry Alex. I didn't know that I didn't post all the script. Sorry...... but thanks anyway

          Comment


          • #6
            jonti
            No problem and you are welcome
            Alex

            Comment

            Working...
            X