MoneyMagnet
Member
The short answer is that I've goofed up . I'm hoping for a longer answer that will help me understand what I'm doing wrong. My purpose is to simply plot a line that I calculate myself, that is not based on a price input. I suspect the problem has to do with the first bar not having a previous bar, but I can't find a clear explanation of how to deal with that situation. Here's what I'm trying:
This is supposed to create a line that zig-zags up and down between 50 and 100, inclusive. No error in TS editor, but nothing shows on the chart...
Code:
def signal;
def dir;
if signal[1] == 100
{dir = -1;}
else
if signal[1] == 50
{dir = 1;}
else
{dir = dir[1];}
if dir == -1 then
{signal = signal - 1;}
else
{signal = signal + 1;}
plot line = signal;
This is supposed to create a line that zig-zags up and down between 50 and 100, inclusive. No error in TS editor, but nothing shows on the chart...