Announcement

Collapse
No announcement yet.

EFS Reset--WHY??

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

  • #16
    You have been of great asisstance. Notice how the the data to the right of the orange line is live data that has never been reset since the EFS was loade at 4:50am . But I had to reboot my computer at 4:45 am and lost all the live signals from 2 am to 4:45 am. But I am now able to replace them as they existed.

    Per your suggestion I am trying to implement the reloading of saved live signal using the...

    "if (getBarState == BARSTATE_ALLBARS) {

    I assume the purpose here is to load the missed live data signals ONLY once, at EFS startup, and not at every bar all over again **after** startup.

    For now, I am keeping this EFS as a seperate EFS and not part of my live trading EFS, to keep the live trading EFS as simple as possible. I also have includeded green bars to show the limits of the added live trading signals by searching through the data for the highest and lowest rawtime, and then incrementing these bar offsets by one for each new bar

    However, I had to rem out the getBarState statement/if because when I used it, it did **not** draw the signals. Why not?

    Also, I am trying to keep the green bars shown all the time, but I can not figure out why they disappear after the 2nd bar is loaded -- they stay on for just one bar's duration.

    Here is complete EFS. How can I design this so the signals load just once and not at every bar. Then all the EFS has to do after that is keep the green bars visible and increment the bar offsets by one.

    PHP Code:
    /*************************************************************************************************
    10:00 pm    09MAR06                LIVELOAD.efs   
    **************************************************************************************************
    Last fix:
    TODO: 
    *****************************************************************************************************/
    var vVERSION "1.0xx";
    var 
    = new File("LIVELOAD.txt");
    var 
    sCurrentSignalData null;
    var 
    sCurrentSignalDataArray null;
    var 
    sCurrentSignalDataBAR null;
    var 
    sCurrentSignalDataSYM null;
    var 
    sCurrentSignalDataPRI null;
    var 
    vMinBarRAW 2222222222222;
    var 
    vMaxBarRAW 0;
    var 
    vMinBarOffset null;
    var 
    vMaxBarOffset null;
    var 
    bOneFlag false;

    function 
    preMain() {
        
    setPriceStudy(true);
        
    setShowCursorLabel(false);
        
    setComputeOnClose();

        
    setStudyTitle("Load Live Signals -- v" vVERSION +  " using LIVELOAD.txt");

    // ************** GET EARLIEST/LASTEST BAR LOCATION -- DRAW GREEN LINES BELOW ********************    f.open("rt");
        
    while(!f.eof()) {
            
    sCurrentSignalData f.readln();
            if (
    sCurrentSignalData != null) {
                
    sCurrentSignalDataArray sCurrentSignalData.split("|");
                
    sCurrentSignalDataBAR sCurrentSignalDataArray[0];
                if (
    sCurrentSignalDataBAR vMinBarRAW) {
                    
    vMinBarRAW sCurrentSignalDataBAR;
                }
                if (
    sCurrentSignalDataBAR vMinBarRAW) {
                    
    vMaxBarRAW sCurrentSignalDataBAR;
                }

            }
        }
         
    f.close(); 

    // end PREMAIN

    function main() {

    //    if (getBarState == BARSTATE_ALLBARS) { // THIS DOES NOT WORK
            
    f.open("rt");
            while(!
    f.eof()) {
                
    sCurrentSignalData f.readln();
                if (
    sCurrentSignalData != null) {
                    
    sCurrentSignalDataArray sCurrentSignalData.split("|");
                    
    sCurrentSignalDataBAR sCurrentSignalDataArray[0];
                    
    sCurrentSignalDataSYM sCurrentSignalDataArray[1];
                    
    sCurrentSignalDataPRI sCurrentSignalDataArray[2];
                    if ( 
    rawtime(0) == sCurrentSignalDataBAR ) {
                        
    drawImageRelative(0sCurrentSignalDataPRIsCurrentSignalDataSYMnullImage.RIGHT Image.ONTOP"CM" rawtime(0));
                    }
                }
            }                
             
    f.close(); 
    //    }

        
    if (rawtime(0) >= vMinBarRAW) {
            
    vMinBarOffset =    vMinBarOffset 1
        
    }

        if (
    rawtime(0) >= vMaxBarRAW) {
            
    vMaxBarOffset =    vMaxBarOffset 1
        
    }

    //    if (getCurrentBarIndex() == 0) {
        
    if (isLastBarOnChart()) {
            
    addLineTool(LineTool.VERTvMinBarOffset * -15Color.lime"EARLYBAR");
            
    addLineTool(LineTool.VERTvMaxBarOffset * -15Color.lime"LASTBAR");
        }


    //    setStudyTitle("Load Live Signals -- v" + vVERSION +  " using LIVELOAD.txt. Earliest bar is: " + vMinBarRAW + " ("+ vMinBarOffset*-1 + ") -- RAW = "+ rawtime(0));


    Data file

    1141870980|SystemCheckMarkBlue|1.2015
    1141871220|SystemHappyFace|1.2016
    1141871700|SystemCheckMarkBlue|1.2008
    1141871820|SystemReallyHappyFace|1.200500000000000 1
    1141876740|SystemCheckMarkBlue|1.1999900000000001
    1141876860|SystemReallyHappyFace|1.199890000000000 1
    1141878780|SystemCheckMarkBlue|1.2008
    1141878900|SystemHappyFace|1.2009
    Attached Files
    Last edited by alexmihh; 03-09-2006, 08:08 PM.

    Comment


    • #17
      have I understood your use of

      "if (getBarState == BARSTATE_ALLBARS) {

      statement correctly??

      Comment


      • #18
        Hello Alex,

        Originally posted by alexmihh on 03-09-2006 at 07:08 PM
        You have been of great asisstance. Notice how the the data to the right of the orange line is live data that has never been reset since the EFS was loade at 4:50am . But I had to reboot my computer at 4:45 am and lost all the live signals from 2 am to 4:45 am. But I am now able to replace them as they existed.

        Per your suggestion I am trying to implement the reloading of saved live signal using the...

        "if (getBarState == BARSTATE_ALLBARS) {

        I assume the purpose here is to load the missed live data signals ONLY once, at EFS startup, and not at every bar all over again **after** startup.

        For now, I am keeping this EFS as a seperate EFS and not part of my live trading EFS, to keep the live trading EFS as simple as possible. I also have includeded green bars to show the limits of the added live trading signals by searching through the data for the highest and lowest rawtime, and then incrementing these bar offsets by one for each new bar

        However, I had to rem out the getBarState statement/if because when I used it, it did **not** draw the signals. Why not?
        You miss interpreted my instructions regarding the use of getBarState(). The reason your code does not work with your current check for BARSTATE_ALLBARS is because your routine only checks the current bar that is being process at allbars to see if it had an image, which it doesn't. As each bar is subsequently processed, they are not being checked against the data from your text file because BARSTATE_ALLBARS only occurs once and the beginning of the reset. What I had originally suggested was to open your custom history file and parse all the data into some arrays, then close the file and prevent any new records from being added until your formula is processing bar 0. Now, as the formula processes each bar during the reload, search your array for the rawtime(0) of the bar that is currently being processed. If that value is found, then draw your system image with the corresponding image name and price level.

        When you split the text data from each line in the text file you are currently storing the data in some global variables. As each new line is split you are overriding the previous data. What you need to do is change those variables (sCurrentSignalDataBAR, sCurrentSignalDataSYM and sCurrentSignalDataPRI) into arrays. In your parsing routine you would increment a counter variable by one for each new line of text that gets parsed so that each new line of text gets saved to a unique array element so you can use it later. The global declarations for the arrays would look like this.

        PHP Code:
        var sCurrentSignalDataBAR = new Array();
        var 
        sCurrentSignalDataSYM = new Array();
        var 
        sCurrentSignalDataPRI = new Array(); 
        Then change your parsing routine to populate these arrays at BARSTATE_ALLBARS so that this is executed only once when the chart gets reset. You will also remove the drawImage call from this routine. That part will be performed in a separate routine.

        PHP Code:
        // new parsing routine
            
        if (getBarState == BARSTATE_ALLBARS) { 
                var 
        nCntr 0;
                
        f.open("rt");
                while(!
        f.eof()) {
                    
        sCurrentSignalData f.readln();
                    
        //debugPrintln(sCurrentSignalData);
                    
        if (sCurrentSignalData != null) {
                        
        sCurrentSignalDataArray sCurrentSignalData.split("|");
                        
        sCurrentSignalDataBAR[nCntr] = sCurrentSignalDataArray[0];
                        
        sCurrentSignalDataSYM[nCntr] = sCurrentSignalDataArray[1];
                        
        sCurrentSignalDataPRI[nCntr] = sCurrentSignalDataArray[2];
                        
        nCntr++;
                    }
                }                
                 
        f.close(); 
            } 
        At this point, all of your text file data is stored in those three arrays. Now you will add a separate routine after the allbars routine that checks the rawtime(0) from each bar as the formula continues to reprocess the history one at a time and search through the sCurrentSignalDataBAR array to see if there is a match. If so, then you will use the same array element number as the element that matched the current bar's rawtime(0) return and call the drawImage function using your other arrays. In your search loop, assign the array element number that had a match to some variable such as nNum.

        drawImageRelative(0, sCurrentSignalDataPRI[nNum], sCurrentSignalDataSYM[nNum], null, Image.RIGHT | Image.ONTOP, "CM" + rawtime(0));


        Also, I am trying to keep the green bars shown all the time, but I can not figure out why they disappear after the 2nd bar is loaded -- they stay on for just one bar's duration.
        You only need to draw the lines once when the reload process has completed. Try changing the condition to the following and see if this fixes the problem. Note that I used your bOneFlag variable that was not being used.

        PHP Code:
        //
            
        if (bOneFlag == false) {
                if (
        rawtime(0) >= vMinBarRAW) {
                    
        vMinBarOffset =    vMinBarOffset 1
                
        }    
                if (
        rawtime(0) >= vMaxBarRAW) {
                    
        vMaxBarOffset =    vMaxBarOffset 1
                
        }
            }

            if (
        bOneFlag == false && isLastBarOnChart()) {
                
        addLineTool(LineTool.VERTvMinBarOffset * -15Color.lime"EARLYBAR");
                
        addLineTool(LineTool.VERTvMaxBarOffset * -15Color.lime"LASTBAR");
                
        bOneFlag true;
            } 
        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


        • #19
          In implementing your method to save live signals to text file with, for instance, Euro Futures text file, why do I get price values that have many zeros in them and others that do not??


          1142791140|SystemCheckMarkBlue|1.2245000000000001| EUR1
          1142791200|SystemReallyHappyFace|1.22439|EUR1
          1142793000|SystemCheckMarkBlue|1.2238900000000001| EUR1
          1142507700|SystemReallyHappyFace|1.2237|EUR1
          1142508480|SystemCheckMarkBlue|1.2248|EUR1

          Comment


          • #20
            Hello Alex,

            That is because of JavaScript's floating point (and other languages also) represention of numbers (see this article on .toFixed() in the Core JavaScript Guide in the EFS KnowledgeBase).
            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