Announcement

Collapse
No announcement yet.

Back Testing

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

  • Back Testing

    This is driving me nuts. When loading "SAR Strategy" that Alex lifted from the Beta Forum, I get error "Downloads\Strategies\Stoch622strategy.efs, line 28: Error Calling Function(main) in SAR.efs.
    Downloads\Strategies\SAR.efs, line 28: Invalaid Series Name(3.4) in getValue()".
    There are no syntax errors just the above error when the EFS has loaded.
    SAR.efs is in the same folder as the strategy. I'm using the SAR.efs from here, right? - http://share.esignal.com/groupconten...Misc&groupid=7

    One more thing: I can't see Stoch622strategy.efs in the folder when using Windows Explorer, only in EFS Editor. Other EFSes are visible just not that one. Weird. Any ideas?

    Cheers, Al.



    Originally posted by Alexis C. Montenegro View Post
    thedon
    That link is to the Beta Forum for which you need to be registered.
    Anyhow I just lifted the formula off that thread and am copying it here.
    Alex

    PHP Code:
    // works well on 85T with Profit = 1.5 and stop = 2.25

    var nsignal 0
    var 
    newTrade 0;
    var 
    prevSAR =0;
    var 
    study = new StochStudy(6,2,2);

    var 
    nTradeEntryPrice
    var 
    ProfitTarget1 1.5;
    var 
    StopLoss1 1.5;
    var 
    ProfitTarget2 0.5;
    var 
    StopLoss2 1.5;
    var 
    Stop 0;
    var 
    Profit 0;

    function 
    preMain() {
    setPriceStudy(true);
    setStudyTitle("SAR Strategy");
    }

    function 
    main() {
    var 
    vHL high(-1) - low(-1);
    var 
    vVar vHL 0.5// used for DrawTextRelative
    var vAddVar vVar 0.5// Used for DrawTextRelative 
    var vFast study.getValue(StochStudy.FAST0, -2);
    var 
    vSlow study.getValue(StochStudy.SLOW0, -2); 

    var 
    SAR callFunction("Downloads/SAR.efs","main",3.4,20);

    if(
    SAR == null || vFast == null || vSlow == null) return;

    if ((
    Strategy.isInTrade() == true) && (newTrade == 1)) 
    {
    nTradeEntryPrice open(); 
    newTrade 0// Turn off NEW TRADE switch
    }

    Strategy.doSell("LongPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice 1));

    // This portion of the code identifies if our profit target has been reached and exits our trades.

    if ((Strategy.isInTrade() == true) && (Strategy.isShort() == true))
    // Check if the profit target has been reached/breached
    if (low() <= (nTradeEntryPrice Profit)) 
    {
    Strategy.doCover("ShortPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Profit));}

    if (
    high() >= (nTradeEntryPrice Stop)) 
    {
    Strategy.doCover("ShortSL Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Stop));}
    }

    if ((
    Strategy.isInTrade() == true) && (Strategy.isLong() == true)) 
    // Check if the profit target has been reached/breached
    if (high() >= (nTradeEntryPrice Profit)) // Profit Target Met Execute Cover order.
    {Strategy.doSell("LongPT Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Profit));}

    if (
    low() <= (nTradeEntryPrice Stop)) // Profit Target Met Execute Cover order.
    {Strategy.doSell("LongSL Exit"Strategy.STOPStrategy.THISBARStrategy.getDefaultLotSize(), (nTradeEntryPrice Stop));}

    }

    //Trailing Stops
    if ((Strategy.isInTrade() == true) && (Strategy.isShort() == true)) {Stop high(-1) + 0.5;}
    if ((
    Strategy.isInTrade() == true) && (Strategy.isLong() == true)) {Stop low(-1) - 0.5;}

    if ((
    SAR close()) && (prevSAR close(-1))) 
    newTrade 1// New Trade Trigger
    nsignal = +1// Buy Signal
    Stop StopLoss1;
    Profit ProfitTarget1;
    }

    if ( (
    Strategy.isInTrade() == false) && (SAR close()) && ((vSlow[1] < vSlow[0]) && (vSlow[1] <= 38)) )
    newTrade 1// New Trade Trigger
    nsignal = +1// Buy Signal
    Stop StopLoss2;
    Profit ProfitTarget2;
    }

    if ((
    SAR close()) && (prevSAR close(-1)))
    newTrade 1// New Trade Trigger
    nsignal = -1// Sell Signal
    Stop StopLoss1;
    Profit ProfitTarget1;
    }

    if( (
    Strategy.isInTrade() == false) && (SAR close()) && ((vSlow[0] < vSlow[1]) && (vSlow[1] >= 62)) )
    newTrade 1// New Trade Trigger
    nsignal = -1// Sell Signal
    Stop StopLoss2;
    Profit ProfitTarget2;
    }

    prevSAR SAR;

    // Execute Trades ONLY if nNewTrade is triggered
    if ((newTrade == 1) && 
    ((
    getHour() >= 18) && ((getHour() < 21))) 

    { if (
    Strategy.isInTrade() == true// reverse current trade position
    {if ((nsignal 0) && (Strategy.isShort() == true)) {Strategy.doCover("Exit Short"Strategy.MARKETStrategy.NEXTBAR);}
    if ((
    nsignal 0) && (Strategy.isLong() == true)) {Strategy.doSell("Exit Long"Strategy.MARKETStrategy.NEXTBAR);}


    if ((
    nsignal 0)) 
    {
    Strategy.doLong("Long"Strategy.MARKETStrategy.NEXTBAR);
    drawShapeRelative(0low() - vVarShape.UPARROW""Color.limenull,"buyShp" getValue("time"));
    drawTextRelative(0low() - (vVar vAddVar), "B"Color.blackColor.lime,Text.BOLD Text.ONTOPnullnull"buyTxt" getValue("time"));
    }
    if ((
    nsignal 0)) 
    {
    Strategy.doShort("Short"Strategy.MARKETStrategy.NEXTBAR);
    drawShapeRelative(0high() + vVarShape.DOWNARROW""Color.rednull,"sellShp" getValue("time"));
    drawTextRelative(0high() + (vVar vAddVar), "S"Color.blackColor.red,Text.BOTTOM Text.BOLD Text.ONTOPnullnull"buyTxt" getValue("time")); 
    }
    nsignal 0
    // END EXECUTE NEW TRADE


    if (getHour() == 21 && getMinute() == 05)
    // Close out at this time each day
    if (Strategy.isShort())
    {
    Strategy.doCover("EOD exit"Strategy.MARKETStrategy.NEXTBAR);
    nsignal 0;}
    else if (
    Strategy.isLong())
    {
    Strategy.doSell("EOD exit"Strategy.MARKETStrategy.NEXTBAR);
    nsignal 0;}

    return ;


  • #2
    Al

    There are no syntax errors just the above error when the EFS has loaded.
    Not sure what you mean with that in as much as the error message you get when the efs is loaded is in effect a syntax error.
    What it is telling you is that the parameter being passed to the SAR.efs is not valid.
    If you look at the arguments of the main() function of the SAR.efs [which is what callFunction()in line 28 of the formula is calling] you will see that it expects 3 parameters - the first one being a Price series - while the callFunction() call in line 28 is only passing 2 of them. Given that the formula is using the Price series within a getValue() function this would have to be “Open”, “High”, “Low” or “Close”. This is further confirmed by the validation routine for that parameter in the SAR.efs ie
    if(Price == null)
    Price = "Close";
    Since the validation routine will assign a parameter if this is null you could just pass the latter as the first parameter of the callFunction() call in line 28. Once you add that parameter that should resolve the error you are seeing.

    One more thing: I can't see Stoch622strategy.efs in the folder when using Windows Explorer, only in EFS Editor. Other EFSes are visible just not that one. Weird. Any ideas?
    From the context of your message it would seem that you are using 10.6 and Vista (or later) as the OS (btw it is good practice to provide this information in the first place so others don’t have to guess). If this is the case then do a forum search for virtual store and you will find an explanation of why this is
    Alex


    Originally posted by alrados View Post
    This is driving me nuts. When loading "SAR Strategy" that Alex lifted from the Beta Forum, I get error "Downloads\Strategies\Stoch622strategy.efs, line 28: Error Calling Function(main) in SAR.efs.
    Downloads\Strategies\SAR.efs, line 28: Invalaid Series Name(3.4) in getValue()".
    There are no syntax errors just the above error when the EFS has loaded.
    SAR.efs is in the same folder as the strategy. I'm using the SAR.efs from here, right? - http://share.esignal.com/groupconten...Misc&groupid=7

    One more thing: I can't see Stoch622strategy.efs in the folder when using Windows Explorer, only in EFS Editor. Other EFSes are visible just not that one. Weird. Any ideas?

    Cheers, Al.

    Comment

    Working...
    X