Announcement

Collapse
No announcement yet.

Indicator: Transaction Visualizer

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

  • Indicator: Transaction Visualizer

    Hello eSignal EFS community,

    This indicator supposed to read transactions in a text file and plot these in the chart in any timeframe. The text file, located in FormulaOutput, contains the following information (in this case for EUR/AUD):

    PHP Code:
    009;01.03.2012 13:38;S;200000;1.23441
    009
    ;02.03.2012 10:17;B;100000;1.22992
    009
    ;05.03.2012 08:26;B;100000;1.23388
    011
    ;06.03.2012 03:34;B;200000;1.24204
    011
    ;08.03.2012 15:44;S;100000;1.25014
    011
    ;09.03.2012 13:30;S;100000;1.24028
    029
    ;03.04.2012 09:35;B;300000;1.2873
    029
    ;04.04.2012 12:05;S;300000;1.27829 
    (Transaction No;Date/Time;Buy/Sell;Lot;Price)

    Unfortunately, I do not succeed to plot any data. I am able to load the indicator, and there is no syntax error. Any hint, where I should look for the error?

    PHP Code:
     //{{EFSWizard_Description
    //
    //    This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vLastAlert = -1;
    var 
    lines = new Array();
    var 
    index 0;
    var 
    0;
    var 
    type "";
    var 
    lot 0;
    var 
    0;
    var 
    firstrun true;
    var 
    count 0;
    //}}EFSWizard_Declarations


    function preMain() 
    {
       
    /**
        *  This function is called only once, before any of the bars are loaded.
        *  Place any study or EFS configuration commands here.
        */
    //{{EFSWizard_PreMain
        
    setPriceStudy(true);
        
    setStudyTitle("Transaction Visualizer");
        
    setShowCursorLabel(false);
        
    setShowTitleParameters(false);
    //}}EFSWizard_PreMain

        
    var f1 = new FunctionParameter("Path"FunctionParameter.STRING);
        
    with(f1)
        {
            
    setName("File Path");
            
    setDefault("");
        }
        

    }

    function 
    main(Path
    {
        if(
    firstrun)
        {
            var 
    = new File("aud.txt");
            if(
    f.exists())
            {
                
    f.open("rt");
                var 
    line;
                while(!
    f.eof())
                {
                    
    line f.readln();
                    if(
    line == null) break;
                    
    count lines.push(line);
                    
    debugPrintln(count);  
                }
                
    f.close();
            }
            else
            {
                
    debugPrintlnPath );  
            }
            
    index 0;
            
    firstrun false;
        }
        
        if(
    getBarState() == BARSTATE_NEWBAR)
        {
            while(
    index count)
            {
                
    ParseLine();
                
    debugPrintln(" = " rawtime(-1));
                if(
    >= rawtime(-1) && rawtime(0))
                {
                    if(
    type == "B")
                    {
                        
    drawShapeRelative(-1pShape.UPARROWnullColor.blueShape.ONTOP);
                    }
                    else
                    {
                        
    drawShapeRelative(-1pShape.DOWNARROWnullColor.redShape.ONTOP);
                    }
                    
    index++;
                }
                else
                {
                    break;
                }
            }
        }

    //{{EFSWizard_Return
        
    return null;
    //}}EFSWizard_Return
    }

    function 
    ParseLine()
    {
        var 
    lines[index].split(";");
        
    Date.parse(a[1])/1000;
        
    //debugPrintln(a[1] + " - " + t);
        
    type a[2];
        
    lot a[3];
        
    a[4];
    }
        
    function 
    postMain() {
       
    /**
        *  The postMain() function is called only once, when the EFS is no longer used for
        *  the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
    }

    //{{EFSWizard_Actions
        //{{EFSWizard_Action_1
        
    function onAction1() {
            
    vLastAlert 1;
        }
        
    //}}EFSWizard_Action_1
        
    //}}EFSWizard_Actions 

    Daniel

  • #2
    Re: Indicator: Transaction Visualizer

    Daniel
    In [briefly] looking at your code it seems to me that you are not passing the date with the correct order and delimiters
    For more information on the Date Object see this article in the EFS KnowledgeBase
    Alex


    Originally posted by OktogonTrading
    Hello eSignal EFS community,

    This indicator supposed to read transactions in a text file and plot these in the chart in any timeframe. The text file, located in FormulaOutput, contains the following information (in this case for EUR/AUD):

    PHP Code:
    009;01.03.2012 13:38;S;200000;1.23441
    009
    ;02.03.2012 10:17;B;100000;1.22992
    009
    ;05.03.2012 08:26;B;100000;1.23388
    011
    ;06.03.2012 03:34;B;200000;1.24204
    011
    ;08.03.2012 15:44;S;100000;1.25014
    011
    ;09.03.2012 13:30;S;100000;1.24028
    029
    ;03.04.2012 09:35;B;300000;1.2873
    029
    ;04.04.2012 12:05;S;300000;1.27829 
    (Transaction No;Date/Time;Buy/Sell;Lot;Price)

    Unfortunately, I do not succeed to plot any data. I am able to load the indicator, and there is no syntax error. Any hint, where I should look for the error?

    PHP Code:
     //{{EFSWizard_Description
    //
    //    This formula was generated by the Alert Wizard
    //
    //}}EFSWizard_Description


    //{{EFSWizard_Declarations
    var vLastAlert = -1;
    var 
    lines = new Array();
    var 
    index 0;
    var 
    0;
    var 
    type "";
    var 
    lot 0;
    var 
    0;
    var 
    firstrun true;
    var 
    count 0;
    //}}EFSWizard_Declarations


    function preMain() 
    {
       
    /**
        *  This function is called only once, before any of the bars are loaded.
        *  Place any study or EFS configuration commands here.
        */
    //{{EFSWizard_PreMain
        
    setPriceStudy(true);
        
    setStudyTitle("Transaction Visualizer");
        
    setShowCursorLabel(false);
        
    setShowTitleParameters(false);
    //}}EFSWizard_PreMain

        
    var f1 = new FunctionParameter("Path"FunctionParameter.STRING);
        
    with(f1)
        {
            
    setName("File Path");
            
    setDefault("");
        }
        

    }

    function 
    main(Path
    {
        if(
    firstrun)
        {
            var 
    = new File("aud.txt");
            if(
    f.exists())
            {
                
    f.open("rt");
                var 
    line;
                while(!
    f.eof())
                {
                    
    line f.readln();
                    if(
    line == null) break;
                    
    count lines.push(line);
                    
    debugPrintln(count);  
                }
                
    f.close();
            }
            else
            {
                
    debugPrintlnPath );  
            }
            
    index 0;
            
    firstrun false;
        }
        
        if(
    getBarState() == BARSTATE_NEWBAR)
        {
            while(
    index count)
            {
                
    ParseLine();
                
    debugPrintln(" = " rawtime(-1));
                if(
    >= rawtime(-1) && rawtime(0))
                {
                    if(
    type == "B")
                    {
                        
    drawShapeRelative(-1pShape.UPARROWnullColor.blueShape.ONTOP);
                    }
                    else
                    {
                        
    drawShapeRelative(-1pShape.DOWNARROWnullColor.redShape.ONTOP);
                    }
                    
    index++;
                }
                else
                {
                    break;
                }
            }
        }

    //{{EFSWizard_Return
        
    return null;
    //}}EFSWizard_Return
    }

    function 
    ParseLine()
    {
        var 
    lines[index].split(";");
        
    Date.parse(a[1])/1000;
        
    //debugPrintln(a[1] + " - " + t);
        
    type a[2];
        
    lot a[3];
        
    a[4];
    }
        
    function 
    postMain() {
       
    /**
        *  The postMain() function is called only once, when the EFS is no longer used for
        *  the current symbol (ie, symbol change, chart closing, or application shutdown).
        */
    }

    //{{EFSWizard_Actions
        //{{EFSWizard_Action_1
        
    function onAction1() {
            
    vLastAlert 1;
        }
        
    //}}EFSWizard_Action_1
        
    //}}EFSWizard_Actions 

    Daniel

    Comment


    • #3
      Re: Re: Indicator: Transaction Visualizer

      Thanks Alexis,

      Applying the U.S. date format in the text file solves the problem.

      Cheers,
      Daniel

      Comment


      • #4
        Re: Re: Re: Indicator: Transaction Visualizer

        Daniel
        You are welcome
        Alex


        Originally posted by OktogonTrading
        Thanks Alexis,

        Applying the U.S. date format in the text file solves the problem.

        Cheers,
        Daniel

        Comment

        Working...
        X