Day of the week into a string variable
-
Please help me implement this.
After successfully closing my trade using the close trade block, I want to save the current day of the week into a string variable and show it in the journal using log message block.The difficulty for me is how to get the day of the week.
Is there a way to know what day of the week is it and save that as a string variable?
-
-
If you use this DayOfWeek(); you will get the number, 0=Sunday. Then write this into custom code.
if (DayOfWeek()==0) Day_variable="Sunday";
else if (DayOfWeek()==1) Day_variable="Monday";
else if (DayOfWeek()==2) Day_variable="Tuesday";
Do this for all days. -
@jstap Thank you
I will try this -
I got it wrong day constant, I meant variable.
-
@jstap
Please how do I save this into a variable or is it automatic and the name of the variable must be Day_variable?Sorry, I have no programming experience

-
Like that, the day variable will always have the day it is, so as you have it should print the name in a log message.
-
@jstap Thank you. It works
-
@jstap
Please I have another issue with this
The custom code runs as if it is directly under on Tick
At the beginning of the day, it logs the week day variable
But I only want it to log the week day variable after a particular profit is reach for the dayI open trades for the day from 10am
The day of the week logs at the first tick of the day, 1 am

-
I am not sure what you're asking, under the once a day block it will only run once at that time.
-
@jstap
I want it to run once a day only after the check profit block is true
But instead it runs at the beginning of each day when the check profit block isn't yet true -
I figured what the problem is
The block is running before another block that resets my group number
Thanks for your help
