Announcement

Collapse
No announcement yet.

How to exit position at EOD or MOC?

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

  • How to exit position at EOD or MOC?

    If I use an interval other than 1 minute how do I ensure that I close positions at 16:15 (I'm working with emini's). With 1 minute interval, I can look at each minute and close at 16:14. What if I use 30 minutes?

  • #2
    Try this...

    You would have to do something like the following....


    PHP Code:
      var vHour;
      var 
    vMin;
      var 
    vSec;
      var 
    vDay;
      var 
    vMonth;

    var 
    vEndHour 13;
    var 
    vEndMin 14;


    function 
    main() {

      var 
    vTime = new Date();
    //---------------------------------------------------
    //  Get Time Variables 
      
    vTime getValue("Time"0);
      
    vHour vTime.getHours();
      
    vMin vTime.getMinutes();
      
    vSec vTime.getSeconds();
      
    vDay vTime.getDate();
      
    vMonth vTime.getMonth() +1;

    var 
    currentChartInterval parseFloat(getInterval());

    //  Calculate "if needed MOC on this bar".
     
    var TempHour vHour;
     var 
    TempMin vMin+currentChartInterval;

      if (
    TempMin >= 60) {
        
    TempHour ++;
        
    TempMin -= 60;
      }
      if ((
    TempHour EndHour) || ((TempHour == EndHour) && (TempMin >= EndMin)) {
    //     Issue MOC Order on the CLOSE of this bar
        
    if (Strategy.isLong()) {
         
    Strategy.doSell("MOC"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, close()):
       }
        if (
    Strategy.isShort()) {
         
    Strategy.doCover("MOC"Strategy.LIMITStrategy.THISBARStrategy.DEFAULT, close()):
       }
      }


    Brad Matheny
    eSignal Solution Provider since 2000

    Comment

    Working...
    X