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
The code from Leon seem convincing it could work. I have digested it well enough and i am some what convince most likely it will work, if I could get a test sample or a place where it has been working.
Great! I dont suspect you'll have an issue at all. If for some reason you got the errors mentioned in this forum, then dont use Time[] at all, just use TimeCurrent() to get the server's current time, which should be WITHIN the current bar Time[zero] and then use the PERIOD_D1 with the PeriodSeconds() method so you don't have to do all that funny math. It eliminates using chart time completely.
Something like:
I cannot code it for you, you will have to run it in strategy tester. just modify the code a bit; set the date value to 7 days in the future by default, Print() the value of the IsTradeRestriction() and run in strategy tester. You should see it only prints True once the current bar is equal to or greater than the trade restriction date.
ALSO:
You will normalize the code back to my original code and not the simplified way of just returning the value because you will want to perform some logging in those functions. Something like
"TRADE RESTRICTION LIFTED".
This will help you debug when running live and you wonder why certain trades were not taken. You will also do the same when the trade restriction is applied.
@Teddy Odafe, @Leon Clifton Gaines, trustfultrading
Note to all posters. Please insert code properly using the "</>" icon or using Alt-S.
Don't just paste your code in plain text. It's difficult to read and has no context styling and colouring of the respective parts.
So, please, edit your posts (if still possible) and place the code properly.
@Teddy Odafe, @Leon Clifton Gaines, trustfultrading
Note to all posters. Please insert code properly using the "</>" icon or using Alt-S.
Don't just paste your code in plain text. It's difficult to read and has no context styling and colouring of the respective parts.
So, please, edit your posts (if still possible) and place the code properly.
Understood and updated. Thanks Fernando.
Hi,
I would calculate that in seconds. I believe there are 604,800 seconds in a week. Just add that to your close time and wait until the current time TimeCurrent() is greater than that result.
Thank you...all support I got is highly appreciated. They have saw me through the first stage. Thank
Something like this:
Close all trades;
startTrade = false;
datetime waitUntil = TimeCurrent() + 604800;
if(TimeCurrent()>=waitUntil){ startTrade = true ;}
Understood and updated. Thanks Fernando.