Login Page - Create Account

Support Board


Date/Time: Sun, 12 Jan 2025 14:53:59 +0000



Post From: Spreadsheet study help

[2017-02-18 16:33:04]
Sawtooth - Posts: 4149
There is no 'one solution fits all' for this, but here is the basic idea:

Use a Formula Column to create a persistent variable of 'condition buy', e.g. column O:
=IF('condition buy',1,IF('condition sell',0,O4))

Use another Formula Column to count bars since 'condition buy', e.g. column P:
=IF(AND(O4=1,O3=0),0,IF(O3=1,P4+1,P4))

Use 2 more Formula Columns to repeat for 'sell condition', e.g. columns Q and R

Then your example looks like this:
=IF(AND(condition1,P3<R3),1,0)

Or more simply, like this:
=AND(condition1,P3<R3)