• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 12:45am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 12:45am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Close OPEN n Pending Orders by SET Pair and SET Directional Profit EA 0 replies

How does expiration on pending order works? 9 replies

Pending Order Expiration 0 replies

Help - Expiration Date on MQL EA 1 reply

Pending Order Expiration... 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe

set pending expiration time

  • Post #1
  • Quote
  • First Post: Nov 16, 2007 3:10pm Nov 16, 2007 3:10pm
  •  pgtips
  • | Joined Nov 2007 | Status: Member | 180 Posts
Hi,

this one is throwing me completely, what is the syntax to set a order expiration time, most code I have looked at sets expiration=0 which means keep open until you close it.
Normally you might say I want this to be open for x hours so expiration would be expiration=x

But I want to say "time to close = 15.30" , and so my pending order is closed at 15.50 gmt.

How do i initialise this and plug it in, I have tried everything and am starting to wonder if it is actually possible.
Any examples really appreciated.

Thanks in advance,

KevM
  • Post #2
  • Quote
  • Nov 18, 2007 9:08am Nov 18, 2007 9:08am
  •  Micro-MiniMe
  • | Joined May 2007 | Status: Seasoned Trader | 820 Posts
Hi pgtips,

The wording of your question had me a bit confused so I will answer in this way.

In MT4 order expiration time is set in seconds. Total seconds in a day = 24hrs*60min*60sec = 86400 seconds/day.

Expiration time only exists for pending orders, not open orders. Once an order is open you would need to write a script to close it at a certain time or a certain time after it becomes an open order.

The code to determine how many seconds until the pending order expires is:

Datetime et =((24-Hour())*60-Minute())*60-Seconds();
//Order expiration must be at least 11 minutes so:
if(et<660) et=0;

Hope this helps,
  • Post #3
  • Quote
  • Last Post: Nov 19, 2007 3:44am Nov 19, 2007 3:44am
  •  pgtips
  • | Joined Nov 2007 | Status: Member | 180 Posts
Hi Micro-MiniMe,

thanks for the response. Looking back I didn't word it too well so I'll try again :-)

I want to specify, in the user input box, the time to expire a pending order.

Not as how many hours to stay live for but rather , time to expire = 15:30 (same day in this case).

The math behind it is

time to expire - current time = number of seconds to stay live

What I am having difficulty with though is getting a vlaue out of the calculation which I can pass to the order send line to set a expire time.

Hope this explains a bit more clearly and thanks again for your help.

Kevin
  • Platform Tech
  • /
  • set pending expiration time
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021