Announcement

Collapse
No announcement yet.

Running an EFS real time

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Running an EFS real time

    Hi,

    I can backtest a formula through the strategy analyzer OK, but I want to set it off real time, rather than backtesting it. Please can you tell me how I do it. Thanks.

  • #2
    Realtime EFSs..

    This really depends on your formula or indicator..

    The first thing you want to do is set most of your code within the following if condition..

    if (getCurrentBarIndex() == 0) {
    // this means you are running the EFS on the current RT bar

    .. your code in here.
    }

    The next thing you have to consider is how your indicator/formula operates. Most of the time, if your formula/indicator (for backtesting) is waiting till the end of the bar, then making decisions, the easiest way to convert it to RT is by adding the following to your system code..

    PHP Code:
    var vRTHour;
    var 
    vRTMin;
    var 
    vRTSec;
    var 
    vHour;
    var 
    vMin;
    var 
    vSec;
    var 
    vDay;
    var 
    vMonth;
    var 
    vYear;
    var 
    vTime = new Date();


    function 
    main() {
    // BLM Added....
    //---------------------------------------------------
    //  Get Time Variables
      
    var vTime = new Date();
      
    vRTHour vTime.getHours();
      
    vRTMin vTime.getMinutes();
      
    vRTSec vTime.getSeconds();
    //---------------------------------------------------
      
    vTime getValue("Time"0);
      
    vHour vTime.getHours();
      
    vMin vTime.getMinutes();
      
    vSec vTime.getSeconds();
      
    vDay vTime.getDate();
      
    vMonth vTime.getMonth() +1;
      
    vYear vTime.getYear();


     if (
    getCurrentBarIndex() == 0) {
     
    //  this means you are running the EFS on the current RT bar


      
    if (nLastRawTime != getValue("rawtime"0)) {
      
    //  this means a new bar has formed. now it is time to check for entry conditions.
         
    BLBarOffset += 1;
         
    nLastRawTime getValue("rawtime"0);


    //  ..  your code in here.
    //  example...
        
    if (close(-1) < close(-2)) {
          .. 
    sell something
       
    }
      }
     }
    //end of main() 
    The trick with this type of code if you have to check the -1 values for all of your entry conditions because you are waiting for a new bar (a new RT bar) to start forming before you check the previous bars for your entry triggers. So, everything you check should be based on bar # -1 or less.

    The other way to handle the RT triggers is in Real-time as they happen. In this example, we'll be checking for the current close() to get above the previous bar's close - or close(-1). But, let's say we only want this trigger to "fire" once ber bar. If this is the case, we have to place a datemarker for this trigger and use this marker as a condition for our entry conditions. Follow along with this example code..

    PHP Code:
    var vRTHour;
    var 
    vRTMin;
    var 
    vRTSec;
    var 
    vHour;
    var 
    vMin;
    var 
    vSec;
    var 
    vDay;
    var 
    vMonth;
    var 
    vYear;
    var 
    vTime = new Date();

    var 
    vEntryTriggerBar null;  // this is our marker

    function main() {
    // BLM Added....
    //---------------------------------------------------
    //  Get Time Variables
      
    var vTime = new Date();
      
    vRTHour vTime.getHours();
      
    vRTMin vTime.getMinutes();
      
    vRTSec vTime.getSeconds();
    //---------------------------------------------------
      
    vTime getValue("Time"0);
      
    vHour vTime.getHours();
      
    vMin vTime.getMinutes();
      
    vSec vTime.getSeconds();
      
    vDay vTime.getDate();
      
    vMonth vTime.getMonth() +1;
      
    vYear vTime.getYear();


      if (
    nLastRawTime != getValue("rawtime"0)) {
      
    //  this means a new bar has formed. now it is time to check for entry conditions.
         
    BLBarOffset += 1;
         
    nLastRawTime getValue("rawtime"0);
      }


     if (
    getCurrentBarIndex() == 0) {
     
    //  this means you are running the EFS on the current RT bar

    //  ..  your code in here.
    //  example...
        
    if ((close() < close(-1)) && (vEntryTriggerBar != BLBarOffset )) {
          .. 
    sell something
         vEntryTriggerBar 
    BLBarOffset;  // set our marker so it can't happen again till another new bar
       
    }
     }
    //end of main() 
    Now, as you see, there is more than one way to accomplish this. I could go on for hours on how to use different facets of EFS to control your EFS. But these are the basics and if you understand what I've shown so far, you should be able to figure out the rest. Most of what I've learned is by trial and error - trying to make it work and fixing the errors.

    Good luck and let me know if I can help.

    B
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Thanks Brad for such a comprehensive response - I'm a newbie, but I'll give it a go.

      Neil.

      Comment

      Working...
      X