i need help to finish this code

helo group, i am trying to code a indicator, it is an oscillator, i need to plot the line between 0.25 oversold and 0.65 overbought , so far everything is working fine, but the line is not plotting right, i need those levels, 0.60 overbought and 0.25 oversold

here is the code:

plot data= close;

declare lower;

input FastLength = 4;
input medLength = 8;
input slowLength = 12;

def trRng = trueRange (high, close, low);

def trRngfast = sum(trRng, fastLength);
def trRngmed = sum(trRng, medLength);
def trRngSlow = sum(trRng, slowLength);

def diff = close - min(close[1], low);

def difffast = sum(diff, fastLength);
def diffmed = sum(diff, medLength);
def diffslow = sum(diff, slowLength);

def factorFast = slowLength / fastLength;
def factormed = slowLength / medLength;

def valfast = (difffast / trRngFast) * factorFast;
def valmed = (diffmed / trRngmed) * factormed;
def valSlow = (diffslow / trRngSlow);

plot U1tosc = if trRngFast == 0 or trRngMed == 0 or trRngSlow == 0 then 0 else (valfast + valMed + valSlow) / (factorFast + factorMed + 1);

u1tosc.setDefaultcolor (getcolor (1) );

input over_Bought = .60;
input over_Sold = .25;
input price = close;

plot Oversold = over_Sold;
plot OverBought = over_Bought;

OverSold.SetDefaultColor (GetColor(6) );
OverBought.SetDefaultColor (GetColor (5) );
 
Solution
@barbaros thank you for the respond, just i need the decimal .25 for oversold and .60 for oversold, plot this two level, i dont know how to upload a pictures here
You are plotting the close price with this:
plot data= close;

If the close price is, let's say, 80, your .60 and 0.25 won't show up if you don't have autoscale on as they are too small.
I was asking about the value of the other plots for this reason as well.
You can't just add percent plots to show up. Solution is to scale them to what actual values they need to be. For this, you need to understand the indicator values and do the math.

If you don't want to merge the close price into this indicator, remove that line and it should be better.

barbaros

Administrator
Staff member
@barbaros thank you for the respond, just i need the decimal .25 for oversold and .60 for oversold, plot this two level, i dont know how to upload a pictures here
You are plotting the close price with this:
plot data= close;

If the close price is, let's say, 80, your .60 and 0.25 won't show up if you don't have autoscale on as they are too small.
I was asking about the value of the other plots for this reason as well.
You can't just add percent plots to show up. Solution is to scale them to what actual values they need to be. For this, you need to understand the indicator values and do the math.

If you don't want to merge the close price into this indicator, remove that line and it should be better.
 
Solution

spartandir

New member
@barbaros can you help me to create a scan for this indicator please, to get stock below the 0.25 for bullish and 0.60 for bearish, also do you think can help me with the watch list as well. thank you in advance
you can use the scan functionality to make this work. use price and study. close > oversold or close < overbought. ( you will need 2 scans). once you save them, you can create and alert and save it as watchlist and it will automatically update. keep in mind that scans/watchlists tend to have a delay.
 
Top