I need help on coding an indicator. I have a moving average, where if it turns up from first being down (point 1), the code will plot a line connecting the recent low to the average's value at the spot it turned up (point 2). It will then extend the trendline until the price closes through it (connect point 1 to point 2 with a line). I posted a chart showing the trendline and then drew a trendline connecting the low to where the average first turned back up.
Below is the code I have so far to at least change colors when the trend change happens.
Below is the code I have so far to at least change colors when the trend change happens.
Code:
input tenkan_period = 9;
plot Tenkan = (Highest(high, tenkan_period) + Lowest(low, tenkan_period)) / 2;
Tenkan.DefineColor("Up", GetColor(1));
Tenkan.DefineColor("Down", GetColor(0));
Tenkan.DefineColor("Neutral", GetColor(4));
Tenkan.AssignValueColor(if Tenkan > Tenkan[1] then Tenkan.color("Up") else if Tenkan < Tenkan[1] then Tenkan.color("Down") else Tenkan.color("Neutral"));