# I need help writing a simple line of code that I plan to use in a strategy

##### Well-known member
In my strategy I have multiple indicators I'm trying to work into it effectively and noticed that when one signal shows bullish or bearish for 4 strait bars, it is a good time to exit a long or short position. How would that be translated to code, essentially I need code that would coincide with [bearish data is true for the last 4 bars] but in proper format. Simple I know, but for a novice little things like this can take way more time then they need to to solve. I figured I could sleep and hopefully wake up with an answer.

#### markos

##### Well-known member
VIP
Now you've done it. You can't sleep and wake up to an answer. Sleep is over-rated.
Go into that Gold Mine I shared earlier and look at tab #2, i think, and you'll find an education tab.
Start there and come back when you get stuck with code.
It's not that simple, you didn't give enough info. Sorry.

#### horserider

##### Well-known member
VIP
low <low[1] .... blah,blah,blah. I am sure there is a way like. [low <low,4] Just off top of my had so may not b correct. Search and you shall find.
should be parenthesis... darn keyboard is failing

#### RobertPayne

##### Member
Let's just use @horserider 's example of low < low[1].

Ruby:
``````def lowerLow = low < low[1];
def four_in_a_row = Sum(lowerLow, 4) == 4;

AssignPriceColor(if four_in_a_row then Color.MAGENTA else Color.CURRENT);``````

How this works.

def lowerLow is a boolean that evaluates as either true (this low is lower than the previous one) or false (it's not). Remember, that true = 1 and false = 0. So, add up the last 4 lowerLow's using the Sum() function. If that adds up to 4, then you know that the condition has been true 4 times in a row.