zzdream:
Hi all,
Having an issue closing orders .
Here is the code for filtering:
Apply only your filter to your opening then.Hi all,
Having an issue closing orders .
Here is the code for filtering:
This is working fine, new trades are not opening. The issue is getting out of the trade. Ie. trade is placed at 7:45am gmt and exit is signaled at 8:15am. Nothing will happen, no tp, breakeven etc..
This is how I normally get out of a trade:
And have tried:
The above basically closes the trade exactly at 7:50am. Not what I am looking from. I want to exit the trade at my normal exit above bypassing the time filter.
... if(Opening_condition) { if( ! (Hour()>=0 && Hour()<=4 || Hour()>=8 && Hour()<=24)) { // Open your trade... } } // Close...See also these posts about mixing of && and ||.
Thanks for the reply. Makes sense :)
Question:
Why is condition being evaluated as true:
Why is condition being evaluated as true:
if (abc>0 && hour()>=4 && hour()<=5) { buy=true; }Testing this, and trying to only trade from 4am gmt to 5am gmt. Trades are being opened at 6:05am.
zzdream:
Question:
Why is condition being evaluated as true: Testing this, and trying to only trade from 4am gmt to 5am gmt. Trades are being opened at 6:05am.
Question:
Why is condition being evaluated as true: Testing this, and trying to only trade from 4am gmt to 5am gmt. Trades are being opened at 6:05am.
Because it is true . . . Print() hour() and see what you get . . . better still . . .
Print("Hour() returns: ", Hour(), " current time is : ", TimeToStr(TimeCurrent(), TIME_DATE|TIME_MINUTES) );
Thanks for replying,
I'll test the above when I get a chance. Can you please explain why ? Please excuse my ignornance ..totally new to this stuff..however find it extremely fascinating. I thought the code above will build a block around the two hours 4 & 5, nothing above or below.
I'll test the above when I get a chance. Can you please explain why ? Please excuse my ignornance ..totally new to this stuff..however find it extremely fascinating. I thought the code above will build a block around the two hours 4 & 5, nothing above or below.
zzdream:
Thanks for replying,
I'll test the above when I get a chance. Can you please explain why ? Please excuse my ignornance ..totally new to this stuff..however find it extremely fascinating. I thought the code above will build a block around the two hours 4 & 5, nothing above or below.
I have seen Hour() not work as many people expect, others have reported that it works just fine . . . how is it working for you ? and . . . when you say between 4 & 5 you actually mean 4 and 5:59 . . . 5:59 has an Hour() of 5
Thanks for replying,
I'll test the above when I get a chance. Can you please explain why ? Please excuse my ignornance ..totally new to this stuff..however find it extremely fascinating. I thought the code above will build a block around the two hours 4 & 5, nothing above or below.
Right so 4 and 5:59 is ok,but 6:05 should return false..I'm confused.
Thanks Raptor, printing out really helps . Still playing around with different time filter combinations.
zzdream:
Thanks Raptor, printing out really helps . Still playing around with different time filter combinations.
So was Hour() correct ?
Thanks Raptor, printing out really helps . Still playing around with different time filter combinations.
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
Having an issue closing orders .
Here is the code for filtering:
This is working fine, new trades are not opening. The issue is getting out of the trade. Ie. trade is placed at 7:45am gmt and exit is signaled at 8:15am. Nothing will happen, no tp, breakeven etc..
This is how I normally get out of a trade:
And have tried:The above basically closes the trade exactly at 7:50am. Not what I am looking from. I want to exit the trade at my normal exit above bypassing the time filter.