BradParticipant
Junior
Hi All,
Could someone please confirm the logic in the following code?
IF (DayOfWeek = 1 AND Time <= 080000) THEN
Trading = 0
ELSE
Trading = 1
ENDIF
The code specifies that no entries are allowed if it is Monday and the time is at or before 08:00.
What happens if my trigger candle meets all the entry conditions, opens at 08:00, and closes at 08:15? Is this considered a valid entry, given that the candle closes at 08:15?
Regards,
Brad
trigger candle meets all the entry conditions, opens at 08:00
But it wouldn’t meet the condition Time <= 080000, you would need to use Time < 080000?
BradParticipant
Junior
My concern is when testing it on the demo account, the trade is triggered.
The candle that triggers the trade is the close of the 07:45 candle (which is < 080000) and then the trade is opened at 080000.
Did you try it with Time < 080000 (not <=) is the trade still opened at 080000?
EDIT / PS
Just cheked your ss and the trade is opened at 081500 after being triggered at the close of the 080000 candle … so that is correct as your code??
Exactly. As Grahal says, the activation occurs on the previous candle. The reason is that the condition Time <= 080000 is true on the previous candle (at the close of the candle it is already 8:00).
BradParticipant
Junior
So, to avoid confusion, is the demo entry correct, as seen in the screenshot?
Yes, demo entry is correct as per your code … IF (DayOfWeek = 1 AND Time <= 080000) THEN
BradParticipant
Junior
Thanks for the clarification, gents. That means a live trade was not triggered.
If you run this code you will se the entry ARROW plotted just under the candle labelled 08:00 every Monday, since the trade is actually entered at 08:00 because the order is placed when the 07:45 candle closes:
IF OnMarket THEN
SELL at Market
ENDIF
IF (DayOfWeek = 1 AND Time = 080000) THEN
BUY at MArket
ENDIF
replacing line 4 by this one, you will se the entry ARROW plotted just under the candle labelled 08:15 every Monday, since the trade is actually entered at 08:15 because the order is placed when the 08:00 candle closes.
IF (DayOfWeek = 1 AND OpenTime = 080000) THEN
BradParticipant
Junior
Thanks Roberto
Small changes can make big differences!