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.
For me...I have try left, right , front, back, up and down..on several suggestions, still haven get it. Please I need more assistance. Please and please.
If I could get any tested with d logic for it, which is to restrict trade for 7days if trade close in loss. Then continue trading after the seven days.
Teddy Odafe #: 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.
For me...I have try left, right , front, back, up and down..on several suggestions, still haven get it. Please I need more assistance. Please and please.
If I could get any tested with d logic for it, which is to restrict trade for 7days if trade close in loss. Then continue trading after the seven days.
Please I eagerly waiting for a kind assistance
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:
TimeCurrent() + PeriodSeconds(PERIOD_D1) * 7;
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.
bool isTradeRestriction()
{
bool retval = false;
if(Time[0] >= restriction_lift_date)
{
//do some logging
retval = false;
}
else
{
//do some logging
retval = true;
}
return retval; // in my opinion, returning the value at the end of the method is best practice. One way into the method, one way out.
}
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
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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.