|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Need procedure to only trade at certain times - Please help
Looking for a procedure to Check Time to see if it is within a trade window. My code here is okay but isn't playing nice with the EA when I'm just trying to test a system. Example - I may only want to open trades from 1700GMT - 2000GMT. Anyway, if anyone has a procedure, that would be great. Thanks in advance.
Minnelli .................................................. ......................................... extern bool xTime = TRUE; extern int _xTime_GMT_Offset = 3; extern int _xTime_From = 17; extern int _xTime_To = 20; e bool CheckTime(int ai_start, int ai_stop) { if (xTime) { if (ai_stop > 0 && ai_stop < 6 && Period() == xPerMin && ai_start >= _xTime_From + _xTime_GMT_Offset || ai_start <= _xTime_To + _xTime_GMT_Offset) { g_is_trade_time = TRUE; return (TRUE); } else { g_is_trade_time = FALSE; return (FALSE); } } else { g_is_trade_time = TRUE; return (TRUE); } } |
|
||||
|
Quote:
Also, you haven't shown enough code to know what problems you may be encountering.
__________________
"Don't work harder, work smarter." -- my Java professor Coder for Hire: http://www.firecell-fx.com |
|
|||
|
Hi Ryan - thanks for responding. The code works great when the time is say 17 to 5 or 18 to 6. But when I narrow it down to just open trades between 12 and 14 it doesn't follow directions
I know I didn't place all of the code but I was only looking for something that would allow me to pick the hours I want to trade and then pass the variable g_is_trade_time = TRUE or FALSE.I would even take take something like: 000-100 : True: 100-200: True; 200-300: False; etc... I just assumed someone had something handy and being the creator the one of the best utility EAs on the forum "Swiss Army EA", you may be the man ....................... Long run I'm looking for something that can maybe trade session opens for a couple hours. But the basic need is just a simple start trading at x and stop placing order at y. I was hoping to keep it GMT and just use the offset like I have now. Once we get something we should be able to share it with everyone. I think most folks could use a time to trade piece of code. It can keep them out of session opens or put them in if it's a breakout system. Minnelli |
|
|||
|
Okay came up with - it allows you to pick a time like 17 to 20 or will allow you to jump over midnight for say 17 to 4. The Offset adjusts time according to GMT. The g_is_trade_time is another variable down below in my EA. Now I know I can mod this to handle 3 times if needed.
Globals: extern int GMT_Offset = 0; extern int StartHour1 = 22; extern int EndHour1 = 9; int StartHour1Adj; int EndHour1Adj; Local: bool CheckTime() { //this is used later to see if CheckTime is TRUE if (xTime) { //a user defined bool to see if you use time or not g_is_trade_time = FALSE; bool midnight=false; StartHour1Adj=StartHour1+GMT_Offset; EndHour1Adj=EndHour1+GMT_Offset; if (EndHour1 - StartHour1 < 0) midnight=true; if ((midnight==false&&Hour()>=StartHour1Adj&&Hour()<= EndHour1Adj)) { g_is_trade_time = TRUE; return (TRUE); } if ((midnight==true&&Hour()>=StartHour1Adj&&Hour()<=2 3)) { g_is_trade_time = TRUE; return (TRUE); } if ((midnight==true&&Hour()>=0&&Hour()<=EndHour1Adj)) { g_is_trade_time = TRUE; return (TRUE); } else { g_is_trade_time = FALSE; return (FALSE); } } } |
|
|||
|
How would I make it so I could turn my EA on at say... 6am for 20 minutes, then it shuts off unless a trade is in progress? I know they did something kinda like that in the news trader EA, but i have no idea how to do it. Any help would be awsome
![]() |
|
|||
|
The SkyDart EA had some good logic but didn't work for me.
Minnelli Forex Signal Providers - Journal - My review site |
|
|||
|
Not sure I had a hard enough time getting the big hand to work
Only hours for me...There is a TimeMinute function available. I would think you would need to have code like I just posted with CheckTime and say something like: if(hours() == 6 {return (FALSE);} Then it would not trade during the 6 o'clock hour. I just have the CheckTime tested before it places trades. Minnelli |
|
|||
|
Trading Times function
Minnelli,
I have code that does what you want. It allows times like 2215 to 335 or 0900 to 1030. Attaching file with functions and variables needed to add to your EA. FYI, I also coded the Skydart EA but only used hours to trade. Robert Last edited by MrPip : 06-22-2007 at 08:41 AM. Reason: attaching code |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trade only certain times of day? | pipsweak | Expert Advisors - Metatrader 4 | 1 | 04-01-2007 05:20 PM |
| Changing Times | Pervaz | General Discussion | 3 | 08-29-2006 10:03 PM |
| Metatrader times | guybraun | Metatrader 4 | 2 | 02-15-2006 01:53 PM |
| Trading Times | dennisros | General Discussion | 3 | 02-13-2006 11:42 AM |
| Trade Times | caldolegare | General Discussion | 7 | 11-15-2005 01:07 PM |