Announcement

Collapse
No announcement yet.

Need help with simple EFS

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

  • Need help with simple EFS

    Hi,

    I am using renko charts and what I am trying to do is on the close of every brick that is in the opposite direction of the previous brick open a trade in the driection of the current completed brick.

    Now I thought this would be easy but the 2 things I am having a problem with is

    1). Cant get the Arrows to show up on the correct brick.

    2). When runing the back test if there is only 1 brick at the far right in a different direction a trade is not opened.


    PHP Code:
    //External Variables
    var nBarCounter            0;
    var 
    nFac                null;
    var 
    nVal2                null;
    var 
    aFPArray            = new Array();
    var 
    bInitialized        false;
    var 
    OldPlot             0;
    var 
    nStatus     0;
    var 
    nAdj        0;
    var 
    grID        0;
    var 
    nFontSize   10;
    var 
    EntryPrice  0;
    var 
    AlertYes    = -1;

    //== PreMain function required by eSignal to set things up
    function preMain() {
    var 
    x;

        
    setPriceStudy(true);
        
    setStudyTitle("EK New");
        
    setShowTitleParametersfalse );
        
    setComputeOnClose(true);
        
        
    //initialize formula parameters
        
        
    aFPArray[x] = new FunctionParameter"DoAlert"FunctionParameter.STRING);
        
    withaFPArray[x] ) {
            
    addOption("Yes");
            
    addOption("No");
            
    setDefault("Yes");
        }  
    }

    //== Main processing function
    function mainDoAlert ) {
        
        
    //script is initializing
        
    if ( getBarState() == BARSTATE_ALLBARS ) {
            return 
    null;
        }

        if ( 
    bInitialized == false ) {
        
            if ( 
    DoAlert == "Yes" )
                
    AlertYes 1;
            else
                
    AlertYes = -1;
                
            
    bInitialized true;
        }

        
    //called on each new bar
        
    if ( getBarState() == BARSTATE_NEWBAR ) {
            if (
    nStatus == -|| nStatus == )
            {
                if (
    close() > close(-1) )
                {
                    
    EntryPrice close()
                    
    goLong();
                }
            }
            if (
    nStatus == || nStatus == )
            {
                if (
    close(-1) > close() )
                {
                    
    EntryPrice close();
                    
    goShort();
                }
            }
        }
    }


    //== gID function assigns unique identifier to graphic/text routines
    function gID() {
        
    grID ++;
        return( 
    grID );
    }

    //== draw the buy/sell arrows and text
    function drawBuySellsTextnDirnColornPrice ) {
    var 
    nOffset;

        
    nOffset getCurrentBarIndex()==1;
        
        
    //buy or cover
        
    if ( nDir==) {
            
    drawShapeRelative(-2low(nOffset)-nAdj,  Shape.UPARROW""Color.magentaShape.TOP Shape.ONTOP gID());
            
    drawTextRelative(-2low(nOffset)-(nAdj*1.5), sTextnColornullText.CENTER Text.TOP Text.BOLD Text.ONTOPnullnFontSizegID());
            return( 
    true );
        }
        
        
    //short or sell
        
    if ( nDir==-) {
            
    drawShapeRelative(-2high(nOffset)+nAdjShape.DOWNARROW""Color.maroonShape.BOTTOM Shape.ONTOP gID());
            
    drawTextRelative(-2high(nOffset)+(nAdj*1.5), sTextnColornullText.BOTTOM Text.CENTER Text.BOLD Text.ONTOPnullnFontSizegID());
            return( 
    true );
        }
    }  

    //== initiate a long trade
    function goLong() {
        
    nStatus 1;
        
    Strategy.doLong("Long"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT );    
        
    //drawBuySell( "Long", 1, Color.green, open(1) );
        
    if ( AlertYes ){
            
    Alert.email("Go Long""EK Alert");
            
    Alert.addToListgetSymbol(), "Go Long"Color.RGB(0,0,0), Color.RGB(0,0,255) );
            
    Alert.playSound"v:\\vault\\Hey Boy Sound.wav" );
        }
    }

    //== initiate a short trade
    function goShort() {
        
    nStatus = -1;
        
    Strategy.doShort("Short"Strategy.CLOSEStrategy.THISBARStrategy.DEFAULT );        
        
    //drawBuySell( "Shrt", -1, Color.red, open(1) );
        
    if ( AlertYes )
        {
            
    Alert.email("Go Short""EK Alert");
            
    Alert.addToListgetSymbol(), "Go Short"Color.RGB(0,0,0), Color.RGB(255,0,0) );
            
    Alert.playSound"v:\\vault\\Hey Boy Sound.wav" );
        }

    Any Ideas?

    Thanks for your Time and Effort
    EK
    Last edited by Emerald King; 08-14-2005, 03:28 AM.

  • #2
    EK
    1) On which brick should they be drawn? It would seem that they will be drawn in different locations when on historical or real time bars.
    2) Remove setComputeOnClose()
    Alex

    Comment


    • #3
      Will Try

      Hello Alex,

      Thanks for taking the time to answer my questions.

      I will see how it turns out on real time bars as to where the arrows show up.

      Thanks
      EK

      Comment


      • #4
        it Works

        Everything is working !

        Thanks
        EK

        Comment

        Working...
        X