Announcement

Collapse
No announcement yet.

Need Help with EFS version 1

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

  • Need Help with EFS version 1

    Hello to All,

    I have a modified version of a Parabolic Entry/Exit system that I found on this forum.

    My Problem is that I am trying to backtest this and the backtest doenst show the correct entry/exit prices.

    This is just on forex data and I am sure that my problem lies with me not understanding how to construct the proper syntax to get the trade to reverse at the psar value.

    Can someone take a look and point me in the right direction?

    PHP Code:
    /*********************************************************
    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 vPSAR null;
    var 
    vLastAlert = -1;
    var 
    MyPSar null;
    var 
    EntryPrice null;
    var 
    Msg "";

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("ParabolicSAR");
        
    setCursorLabelName("PSAR");
        
    setDefaultBarFgColor(Color.blue);
        
    setDefaultBarThickness(2);
        
    setPlotType(PLOTTYPE_DOT);
        
    //checkVersion(1,"http://share.esignal.com/ContentRoot/ACM%20Test/Formulas/basicParabolic.efs");
        
        
    var fp1 = new FunctionParameter("Start"FunctionParameter.NUMBER);
        
    fp1.setLowerLimit(0);        
        
    fp1.setDefault(0.02); //Edit this value to set a new default    
        
        
    var fp2 = new FunctionParameter("Increment"FunctionParameter.NUMBER);
        
    fp2.setLowerLimit(0);        
        
    fp2.setDefault(0.018); //Edit this value to set a new default    
        
        
    var fp3 = new FunctionParameter("Max"FunctionParameter.NUMBER);
        
    fp3.setLowerLimit(0);        
        
    fp3.setDefault(0.5); //Edit this value to set a new default    
    }

    function 
    main(StartIncrementMax) {

        if (
    vPSAR == nullvPSAR = new ParabolicStudy(StartIncrementMax);
        

    /****************************************************
    Insert your code following this text block           
    Use vPSAR.getValue(ParabolicStudy.STOP) for your code
    *****************************************************/


            
    MyPSar vPSAR.getValue(ParabolicStudy.STOP,-1);
        if ( 
    MyPSar >= high(-1) && Strategy.isShort()== false)
        {
            
    Msg "Short"
            
    goShort(1);
        }
        
        if (
    MyPSar <= low(-1) && Strategy.isLong() == false)
        {
            
    Msg "Long"
            
    goLong(1);
        }

        if ( 
    Strategy.isLong() )
        {
            if ( 
    close() < EntryPrice .0050 )
            {
                
    Msg "Rv2Short";
                
    goShort(2);
            }
        }
        
        if ( 
    Strategy.isShort() )
        {
            if ( 
    close() > EntryPrice .0050 )
            {
                
    Msg "Rv2Long";
                
    goLong(2);
            }
        }
        return 
    vPSAR.getValue(ParabolicStudy.STOP);
    }

    function 
    goLong(Type)
    {
        
    EntryPrice MyPSar;
        if ( 
    Type == )
        {
            
    Strategy.doLong(MsgStrategy.MARKETStrategy.THISBARStrategy.DEFAULT, EntryPrice);
        }
        else
        {
            
    Strategy.doLong(MsgStrategy.MARKETStrategy.THISBARStrategy.DEFAULT, EntryPrice .0050);
        }
        if(
    vLastAlert!=2)drawTextRelative(0low(-1), "B"Color.greenColor.yellowText.FRAME Text.ONTOPText.CENTER Text.BOLDnull12);
        
    vLastAlert=2;
    }

    function 
    goShort(Type)
    {
        
    EntryPrice MyPSar;
        if ( 
    Type == )
        {
            
    Strategy.doShort(Msg Strategy.MARKETStrategy.THISBARStrategy.DEFAULT, EntryPrice); 
        }
        else
        {
            
    Strategy.doShort(Msg Strategy.MARKETStrategy.THISBARStrategy.DEFAULT, EntryPrice .0050); 
        }
        if(
    vLastAlert!=1)drawTextRelative(0high(-1), "S"Color.redColor.yellowText.FRAME Text.ONTOP Text.CENTER Text.BOTTOM Text.BOLDnull12);
        
    vLastAlert=1;

    It is not reversing a trade when it hits a 50 pip drawdown.

    Thanks for your Time
    EK

  • #2
    Hello EK,

    You are using the entry constants .MARKET/.THISBAR, which will use the open of the bar being processed for the entry. If you want to use the close of the bar as the entry use .CLOSE/.THISBAR. Or you could use the open of the next bar with .MARKET/.NEXTBAR.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment

    Working...
    X