Hello @robertogozzi, here is an example:
1. At 1:45 pm, the indicator PRC_AnotherRSIdivergence signals by a red bar a bearish divergence.
2. From this signal, I want my robot to stop buying as long as the RSI is > 30 (but the robot can sellBut the robot must be able to sell if there is a sell signal)
In the image you can see the gray area between the beginning of the signal and the moment when the RSI is < 30.
If it can be useful I attach the code of the indicator:
//PRC_AnotherRSIdivergences | indicator
//25.02.2019
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
RSIp=10
obLevel=70
osLevel=30
// --- end of settings
irsi = rsi[RSIp]
ob = irsi>obLevel
os = irsi<osLevel
if ob then
if not ob[1] then
maxrsi = 0
maxprice = 0
endif
maxrsi=max(maxrsi,irsi)
maxprice=max(maxprice,high)
if maxrsi<>maxrsi[1] then
maxrsibar=barindex
endif
endif
if os then
if not os[1] then
minrsi = 100
minprice = close*100
endif
minrsi=min(minrsi,irsi)
minprice=min(minprice,low)
if minrsi<>minrsi[1] then
minrsibar=barindex
endif
endif
divsell=0
if irsi crosses under obLevel then
//verif divergence
div = maxprice>oldmaxprice and maxrsi<oldmaxrsi
if div then
drawsegment(oldmaxrsibar,oldmaxrsi,maxrsibar,maxrsi) coloured(200,0,0)
drawarrowdown(maxrsibar,maxrsi) coloured(200,0,0)
divsell=osLevel
endif
oldmaxrsi = maxrsi
oldmaxprice = maxprice
oldmaxrsibar = maxrsibar
endif
divbuy=0
if irsi crosses over osLevel then
//verif divergence
div = minprice<oldminprice and minrsi>oldminrsi
if div then
drawsegment(oldminrsibar,oldminrsi,minrsibar,minrsi) coloured(0,200,0)
drawarrowup(minrsibar,minrsi) coloured(0,200,0)
divbuy=osLevel
endif
oldminrsi = minrsi
oldminprice = minprice
oldminrsibar = minrsibar
endif
return irsi style(line,2),obLevel coloured(168,168,168) style(dottedline,1), osLevel coloured(168,168,168) style(dottedline,1), divsell coloured(200,0,0) style(histogram), divbuy coloured(0,200,0) style(histogram)