I’ve updated the code but I knew immediately that it wouldn’t generate the entry signal – it is my fault because I don’t know how to define “Definitehigh” properly. Doing it as “highest[10]” when the market is rising will use a bar that is too recent. In the case of the screengrab, the highest in the range of 10 is simply the previous bar, which isn’t what I want. I need it to look back to find the high that was previously the highest before the market went upwards (at 10:25am on the screengrab). It’s similar to how someone would look back a certain number of bars to find a significant high in a divergence system. How would I do this?
StartTime = 080000
Limitentrytime = 230000
daysforbiddenentry = OpenDayOfWeek=6 OR OpenDayOfWeek=0
Definitehigh=highest[10](high)
ONCE Signal = 0
Ema15 = average[15,1](close)
IF high > (definitehigh[1] + 7) THEN
Signal = 1
ENDIF
IF close < Ema15 THEN
Signal = 0
ENDIF
IF Not OnMarket AND Signal AND ((low <= Ema15) AND (min(open,close) >= Ema15)) and time >=StartTime and time <=LimitEntrytime and not daysForbiddenEntry THEN
BUY 1 perpoint at Market
SET STOP pLOSS 16
SET TARGET pPROFIT 5
ENDIF
graph definitehigh[1]
You can use a LookBack period to shift the search leftwards:
LookBack = 10
Definitehigh=highest[10](high[LookBack])