Page 1 of 1

RSI BullBack detecttor issue

Posted: Thu Feb 23, 2023 9:44 am
by wirtabittuaali
Hi Fellows , this is my first post in the forum and I am pretty new for Pine. I would need some help for my script because I assume that my "RSI local top" detection does system does not work properly >> script does not give any Entry trigger

I have tried to create "Long Entry Condition" script that has combined two-step entry trigger system:
1. trigger is ta.crossover(rsiLongTrig, rsiTrig2); this trigger stays on and waits for rsiLongTrig to go up and make local top and then comes downwards at least (2) following bars and finally pulls the trigger 2 ON when rsiLongTrig turns up again.

" Long Entry Condition "goes OFF if ta.crossunder(rsiLongTrig, rsiTrig2) and (close < maSig1 or close < maSig2 or close < maSig3)


My current script:
var LongTrigCond = false
float rsiLongTrigTop = na

// Long Entry Triggers
if LONG and ta.crossover(rsiLongTrig, rsiTrig2) // (Trigger 1)
rsiLongTrigTop := rsiLongTrig[1] > rsiLongTrig and rsiLongTrig > rsiLongTrigTop ? rsiLongTrig[1] : rsiLongTrigTop
if rsiLongTrigTop > 0 and rsiLongTrigTop > rsiLongTrig and rsiLongTrig < rsiLongTrig[1]
if rsiLongTrig[3] > rsiLongTrig[2] and rsiLongTrig[2] > rsiLongTrig[1] and rsiLongTrig > rsiLongTrig[1]
LongTrigCond := true

if ta.crossunder(rsiLongTrig, rsiTrig2) and (close < ma1 or close < ma2 or close < ma3)
LongTrigCond := false

I would be really grateful if someone could help me with this issue, thanks for advance

Best regard Jari

Re: RSI BullBack detecttor issue

Posted: Fri Feb 24, 2023 6:28 am
by Steve Burman
Hi Jari,

I have questions about your criteria. I'm assuming rsiLongTrig & rsiTrig2 are the 2 standard RSI lines? You've said your criteria is... 1. trigger is ta.crossover(rsiLongTrig, rsiTrig2); this trigger stays on and waits for rsiLongTrig to go up (IS THAT JUST ONE BAR UP?) and make local top (how do you define LOCAL TOP?) and then comes downwards at least (2) following bars and finally pulls the trigger 2 ON when rsiLongTrig turns up again (IS THAT JUST ONE BAR? UP)

Can you resend with indents and further comments to make it easier to read.

rsiLongTrigTop := rsiLongTrig[1] > rsiLongTrig and rsiLongTrig > rsiLongTrigTop ? rsiLongTrig[1] : rsiLongTrigTop // This line looks fine

Not sure what these mean as they don't seem to match your criteria
if rsiLongTrigTop > 0 and rsiLongTrigTop > rsiLongTrig and rsiLongTrig < rsiLongTrig[1]
if rsiLongTrig[3] > rsiLongTrig[2] and rsiLongTrig[2] > rsiLongTrig[1] and rsiLongTrig > rsiLongTrig[1]
LongTrigCond := true

I look forward to your reply!

Re: RSI BullBack detecttor issue

Posted: Fri Feb 24, 2023 8:11 am
by wirtabittuaali
Hi Steve

I created test indicator for this "2 Step Entry system" >> please check it below
I try to create Entry trigger for my Strategy where I have several other variables for Entry Condition (Long or Short Trends + other market conditions) so this is just Trigger Condition for that >> Final purpose is use Strategy with 3Commas for Trading automation

Answers for your questions:
(IS THAT JUST ONE BAR UP?):
- Yes, Final trigger ON right after first RSI bar turns upwards

(how do you define LOCAL TOP?):
- Hmm this is hard :D.... script should search Local Top as long as RSI rises Up after crossover + when Top has found and we see 2 continuous bars down = Top is confirmed and we start to search next RSI bar which closes upwards == Final Entry signal

I managed to FIX issues that script does not find any trigger point but now it seems that it triggers Entry even if Top has not formed properly

Hopefully I managed to clarify my thoughts to you

Best Regadrs
Jari

////////////////////////////////////////////////////////////////

Code: Select all

//@version=5
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

indicator(title='JAT RSI MTF', format=format.price, precision=2)

// INPUT
ob = input(title='Overbought', defval=70)
os = input(title='Oversold', defval=30)
res1 = input.timeframe(title='Rsi1 Timeframe', defval='6')
res2 = input.timeframe(title='Rsi2 Timeframe', defval='6')
res3 = input.timeframe(title='Rsi3 Timeframe', defval='12')
res4 = input.timeframe(title='Rsi4 Timeframe', defval='24')
len1 = input.int(title='Rsi1 Length', defval=3, minval=1)
len2 = input.int(title='Rsi2 Length', defval=14, minval=1)
len3 = input.int(title='Rsi3 Length', defval=14, minval=1)
len4 = input.int(title='Rsi4 Length', defval=14, minval=1)

allowRepainting = input(true, 'Allow Repainting?')

// CALC
rsiL1 = ta.rsi(close, len1)
rsiL2 = ta.rsi(close, len2)
rsiL3 = ta.rsi(close, len3)
rsiL4 = ta.rsi(close, len4)

rsi1 = allowRepainting ? request.security(syminfo.tickerid, res1, rsiL1) : request.security(syminfo.tickerid, res1, rsiL1[1], lookahead=barmerge.lookahead_on)
rsi2 = allowRepainting ? request.security(syminfo.tickerid, res2, rsiL2) : request.security(syminfo.tickerid, res2, rsiL2[1], lookahead=barmerge.lookahead_on)
rsi3 = allowRepainting ? request.security(syminfo.tickerid, res3, rsiL3) : request.security(syminfo.tickerid, res3, rsiL3[1], lookahead=barmerge.lookahead_on)
rsi4 = allowRepainting ? request.security(syminfo.tickerid, res4, rsiL4) : request.security(syminfo.tickerid, res4, rsiL4[1], lookahead=barmerge.lookahead_on)

// 2 step Long Entry Condition
LongTrigCond = false
if ta.crossover(rsi1, rsi4)  /// Trigger 1, this should stay ON and wait local TOP to form + pull down at least 2 bars + turn back up again to make ENTRY
    float rsiLongTrigPeak = na
    rsiLongTrigPeak := rsi1[1] > rsi1 and rsi1 > rsiLongTrigPeak ? rsi1[1] : rsiLongTrigPeak  // Local TOP calculation
    if rsiLongTrigPeak > 0 and rsiLongTrigPeak > rsi1 and rsiLongTrigPeak > rsi1[1] and rsi1[1] < rsi1[2] and rsi1 < rsi1[1]  //   PullBack Calculations  after Local TOP
        RsiUpOK = false
        if rsi1 > rsi1[1]   //  Final Trigger for Entry
            RsiUpOK := true

LongTrigCond := true

if ta.crossunder(rsi3, rsi4)  //  This is just test Close 
    LongTrigCond := false

// PLOT
plotshape(LongTrigCond, title="Long Entry Trigger", location=location.top, color=color.green)
plot(rsi1, 'RSI 1', color=color.new(#04ff04, 0))
plot(rsi2, 'RSI 2', color=color.new(#ff4141, 0))
plot(rsi3, 'RSI 3', color=color.new(#dad6d6, 0))
plot(rsi4, 'RSI 4', color=color.new(#f3ff45, 1))
upperBand = hline(ob)
lowerBand = hline(os)
fill(upperBand, lowerBand, color=color.new(color.purple, 90))


Re: RSI BullBack detecttor issue

Posted: Fri Feb 24, 2023 8:26 am
by wirtabittuaali
Hi Again
Here is pic of system >> hopefully it clarify more of my purposes

https://drive.google.com/file/d/1RWnat5 ... share_link

BR Jari

Re: RSI BullBack detecttor issue

Posted: Wed Mar 01, 2023 5:31 am
by Steve Burman
Hi Jari,

Thanks for your reply and sorry I haven't been back to you for a while.

When you say "script should search Local Top as long as RSI rises Up after crossover", what do you mean by local top? I'm still trying to understand what local top means to you?