Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() | Hi, Dave The trick is to check the 250-day-low condition for five days PRIOR, and the four bars SINCE then. OT/OL don't allow looking into the future. ;~) IF L[5]=LLV(250)[5] and HHV(RSI(5),4) >= 85 Then Signal = ShortSignal However, that simple approach will create a ***delayed*** entry signal if the RSI rule is met on days 1-3 after the low rule is met. The correct way to do it is to ask if the RSI rule is met TODAY, and if so, check back for the Low rule being satisfied in the "acceptable" window: dim gI as integer If RSI(5) >= 85 then for gI = 1 to 4 if L[gI]=LLV(250)[gI] then Signal = ShortSignal exit for end if next gI This will give you the earliest possible entry signal that meets your rules. The forum doesn't permit indentation but hopefully you can follow it OK. Note that LLV is an "inefficient" function, so this code tries to minimize its use ... an efficient workaround to LLV for this application requires a lot more code. I doubt that you'd notice the difference, unless your rule allowed for the prior lowest-low to occur a long time before the RSI rule. [Edited by Jim Dean on 10/3/2019 1:06 PM] |