Page 1 of 1

Mismatched input for 3 bar pattern

Posted: Wed Apr 06, 2022 6:56 am
by AnthonyB
//@version=5
strategy(title="3-Bar-Reversal-Pattern Strategy", shorttitle="3-Bar-Reversal2", overlay = true)
pos = if(close[0] > close[3] and low[0] > low[3] or close[0] > close[3] and low[0] < low[2], 1)
if(close[0] < close[3] and low[0] < low[3] or close[0] < close[3] and low[0] > low[2], -1, nz(pos[1], 0)))

barcolor (pos == -1 ? red: pos == 1 ? green : blue )

line 14: Mismatched input ',' expecting ')'.
This is line 14
pos = if(close[0] > close[3] and low[0] > low[3] or close[0] > close[3] and low[0] < low[2], 1)

Am I missing a comma or bracket?

Re: Mismatched input for 3 bar pattern

Posted: Wed Feb 01, 2023 8:12 pm
by processingclouds
Hey,

I have cleaned the above code and i think this is what you are trying to do:

Code: Select all

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © processingclouds

//@version=5
strategy(title="3-Bar-Reversal-Pattern Strategy", shorttitle="3-Bar-Reversal2", overlay = true)
pos = if(close[0] > close[3] and low[0] > low[3] or close[0] > close[3] and low[0] < low[2])
    1
else
    if(close[0] < close[3] and low[0] < low[3] or close[0] < close[3] and low[0] > low[2])
        -1
    
barcolor (pos == -1 ? color.red: pos == 1 ? color.green : color.blue )
Note: I am not sure what you are trying to do with nz(pos[1],0).