@robertogozzi
Perfect 😊, I’ve been racking my brain for another 40 minutes to understand your explanation and that of @JC_Bywan
@All
I thank you very much for your answers and your help,
I finally realized my mistake, which was simply that I was not resetting my variable, I was torturing my head to make it true but it was never reset to false
I enclose a small diagram that could help other readers before throwing it away
hi everyone,
that is now my day of week period for my math :
IF (DayOfWeek = 1 AND Time > 080500) THEN
MyMondayPeriod = 1
MyFridayPeriod = 0
ENDIF
IF (DayOfWeek >= 2 AND Time > 080500) THEN
MyMondayPeriod = 0
ENDIF
IF (DayOfWeek = 2 AND Time > 080500) THEN
MyTuesdayPeriod = 1
ENDIF
IF (DayOfWeek >= 3 AND Time > 080500) THEN
MyTuesdayPeriod = 0
ENDIF
IF (DayOfWeek = 3 AND Time > 080500) THEN
MyWednesdayPeriod = 1
ENDIF
IF (DayOfWeek >= 4 AND Time > 080500) THEN
MyWednesdayPeriod = 0
ENDIF
IF (DayOfWeek = 4 AND Time > 080500) THEN
MyThursdayPeriod = 1
ENDIF
IF (DayOfWeek >= 5 AND Time > 080500) THEN
MyThursdayPeriod = 0
ENDIF
IF (DayOfWeek = 5 AND Time > 080500) THEN
MyFridayPeriod = 1
ENDIF
I find myself with a new problem, I will try to think about it and especially to formulate the question well 😊
MyMondayPeriod = 0
MyTuesdayPeriod = 0
MyWednesdayPeriod = 0
MyThursdayPeriod = 0
MyFridayPeriod = 0
MySaturdayPeriod = 0 // Theoretically.
MySundayPeriod = 0 // Theoretically.
IF (DayOfWeek = 1 AND Time > 080500) THEN
MyMondayPeriod = 1
ENDIF
IF (DayOfWeek = 2 AND Time > 080500) THEN
MyTuesdayPeriod = 1
ENDIF
[...] // :-)
that is my new code :
IF (DayOfWeek = 1 AND Time > 080500) THEN
MyMondayPeriod = 1
MyFridayPeriod = 0
ENDIF
IF (DayOfWeek = 2 AND Time > 080500) THEN
MyMondayPeriod = 0
MyTuesdayPeriod = 1
ENDIF
IF (DayOfWeek = 3 AND Time > 080500) THEN
MyTuesdayPeriod = 0
MyWednesdayPeriod = 1
ENDIF
IF (DayOfWeek = 4 AND Time > 080500) THEN
MyWednesdayPeriod = 0
MyThursdayPeriod = 1
ENDIF
IF (DayOfWeek = 5 AND Time > 080500) THEN
MyThursdayPeriod = 0
MyFridayPeriod = 1
ENDIF
@PeterSt
Thank you very much for your answer, I tested your code but it does not work as I want, I explain :
my Monday period starts on Monday at 08:05 and ends on Tuesday at 08:00
with your method that we will call solution B, the condition is false between the bar index 0 of Tuesday until Tuesday 8:00 am
Solution A (Mine) :
IF (DayOfWeek = 1 AND Time > 080500) THEN
MyMondayPeriod = 1
ENDIF
IF (DayOfWeek = 2 AND Time > 080500) THEN
MyMondayPeriod = 0
ENDIF
Solution B (PeterSt) :
MyMondayPeriod = 0
IF (DayOfWeek = 1 AND Time > 080500) THEN
MyMondayPeriod = 1
ENDIF
with your method that we will call solution B, the condition is false between the bar index 0 of Tuesday until Tuesday 8:00 am
I understand. But I had to guess that your Instrument would open at 08:00 – e.g. almost all Eurex.
So what you say is that e.g. on Monday at 07:55 you still want to use Friday as MyxxxxPeriod ?
Anyway, I thought to rewrite your code a little shorter and with less redundancy. If that functionally can’t work (I understand that now) then apologies for the noise.
I understand. But I had to guess that your Instrument would open at 08:00 – e.g. almost all Eurex.
Yes, you’re right, the goal is to learn and master the programming, I also say to myself that Forex is a 24 hour market and that it is traded mostly by robots like all markets, so start at 8am or just after or just before, I think we understand each other
So what you say is that e.g. on Monday at 07:55 you still want to use Friday as MyxxxxPeriod ?
As far as the period from Friday to Monday 8am is concerned it doesn’t make sense, but as I take trades due every day from 8am onwards I would like to know how much I lost the day before, hence the calculation of this period in case on Friday I don’t cut all or part of my position and there are leftovers
Anyway, I thought to rewrite your code a little shorter and with less redundancy. If that functionally can’t work (I understand that now) then apologies for the noise.
you have thought and you have done very well to answer me, any answer or remark or criticism is more than welcome 😃
@PeterSt
You did well to ask the question, I noticed that there was an overlap and that the values were not reset at the right time between Friday and Monday 😊