Hello all. I would like to thank all who help people in this forum in advance. My problem is i am trying to set a Buystop order and it should only be active for 8 hours or Until 6:00. I am trying to figure out the Ordersend's Time Expiration area but cannot figure out the correct way. I have looked at other forums where someone sugested Curtime + 8 *3600 or something but taht does not work. It gives me an hour about "green is not a variable" like the time area was not complete or something. I have tried a couple of different ways of doing but am unsuccesful. Also a big bonus would be if this advisor could work with the backtester :). Thank you all very much for your time!
- Metatrader deletes my Pending Order Script.
- [ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5.
- [WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you.
Hi Cory,
You can build it using the CurTime() and add the necessary seconds. See the example:
You can build it using the CurTime() and add the necessary seconds. See the example:
/* ****************************************************************** */ /* DateTime test */ /* ------------------------------------------------------------------ */ /* Copyright and pricing */ /* */ /* This code was developed by coriFX 2005. */ /* */ /* You can use this code to make money as much as you wish without */ /* fee. If you have made your first million using my code, I would */ /* ask you to send me 10%. contact me at { corifx at o2go dot de }. */ /* I will send you the information for money transfer. */ /* */ /* ****************************************************************** */ extern int hoursToAdd = 8; extern int minutesToAdd = 0; int start() { int timeToAdd = ( hoursToAdd * 3600 ) + ( minutesToAdd * 60 ); datetime now = CurTime(); datetime then = now + timeToAdd; Print( "now: ", TimeToStr( now, TIME_DATE | TIME_MINUTES | TIME_SECONDS ), ", timeToAdd: ", timeToAdd, ", then: ", TimeToStr( then, TIME_DATE | TIME_MINUTES | TIME_SECONDS ) ); return( 0 ); }
regards, cori
Cory,
I have never used the expiry parameter in the OrderSend (so thanks cori) but the code below does the job (30 mins in this example). U will also need to test for 18:00.
regards..
I have never used the expiry parameter in the OrderSend (so thanks cori) but the code below does the job (30 mins in this example). U will also need to test for 18:00.
regards..
TotalTrades = OrdersTotal(); for(int cnt=0;cnt<TotalTrades;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if ( ((CurTime()-OrderOpenTime()) > 1800) ) // 1800 is in seconds... { OrderDelete(OrderTicket()); } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register