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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

MT4 Order Pending Order/Order Modify Issue 1 reply

How does expiration on pending order works? 9 replies

Pending Order Expiration 0 replies

If the pending order is executed,will its order type be changed to order_buy 3 replies

set pending expiration time 2 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 3
Attachments: Pending Order Expiration...
Exit Attachments

Pending Order Expiration...

  • Post #1
  • Quote
  • First Post: Dec 10, 2007 7:11pm Dec 10, 2007 7:11pm
  •  lucidlamp
  • | Joined May 2007 | Status: I do my best while asleep... | 238 Posts
Hi,

The following script will place a buystop using the previous bar high as entry, the previous bar low as stop and the previous pivot high as take profit.

Attached File
File Type: mq4 temp.mq4   < 1 KB | 649 downloads


Now i would like to add an expiration to the pending order. The expiration would correspond to the timeframe in which the script was run.

For example I run the script on a five minute chart. The time I run the script is 2007.12.10 01:22:34. So I would like the script to set the pending order expiration to 2007.12.10 01:25:00. Which would be the next five minute bar, since I am using it on a five minute chart.

For example I run the script on a one hour chart. The time I run the script is 2007.12.10 01:22:34. So I would like the script to set the pending order expiration to 2007.12.10 02:00:00. Which would be the next hour bar, since I am using it on an hourly chart.

For example I run the script on a four hour chart. The time I run the script is 2007.12.10 01:22:34. So I would like the script to set the pending order expiration to 2007.12.10 03:00:00 (which would correspond to my brokers four hour period regimine). Which would be the next four hour bar, since I am using it on an four hour chart.

For example I run the script on a daily chart. The time I run the script is 2007.12.10 01:22:34. So I would like the script to set the pending order expiration to 2007.12.11 00:00:00. Which would be the next daily bar, since I am using it on an daily chart.

The script would be applied to a daily chart primarily, so that would be my priority (setting expiration to the next daily bar). But I would think that when one timeframe is solved the rest will fall into place.

I've been at it for a day or so, trying to figure it out. I've checked code for 'time to next bar' indicators. I've tried multiple methods of swithing to datetime to string dataypes and vice versa. If anyone has a suggestion I am all ears.

Regards,
lucidlamp
  • Post #2
  • Quote
  • Dec 10, 2007 9:18pm Dec 10, 2007 9:18pm
  •  Micro-MiniMe
  • | Joined May 2007 | Status: Seasoned Trader | 820 Posts
Firstly, expiration times must be at least 10 minutes from current time(check the MT4 UserGuide-search for 'expiration').

Here's a code snipit to set expiration time to 10 min:

int et = TimeCurrent()+(PERIOD_M5*60)*2;

OrderSend(Symbol(),OP_BUYSTOP,0.10,0,3,0,0,"0",0,et,Green);

Note: expiration time is set in seconds; hence the need to multiply PERIOD_M5*60 and that by 2 to get 10 min.

Good luck and thanks for this question. It helped me look at expiration times in more detail and I learned in the process as well.
  • Post #3
  • Quote
  • Dec 10, 2007 10:51pm Dec 10, 2007 10:51pm
  •  lucidlamp
  • | Joined May 2007 | Status: I do my best while asleep... | 238 Posts
Hi Micro-MiniMe,

Thanks for the reply.

I have got the script working for a one hour chart, although if it can be coded more effectively I would love to learn how:

Attached File
File Type: mq4 temp.mq4   2 KB | 814 downloads


Running the script and checking the returns in the Expert Window should give you a better idea of what I meant, if you misread my earlier post. The expiration is set to expire upon a new hour bar, and for a four hour chart the expiration would be set to expire upon creation of the next four hour bar, same with daily charts...

I don't know what it will do if executed during the last hour of trading for the week, but I am not worried about that.

The script will also be run at the beginning of the hour bar so the ten minute clause you mentioned will not apply, although that is good to know.

Thanks again,
lucidlamp
  • Post #4
  • Quote
  • Last Post: Dec 10, 2007 11:03pm Dec 10, 2007 11:03pm
  •  Micro-MiniMe
  • | Joined May 2007 | Status: Seasoned Trader | 820 Posts
You were right. I misread your post. Perhaps you should concider deleting all pending orders when a new bar begins. Something like if(Volume[0]>1)run script.
Here's a script to delete all pending orders:
Attached File
File Type: mq4 delete_pending.mq4   1 KB | 1,194 download
  • Platform Tech
  • /
  • Pending Order Expiration...
  • 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