EA will not manage trade outside time filter

 
extern bool   TradeOnFriday     =true;        //trade on friday
extern int    FridayStartHour     =9;            //start hour time filter on friday
extern int    FridayEndHour       =12;          //end hour time filter on friday

void start()  {
//+------------------------------------------------------------------+
//|               Day&Time Filter                                    |
//+------------------------------------------------------------------+
bool TradeHour;
if( 

(TradeOnFriday==false&&DayOfWeek()==5)||
(TradeOnFriday&&DayOfWeek()==5&&!Hour()>=FridayStartHour)||
(TradeOnFriday&&DayOfWeek()==5&&!Hour()<=FridayEndHour-1)

)
return(TradeHour);

//+------------------------------------------------------------------+
//|               Rest of Code                                       |
//+------------------------------------------------------------------+

I install'd time filter in the very beginning of the EA and it works fine,open trade only in trading hours, problem is EA will not manage open trade outside time filter. 

TrailingStop will not work. i believe the EA at all stop working outside time filter.

How do i create time filter to open trade (EA does it already) but keep on managing open trade outside time?

Please point me in the right way! 

Thanks alot

sorry about my Denglish

Denglish=(Deutsch+English) 

 
pieronetto:

I install'd time filter in the very beginning of the EA and it works fine,open trade only in trading hours, problem is EA will not manage open trade outside time filter. 

TrailingStop will not work. i believe the EA at all stop working outside time filter.

How do i create time filter to open trade (EA does it already) but keep on managing open trade outside time?

Please point me in the right way! 

Thanks alot

sorry about my Denglish

Denglish=(Deutsch+English) 

<CODE DELETED>

Please read some other posts before posting . . .

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 

Rest of Code   is not executed if  . . .

return(TradeHour);
 
RaptorUK:

Please read some other posts before posting . . .

Please edit your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 

Rest of Code   is not executed if  . . .

extern bool   TradeOnFriday     =true;        //trade on friday
extern int    FridayStartHour     =9;            //start hour time filter on friday
extern int    FridayEndHour       =12;          //end hour time filter on friday

void start()  {
//+------------------------------------------------------------------+
//|               Day&Time Filter                                             |
//+------------------------------------------------------------------+
bool TradeHour;
if( 

(TradeOnFriday==false&&DayOfWeek()==5)||
(TradeOnFriday&&DayOfWeek()==5&&!Hour()>=FridayStartHour)||
(TradeOnFriday&&DayOfWeek()==5&&!Hour()<=FridayEndHour-1)

)
return(TradeHour);

//+------------------------------------------------------------------+
//|               Rest of Code                                                  |
//+------------------------------------------------------------------+

 
pieronetto:
Thanks for the src tip, what should i change?
 
pieronetto:
Thanks for the src tip, what should i change?

If you want your "time filter" to apply just to opening trades then check it before you place a trade and if it applies don't place the trade.

Please edit your first post.

 
RaptorUK:

If you want your "time filter" to apply just to opening trades then check it before you place a trade and if it applies don't place the trade.

Please edit your first post.

So what you saying is the TF is in the wrong place in the EA.

Thanks for the quick respond. 

 
pieronetto:

So what you saying is the TF is in the wrong place in the EA.

Thanks for the quick respond. 

Wrong place or just poorly implemented.

Please edit your first post

 
RaptorUK:

Wrong place or just poorly implemented.

Please edit your first post

Please edit your first post (Hope thats rightnow)

Wrong place and poorly implemented.

To implemented right is there a place (in this forum) i can read about it .

I do believe somone had a simular problem before me.

i do not want to ask somone to writte it for me, thats not the way of learning, i like to find out on my own.

Please do give me derection. 

Thanks again for the fast response 

 
pieronetto: I install'd time filter in the very beginning of the EA, problem is EA will not manage open trade outside time filter.
So manage open trades FIRST and THEN test for opening new ones.
 
pieronetto:

Please edit your first post (Hope thats rightnow)

Wrong place and poorly implemented.

To implemented right is there a place (in this forum) i can read about it .

I do believe somone had a simular problem before me.

i do not want to ask somone to writte it for me, thats not the way of learning, i like to find out on my own.

Thank you for editing your post.

A simple quick modification would be to set a bool variable to true or false depending on the result of the filter instead of using return,  then check this bool before placing a new trade . . . for example . . .

bool TimeFilterAllowTrading;

//  your time filter . . .
TimeFilterAllowTrading = false;   //  instead of return
else TimeFilterAllowTrading = true;

// later in your code where you place trades  . . . 
if(TimeFilterAllowTrading) Ordersend(. . . . );

 
RaptorUK:

Thank you for editing your post.

A simple quick modification would be to set a bool variable to true or false depending on the result of the filter instead of using return,  then check this bool before placing a new trade .

RaptorUK:

Thank you for editing your post.

A simple quick modification would be to set a bool variable to true or false depending on the result of the filter instead of using return,  then check this bool before placing a new trade . . . for example . . .

 

 

Thanks i will work on it, let you know how i do
Reason: