Stable signal on watch list


0
0

How are you doing? Hope all is well.

I’m looking for a stable signal in the watch list. Let me explain.

When I’m on Watchlist and I have a 1-minute trend reversal signal, when the 1-minute candle is finished, the signal also disappears.Can you create when the signal appears,it stays until the signal reverse .

I want the red and green color in the Watch List to show several bars AFTER the signal until the signal is reversed

When I’m on Watchlist and I have a 1-minute trend reversal signal, when the 1-minute candle is finished, the signal also disappears.
I want the red and green color in the Watch List to show several bars AFTER the signal until the signal is reversed
Can you create when the signal appears,it stays until the signal reverse .

an example of stable signal created by you:
#———- Signals Section
def upSignal = rsi > ma;
def downSignal = rsi < ma;
plot data = if upSignal then 1 else if downSignal then -1 else 0;
data.AssignValueColor(if data == 0 then Color.CURRENT else Color.BLACK);
AssignBackgroundColor(if data == 1 then Color.GREEN else if data == -1 then Color.RED else Color.CURRENT);

watch list code:input offset = 1;
input withinBars = 1;
def price = close;
def superfast_length = 9;
def fast_length = 14;
def slow_length = 21;
def displace = 0;

def mov_avg9 = ExpAverage(price[-displace], superfast_length);
def mov_avg14 = ExpAverage(price[-displace], fast_length);
def mov_avg21 = ExpAverage(price[-displace], slow_length);

#moving averages
def Superfast = mov_avg9;
def Fast = mov_avg14;
def Slow = mov_avg21;

def buy = mov_avg9 > mov_avg14 and mov_avg14 > mov_avg21 and low > mov_avg9;
def stopbuy = mov_avg9 <= mov_avg14;
def buynow = !buy[1] and buy;
def buysignal = CompoundValue(1, if buynow and !stopbuy then 1 else if buysignal[1] == 1 and stopbuy then 0 else buysignal[1], 0);

def Buy_Signal = buysignal[1] == 0 and buysignal == 1;
def Momentum_Down = buysignal[1] == 1 and buysignal == 0;

def sell = mov_avg9 < mov_avg14 and mov_avg14 < mov_avg21 and high < mov_avg9;
def stopsell = mov_avg9 >= mov_avg14;
def sellnow = !sell[1] and sell;
def sellsignal = CompoundValue(1, if sellnow and !stopsell then 1 else if sellsignal[1] == 1 and stopsell then 0 else sellsignal[1], 0);
def Sell_Signal = sellsignal[1] == 0 and sellsignal;

input method = {default average, high_low};
def bubbleoffset = .0005;
def percentamount = .01;
def revAmount = .05;
def atrreversal = 2.0;
def atrlength = 5;
def pricehigh = high;
def pricelow = low;
def averagelength = 5;
def averagetype = AverageType.EXPONENTIAL;
def mah = MovingAverage(averagetype, pricehigh, averagelength);
def mal = MovingAverage(averagetype, pricelow, averagelength);
def priceh = if method == method.high_low then pricehigh else mah;
def pricel = if method == method.high_low then pricelow else mal;
def EI = ZigZagHighLow(“price h” = priceh, “price l” = pricel, “percentage reversal” = percentamount, “absolute reversal” = revAmount, “atr length” = atrlength, “atr reversal” = atrreversal);
rec EISave = if !IsNaN(EI) then EI else GetValue(EISave, 1);
def chg = (if EISave == priceh then priceh else pricel) – GetValue(EISave, 1);
def isUp = chg >= 0;
def EIL = if !IsNaN(EI) and !isUp then pricel else GetValue(EIL, 1);
def EIH = if !IsNaN(EI) and isUp then priceh else GetValue(EIH, 1);
def dir = CompoundValue(1, if EIL != EIL[1] or pricel == EIL[1] and pricel == EISave then 1 else if EIH != EIH[1] or priceh == EIH[1] and priceh == EISave then -1 else dir[1], 0);
def signal = CompoundValue(1, if dir > 0 and pricel > EIL then if signal[1] <= 0 then 1 else signal[1] else if dir < 0 and priceh < EIH then if signal[1] >= 0 then -1 else signal[1] else signal[1], 0);

def up = within(signal > 0 and signal[1] <= 0, withinBars);
def down = within(signal < 0 and signal[1] >= 0, withinBars);

plot scan = if up[offset] then 2 else if down[offset] then 1 else 0;
scan.assignValueColor(
if up[offset] then color.dark_green
else if down[offset] then color.red
else color.black);
assignBackgroundColor(
if up[offset] then color.dark_green
else if down[offset] then color.red
else color.black);
####################################### END COLUMN

Marked as spam
Posted by (Questions: 3, Answers: 2)
Asked on May 2, 2020 6:54 am
182 views
0
Private answer

I must warn the newbies visiting this forum that the code posted in the question above is full all the worst code writing behavior I have seen. What I am really saying here is don't use that trash as an example of how proper code should be formatted or constructed.

I'm not going to waste any time trying to correct it. But I just want to warn folks because posting garbage code like this in a Q&A forum tends to leads to newbies learning to write garbage code.

From the bottom of the code we need to remove the following:

plot scan = if up[offset] then 2 else if down[offset] then 1 else 0;
scan.assignValueColor(
if up[offset] then color.dark_green
else if down[offset] then color.red
else color.black);
assignBackgroundColor(
if up[offset] then color.dark_green
else if down[offset] then color.red
else color.black);

Then replace those lines of code with the following:

plot scan = signal[offset];
scan.AssignValueColor(if scan == 1 then Color.GREEN else if scan == -1 then Color.RED else Color.CURRENT);

Oh, one last warning about this code. However built this used a built-in study named ZigZagHighLow. This code is subject to having it's plots repaint as new data is added to the chart. Anytime you see the use of any of the ZigZag studies you should just simply walk away. The code that uses ZigZag studies will tend to produce signals that cannot be traded in a live market. Great for training the eyes to identify changes in trend. But useless for back-testing previous signals to find trading opportunities.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on May 2, 2020 8:27 am