I've been trying to figure this error for a over a weeks now with no luck. Frankly I don't know if it's possible to make it work. I don't know much about scripting, just enough to give myself headaches. I got it down to one final error which I can't fiqure out. Any help is appreciated.
This is line #70, I'm asuming :23 are character from the beginning of the line.
"Syntax error: An 'else' block expected at 75:23"
Diff.AssignValueColor(if Diff >= 0 then if h3 and DiffHi[offset] then Diff.Color("UpperUpFrac") else if Diff <= 0 and h3 and DiffHi[offset] then Diff.Color("LowerUpFrac") else if Diff <= 0 and l3 and DiffLo[offset] then Diff.Color("LowerDwnFrac") else if Diff >= 0 then l3 and DiffLo[offset] else Diff.Color("UpperUpFrac"));
people,
don't post partial code
posting partial code and expecting others to decipher it is lazy.
i had to create 6 variables and 4 colors, just to get started
this is wrong ,
then instead of and
else if Diff >= 0 then l3 and DiffLo[offset]
should be
else if Diff >= 0 and l3 and DiffLo[offset]
-------------------------------
no color listed after this condition
else if Diff >= 0 and l3 and DiffLo[offset]
-----------------------------
you have a then if
Diff.AssignValueColor(if Diff >= 0 then if h3
should end the formula with 2 else's
else color.gray
else color.blue);
this part may have worked, but i changed it anyway
i changed the first part, to check the opposite, to remove the nested if then.
i assumed you want d>= 0 to decide on a color, so i checked for the opposite as the first condition.
if diff < 0 then Color.GRAY
so undesired diff values are not passed on to the if then color choices.
---------------------------
write each condition, each if then, on a different line. it makes it easier to read and debug.
Code:
def offset = 2;
def DiffHi = 1;
def difflo = 0;
def h3 = 1;
def l3 = 0;
plot diff = close;
diff.DefineColor("UpperUpFrac", Color.GREEN);
diff.DefineColor("LowerUpFrac", Color.CYAN);
diff.DefineColor("Lowerupfrac", Color.YELLOW);
diff.DefineColor("LowerDwnFrac", Color.RED);
diff.AssignValueColor(
if diff < 0 then Color.GRAY
else if h3 and DiffHi[offset] then diff.Color("UpperUpFrac")
else if diff <= 0 and h3 and DiffHi[offset] then diff.Color("LowerUpFrac")
else if diff <= 0 and l3 and difflo[offset] then diff.Color("LowerDwnFrac")
else if diff >= 0 and l3 and difflo[offset] then diff.Color("UpperUpFrac")
else color.gray
);
-----------------
original code line fixed
...add else color, at the end
...add color to 4th condition , else if Diff >= 0 and l3 and DiffLo[offset] then ...
Code:
Diff.AssignValueColor(
if Diff >= 0 then
if h3 and DiffHi[offset] then Diff.Color("UpperUpFrac")
else if Diff <= 0 and h3 and DiffHi[offset] then Diff.Color("LowerUpFrac")
else if Diff <= 0 and l3 and DiffLo[offset] then Diff.Color("LowerDwnFrac")
else if Diff >= 0 and l3 and DiffLo[offset] then Diff.Color("LowerDwnFrac")
else Diff.Color("UpperUpFrac")
else color.gray
);