mharoon:
What exactly doesn't work ? Does the TradingDayTime function return the correct value ? Does Closing ALL Open Positions print to the log ?
All , I'm stumpted here... I trying to disable further trading if its Friday 9AM (PST) 17:00 GMT from Server
Here is my code, but it doesn't seem to work...
If also tried this code as well...
as of this writing server time is 19:00 GMT server time
if ( TradingDayTime(vDayOfWeek,vHour,vMinute) == false ) { Print("Trading suspended. It\'s ",vday," after ",vHour,":",vMinute," GMT "); Print("Current Server Time: ",vday," ",Hour(),":",Minute()); /* display=StringConcatenate("Trading suspended. It\'s ",vday," after ",vHour,":",vMinute," GMT "); display=StringConcatenate(display,"\nCurrent Server Time: ",vday," ",Hour(),":",Minute()); Print("Closing ALL Open Positions"); ExitAll(LONG); ExitAll(SHORT); */ } else { Print(" Trading Time OK"); }
Output from log file...
11:00:35 Fibtrading_v4.6 EURUSD,H4: initialized 11:00:35 Fibtrading_v4.6 EURUSD,H4 inputs: TradeSettings="Trade Settings"; Lots=0.1; Stop=0; TakeProfit=0; SLdist=15; TPdist=15; TradeModSettings="Trade Modification Settings"; TrailStart=0; TrailAmount=0; ModTrail=10; LotsStep=0.1; TradeOpenSettings="Trade Opening Settings"; maxOpenOrders=3; maxMA2PriceDistance=20; tradeTimeWaitINmin=15; minPipsToTrade=50; TradeTrendGap=35; eRangeLimit=50; eLossThreshold=3; eLossThreshTimeInMin=1440; resetTrading=false; MAUsageSettings="Trend Usage Settings "; MAUsageSettings2="*** MAKE SURE ONLY ONE OF THESE IS TRUE"; Use30EMA_STEELBLUE=true; Use15EMA_BROWN=false; Use7EMA_RED=false; Use3EMA_OLIVE=false; EnableTradingS="Enable Trading, set to false for testing only "; EnableTrading=true; EnableEmail=false; vDayOfWeek=5; vHour=17; vMinute=59; IndicatorSettings="Indicator Settings"; Ind_Name="Fibtrading_ind_v4.6"; Ind_eFibTF=240; Ind_eFibBars=300; Ind_eFibShift=10; Ind_eFibColor1=(70,130,180); Ind_eFibColor2=(148,0,211); Ind_eMAtf=240; Ind_eMAmode=1; Ind_eMAap=0; Ind_eMA1p=30; Ind_eMA2p=15; Ind_eMA3p=7; Ind_eMA4p=3; 11:01:20 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:32 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:34 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:36 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:38 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:39 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:39 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:40 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:40 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:41 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:43 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:43 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:44 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:46 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:47 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:47 Fibtrading_v4.6 EURUSD,H4: Trading Time OK 11:01:49 Fibtrading_v4.6 EURUSD,H4: Trading Time OK
Does the TradingDayTime function return the correct value ? Looks like it is...
Print("Function Value: ",TradingDayTime(vDayOfWeek,vHour,vMinute));
output in log file...
11:05:46 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:47 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:48 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:52 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:52 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:53 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:54 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:54 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:55 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:05:59 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:06:03 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:06:10 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:06:11 Fibtrading_v4.6 EURUSD,H4: Function Value: 1
bool TradingDayTime(int day, int hour, int min) { bool condition=true; if( DayOfWeek() == day ) { // this is 5 (TRUE) if (Hour() >= hour ){ // Hour is greater than 17 (TRUE) if (Minute() >= min ){ // Minute is 09 (TRUE... hmm should I concatinate the condition) above... condition=false; } } } /* Iteration of code if( DayOfWeek() == day && Hour() >= hour && Minute() >= min ){ condition=false; } */ return(condition); }
Updated code... same resutls in log file...
bool TradingDayTime(int day, int hour, int min) { bool condition=true; if( DayOfWeek() == day ) { if (Hour() >= hour && Minute() >= min ){ condition=false; } } return(condition); }
logfile:
11:13:59 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:00 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:01 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:04 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:05 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:07 Fibtrading_v4.6 EURUSD,H4: Function Value: 1 11:14:09 Fibtrading_v4.6 EURUSD,H4: Function Value: 1
bool TradingDayTime(int day, int hour, int min) { bool condition=true; Print("condition: ",condition,"day :",day," hour: ",hour," min: ",min); if( DayOfWeek() == day ) { if (Hour() >= hour && Minute() >= min ){ condition=false; } } logfile: 11:21:28 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:28 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:28 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:28 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:29 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:29 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59 11:21:29 Fibtrading_v4.6 EURUSD,H4: condition: 1day :5 hour: 17 min: 59
mharoon:
Try using TimeDayOfWeek(TimeCurrent()) instead of DayOfWeek() and like wise with TimeHour(TimeCurrent()) and TimeMinute(TimeCurrent())
Updated code... same resutls in log file...
bool TradingDayTime(int day, int hour, int min) { bool condition=true; Print("Day: ",TimeDayOfWeek(TimeCurrent())," Hour: ",TimeHour(TimeCurrent())," Minutes: ",TimeMinute(TimeCurrent())); if( TimeDayOfWeek(TimeCurrent()) == day ) { if (TimeHour(TimeCurrent()) >= hour ) if( TimeMinute(TimeCurrent()) >= min ){ condition=false; } } return(condition); } logfile: 11:41:19 Fibtrading_v4.6 EURUSD,H4: Day: 5 Hour: 19 Minutes: 41 11:41:19 Fibtrading_v4.6 EURUSD,H4: Day: 5 Hour: 19 Minutes: 41 11:41:26 Fibtrading_v4.6 EURUSD,H4: Day: 5 Hour: 19 Minutes: 41 11:41:26 Fibtrading_v4.6 EURUSD,H4: Day: 5 Hour: 19 Minutes: 41 11:41:26 Fibtrading_v4.6 EURUSD,H4: Day: 5 Hour: 19 Minutes: 41 11:41:26 Fibtrading_v4.6 EURUSD,H4: Function Value: 1
Same woring value " 11:41:26 Fibtrading_v4.6 EURUSD,H4: Function Value: 1"
Interesting ... if I set the min variable to "0" instead of "min" then it works
bool TradingDayTime(int day, int hour, int min) { bool condition=true; Print("Day: ",TimeDayOfWeek(TimeCurrent())," Hour: ",TimeHour(TimeCurrent())," Minutes: ",TimeMinute(TimeCurrent())); if( TimeDayOfWeek(TimeCurrent()) == day ) if (TimeHour(TimeCurrent()) >= hour ) if( TimeMinute(TimeCurrent()) >= 00 ){ condition=false; } return(condition); }
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
All , I'm stumpted here... I trying to disable further trading if its Friday 9AM (PST) 17:00 GMT from Server
Here is my code, but it doesn't seem to work...
If also tried this code as well...