Can some one please point me in the correct direction for some code, I am aiming for the following:
Close at a set time on a previous day
Where the time and the relative day are variable.
Many thanks
How can you close at a set time on a previous day, say yesterday?
You should have closed yesterday.
Apologies I might not have been clear in my wording. I am trying to perform a price test on historic prices as a set time of day to base the decision to open on.
In words I am trying to achieve the following:
I want the price at 4pm 5 days ago to compare to the price at 4pm yesterday. If this is positive I will open a position at the today at 11am .
I have tried the below but is it not working as expected on 1 hour charts
IF (dclose (5) <= dclose(1)) AND (hour=16 and minute = 0000) THEN
C1= 1
endif
IF (C1=1 AND time = 080000 AND not daysForbiddenEntry) THEN
BUY 1 PERPOINT AT MARKET
ENDIF
I am sure it must be simple, just new to this and trying to get some basic testing done.
Man thanks for any input in advance.
I understand. It’s not possible to reference past times using brackets as only past bars can be referenced.
You have to save 5 prices at the same time, shifting them as days go by, then compare each day the previous one with the 5th previous one. You’ll have to use 5 different variable names (v11 might allow using arrays, but they are not much help this time):
ONCE Day5 = 999999
ONCE Day4 = 999999
ONCE Day3 = 999999
ONCE Day2 = 999999
ONCE Day1 = 999999
IF time = 160000 THEN
Day5 = Day4
Day4 = Day3
Day3 = Day2
Day2 = Day1
Day1 = close
ENDIF
IF time = 110000 THEN
C1 = 0
IF Day5 <= Day1 THEN
C1 = 1
ENDIF
endif
IF (C1=1 AND time = 110000 AND not daysForbiddenEntry) THEN
BUY 1 PERPOINT AT MARKET
ENDIF
Sorry, I just edited line 15 due to mistyping.