Announcement

Collapse
No announcement yet.

close at end of day

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

  • close at end of day

    Hello,

    I was wondering if someone could help me figure out how to close out of positions (long or short) 5 minutes before the end of each day (15:55 if in a trade). I've attached the file I'm currently working on. I've try to look through this forum for the answers but no luck.

    thanks
    jim
    Attached Files

  • #2
    Jim
    I think the attached does what you want.
    All conditions were added with Formula Wizard so you can use that tool to view and/or edit the efs.
    I have also added the condition that it will not execute trades outside of 9:30-15:55 and a check to see if it is already Long/Short before issuing a Buy/Sell order.
    Alex
    Attached Files

    Comment


    • #3
      Jim
      An additional note and a suggestion for a correction.
      The efs I posted assumes that there will be a bar at 15:55 which may or may not happen depending on whether you are using an interval that will plot a bar with that timestamp or that all bars will be plotted.
      It may be worthwhile to modify Line 70 and 77 respectively to read as follows

      (getHour()*100)+getMinute() >= 1555

      This way if for any reason the 15:55 bar is skipped it should still be able to close a trade on any bars after 15:55
      Alex

      Comment


      • #4
        thank you

        Excellent Alex, that's exactly what I'm looking for,

        thanks for the quick response.

        jim

        Comment

        Working...
        X