hi, here is my problem
in this case, how can i set all if function to run independently? when i test, i found out that two if function can't run at the same time, if i use "else" all function get executed without taking into consideration the input bool variable. if separate each of them in different function (Bool trade filter) it greatly affects my variables and the returned variables.
i would like each if function to be executed separately, no matter how many is active at the same time. Thanks
I think that's a little bit sloppy as an answer. Doesn't even animate or guide into the right direction.
ok, i will explain it more in detail. I'm trying to write a trading days function so that the ea can only trade on the choosen days.
//--------- Imput Section input bool InpTimeControl = false; // Use time control input bool Monday = false; // Monday input bool Tuesday = false; // Tuesday input bool Wednesday = false; // Wednesday input bool Thursday = false; // Thursday input bool Friday = false; // Friday input bool Saturday = false; // Saturday input bool Sunday = false; // Sunday //------ The main function is bool and return a variable //+------------------------------------------------------------------+ //| CheckTradingTime | //+------------------------------------------------------------------+ bool TimeControlHourMinute() { // i have already defined all variables used, days of the week are ok, server times also. if(DayOfTheWeek==1) WeekDay="Monday"; if(DayOfTheWeek==2) WeekDay="Tuesday"; if(DayOfTheWeek==3) WeekDay="Wednesday"; if(DayOfTheWeek==4) WeekDay="Thursday"; if(DayOfTheWeek==5) WeekDay="Friday"; if(DayOfTheWeek==6) WeekDay="Saturday"; if(DayOfTheWeek==0) WeekDay="Sunday"; Comment ( "The Date is ",YearAndDate,"\n", "Today is ",WeekDay,"\n", "The time is ",HoursAndMinutes,"\n" "TradingIsAllowed= ",TradingAllowed,"\n", "Current Time = ", CurrenTime,"\n"); // Monday Statement if(Monday){ if(DayOfTheWeek==1) TradingAllowed=true; if(DayOfTheWeek !=1) TradingAllowed=false; } if(Tuesday){ if(DayOfTheWeek==2) TradingAllowed=true; if(DayOfTheWeek !=2) TradingAllowed=false; } if(Wednesday){ if(DayOfTheWeek==3) TradingAllowed=true; if(DayOfTheWeek !=3) TradingAllowed=false; } if(Thursday){ if(DayOfTheWeek==4) TradingAllowed=true; if(DayOfTheWeek !=4) TradingAllowed=false; } if(Friday){ if(DayOfTheWeek==4) TradingAllowed=true; if(DayOfTheWeek !=4) TradingAllowed=false; } if(Saturday){ if(DayOfTheWeek==5) TradingAllowed=true; if(DayOfTheWeek !=5) TradingAllowed=false; } if(Sunday){ if(DayOfTheWeek==0) TradingAllowed=true; if(DayOfTheWeek !=0) TradingAllowed=false; } // Return the result to the main function return TradingAllowed; }
The function are basically ok, before to open a trade, if InpTimeControl, then the ea will check which day is allowed or not. but the function stop working when more than one day is set true, however suppose if you choose to trade only on Monday, the function will work extremely weel, if you decided to trade only on Monday and another day, the function stop working, and after many tests i have realize that each day work well when they only one activated at the time.
ok, i will explain it more in detail. I'm trying to write a trading days function so that the ea can only trade on the choosen days.
The function are basically ok, before to open a trade, if InpTimeControl, then the ea will check which day is allowed or not. but the function stop working when more than one day is set true, however suppose if you choose to trade only on Monday, the function will work extremely weel, if you decided to trade only on Monday and another day, the function stop working, and after many tests i have realize that each day work well when they only one activated at the time.
if(DayOfTheWeek==1) { WeekDay="Monday"; TradingAllowed = Monday; }
ok, i will explain it more in detail. I'm trying to write a trading days function so that the ea can only trade on the choosen days.
The function are basically ok, before to open a trade, if InpTimeControl, then the ea will check which day is allowed or not. but the function stop working when more than one day is set true, however suppose if you choose to trade only on Monday, the function will work extremely weel, if you decided to trade only on Monday and another day, the function stop working, and after many tests i have realize that each day work well when they only one activated at the time.
do things only once when you can it is easier to code and understand...
TradingAllowed=false; // do this once if(Monday && DayOfTheWeek==1) TradingAllowed=true; if(Tuesday && DayOfTheWeek==2) TradingAllowed=true; if(Wednesday && DayOfTheWeek==3) TradingAllowed=true; // etc.... // or simplify again.... if((Monday && DayOfTheWeek==1) || (Tuesday && DayOfTheWeek==2) || (Wednesday && DayOfTheWeek==3)) TradingAllowed=true; // or use a switch statement
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi, here is my problem
in this case, how can i set all if function to run independently? when i test, i found out that two if function can't run at the same time, if i use "else" all function get executed without taking into consideration the input bool variable. if separate each of them in different function (Bool trade filter) it greatly affects my variables and the returned variables.
i would like each if function to be executed separately, no matter how many is active at the same time. Thanks