Announcement

Collapse
No announcement yet.

Calling whether EFS code is running in real-time or in a backtest

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

  • Calling whether EFS code is running in real-time or in a backtest

    Hello,

    Is there some function in EFS that I can call, that will tell me if the EFS strategy is running in real-time mode or in backtesting mode?

    For example, the EFS code might return a 1 if running in real-time, or 0 if running in backtesting mode due to the strategy running due to a backtest being done.

    Is this possible in EFS language?

    The reason I ask this question is because in the platform that i used previously, when i applied a strategy to a chart (to do auto trading via generating auto trade signals), it did a backtest first, and then after the backtest was finished the strategy then started to run live in real-time. Also, when the strategy was running in real-time, sometimes when my internet connection went down for a few minutes, when this happened it caused the strategy to "re-calulate" and when it re-calculted this was the same as performing a backtest. Also, due to daily maintenance, the strategy also re-calculated.

    Does this happen in E-signal too? for example, does my computer still remember the values stored in my variables and global variables within an EFS, if my computer goes offline and then goes back online in a few minutes? (assuming that the variables contain values that were recorded say 20 days ago ie 20 bars back from todays bar).

    ALso, in E-signal, is there a daily maintenance period which causes me to be switched to another server at e-signal? if so, does this daily maintenance cause the EFS strategy applied to a chart to "re-calculate" so that the values stored within variables are still retained and remembered by my computer?

    Thanks in advance.

    Regards

    Rod
    Last edited by Rocket130713; 08-14-2008, 06:09 AM.

  • #2
    Re: Calling whether EFS code is running in real-time or in a backtest

    Rod

    Is there some function in EFS that I can call, that will tell me if the EFS strategy is running in real-time mode or in backtesting mode?
    To ensure that the strategy is not executing on historical bars as the script loads in the chart you would check if you are on the last bar using either the isLastBarOnChart() function or a conditional statement such as if(getCurrentBarIndex()==0) that checks if the efs is processing bar index 0 (ie the current bar)

    The reason I ask this question is because in the platform that i used previously, when i applied a strategy to a chart (to do auto trading via generating auto trade signals), it did a backtest first, and then after the backtest was finished the strategy then started to run live in real-time.
    Assuming I understood correctly what you are describing then this is not the case in eSignal. A backtest occurrs only if you run the Strategy Analyzer. For information on the Strategy Analyzer you may want to review the articles available in the Help Guides and Tutorials-> Strategy Analyzer-> Version 2.0 folder in the EFS KnowledgeBase. You may also want to review the Back Testing Tutorials 1-3 which are in the Help Guides and Titorials->Beginner Tutorials folder also in the same KB

    ...when the strategy was running in real-time, sometimes when my internet connection went down for a few minutes, when this happened it caused the strategy to "re-calulate" ...
    I don't think a disconnect/reconnect will cause a reload of the data however you may have a gap in the data which will be filled only with a refresh (see also next answer)

    ...for example, does my computer still remember the values stored in my variables and global variables within an EFS, if my computer goes offline and then goes back online in a few minutes?
    Global variables do not reinitialize unless you reload the efs OR you refresh the data (or request more data) and these variables are initialized within a BARSTATE_ALLBARS conditional statement (see getBarState() in the EFS KnowledgeBase). You should be able to verify this using the following script.
    PHP Code:
    var bInit false;
    var 
    Counter1 1;
    var 
    Counter2 1;

    function 
    main(){   
        
    debugClear()
        if(
    getBarState()==BARSTATE_ALLBARS){
            
    Counter1 1;
        }
        if(
    bInit==false){
            
    Counter2 1;
            
    bInit=true;
        }
        if(
    getBarState()==BARSTATE_NEWBAR){
            
    Counter1++;
            
    Counter2++
        }
        if(
    isLastBarOnChart()){
        
    debugPrintln("Total bars in chart "+getNumBars()+
                     
    " Counter1 "+Counter1+
                     
    " Counter2 "+Counter2);
        }

    Load it in a chart and then refresh the chart using Ctrl+OK. You will see that Counter1 will always match the total number of bars in the chart while Counter2 instead keeps on compounding at each refresh. Also run the script in a chart set to Dynamic mode and you will see the same results as you scroll back in the chart and new data gets added

    ALso, in E-signal, is there a daily maintenance period which causes me to be switched to another server at e-signal?
    Not that I know of
    Hope this helps
    Alex


    Originally posted by Rocket130713
    Hello,

    Is there some function in EFS that I can call, that will tell me if the EFS strategy is running in real-time mode or in backtesting mode?

    For example, the EFS code might return a 1 if running in real-time, or 0 if running in backtesting mode due to the strategy running due to a backtest being done.

    Is this possible in EFS language?

    The reason I ask this question is because in the platform that i used previously, when i applied a strategy to a chart (to do auto trading via generating auto trade signals), it did a backtest first, and then after the backtest was finished the strategy then started to run live in real-time. Also, when the strategy was running in real-time, sometimes when my internet connection went down for a few minutes, when this happened it caused the strategy to "re-calulate" and when it re-calculted this was the same as performing a backtest. Also, due to daily maintenance, the strategy also re-calculated.

    Does this happen in E-signal too? for example, does my computer still remember the values stored in my variables and global variables within an EFS, if my computer goes offline and then goes back online in a few minutes? (assuming that the variables contain values that were recorded say 20 days ago ie 20 bars back from todays bar).

    ALso, in E-signal, is there a daily maintenance period which causes me to be switched to another server at e-signal? if so, does this daily maintenance cause the EFS strategy applied to a chart to "re-calculate" so that the values stored within variables are still retained and remembered by my computer?

    Thanks in advance.

    Regards

    Rod

    Comment


    • #3
      to help any one else that is trying to write some lines of code to determine whether an EFS is calculating in backtest or real_time mode this is the line to insert:

      PHP Code:
      if ( isLastBarOnChart() && getBarState()==BARSTATE_CURRENTBAR 
      this line of code if true tells us that we are on the last bar of chart AND that live ticks are flowing through.

      using LastBarOnChart alone is not really the same, as the EFS can still be on the lastbaronchart and not calculating in real-time. ie when an EFS is calculating once on all previous bars (including the current bar) there is 1 check of last bar just before the EFS goes live, once this last check is done the EFS then will be calculating in real-time with live ticks flowing through.

      hope this helps someone else! Good trading!

      regards

      Rod
      Last edited by Rocket130713; 09-01-2008, 04:14 AM.

      Comment


      • #4
        Rod
        Keep in mind that the condition
        PHP Code:
        if ( isLastBarOnChart() && getBarState()==BARSTATE_CURRENTBAR 
        will evaluate to false on the first tick of every new bar (ie at BARSTATE_NEWBAR) even when running in real time .
        More information on this topic can be found in the Tutorial #4 Understanding Bar State and Bar Indexing which is provided in the Help Guides and Tutorials-> Beginner Tutorials folder of the EFS KnowledgeBase and in the documentation on getBarState() also in the KB
        Alex


        Originally posted by Rocket130713
        to help any one else that is trying to write some lines of code to determine whether an EFS is calculating in backtest or real_time mode this is the line to insert:

        PHP Code:
        if ( isLastBarOnChart() && getBarState()==BARSTATE_CURRENTBAR 
        this line of code if true tells us that we are on the last bar of chart AND that live ticks are flowing through.

        using LastBarOnChart alone is not really the same, as the EFS can still be on the lastbaronchart and not calculating in real-time. ie when an EFS is calculating once on all previous bars (including the current bar) there is 1 check of last bar just before the EFS goes live, once this last check is done the EFS then will be calculating in real-time with live ticks flowing through.

        hope this helps someone else! Good trading!

        regards

        Rod

        Comment

        Working...
        X