1
Welcome to the BEST forum for traders
Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Hi
That's because longCondition_0 and longCondition_1 need to be declared above the first if
Should be
type = input(0)
var bool longCondition_0 = false
var bool longCondition_1 = false
if type == 0
longCondition_0 := (ta.crossover(EMA5,EMA20) and (DI_Up > DI_Down))
longCondition_1 := ((EMA5 > EMA20) and ta.crossover(DI_Up,DI_Down))
else
longCondition_0 := (ta.crossover(EMA5,EMA20) and tsi_condition)
longCondition_1 := ((EMA5 > EMA20) and tsi_condition)
if ((longCondition_0 or longCondition_1))
strategy.entry("Buy", strategy.long)
Hi I'm trying to script an option (variable entitled type
) to quickly change conditions of entry of a strategy. Even though I use the input() function, the script keeps telling me Undeclared variable longCondition_0
and same for longCondition_1.
Why is that ?
type = input(0)
if type == 0
longCondition_0 = (ta.crossover(EMA5,EMA20) and (DI_Up > DI_Down))
longCondition_1 = ((EMA5 > EMA20) and ta.crossover(DI_Up,DI_Down))
else
longCondition_0 = (ta.crossover(EMA5,EMA20) and tsi_condition)
longCondition_1 = ((EMA5 > EMA20) and tsi_condition)
if ((longCondition_0 or longCondition_1))
strategy.entry("Buy", strategy.long)
Thanks