// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jeromehorus predicts everything cyclical, can be applied to wind etc
//@version=6
indicator("marketing range bot" ,overlay=true)
range= input.int(33,"peaks")
clos = ta.sma(close,13)
float dm =0
float dd =0
for i = 0 to range
m= clos-clos[1]>0?true:false
diff= math.abs(clos-clos[1])
dm := m? dm+diff:dm
dd := m==false? dd+diff:dd
bas = ta.lowest(close,13)
high = ta.highest(close,13)
rsip = input.int(27,"rsi range")
rsivb = input.int(35,"oversold value")
rsivh = input.int(70,"overbought value")
rsiv = ta.rsi(close,rsip)
eml = input.int(83,"ema length")
ema200 = ta.ema(close,eml)
ema666 = ta.ema(close,666)
m6 = ema666 - ema666[1] >0? true:false
plot( ema200, color= m6? color.green:color.red)
m2 = ema200 - ema200[1] >0? true:false
base = ta.lowest(close,33)
haute = ta.highest( close,33)
plot( close, color= close> haute[13] ? color.green: close< base[13]? color.red: color.yellow,linewidth=5)
of= input.float(10.0, "Minimal rebound in $ to validate the high signal")//10 for btc peaks are more violent in volatility
ofb= input.float(0.01, "Minimal rebound in $ to validate the bottom signal")// peaks are more violent in volatility
// Memory of the last detected bottom or top
// Memory
var float basDetected = na
var bool waitingForBounce = false
var bool signalDisplayed = false
// Detection of the bottom
if (close == bas and dd > dm and rsiv < rsivb and not waitingForBounce)
basDetected := close
waitingForBounce := true
signalDisplayed := false
// If waiting and rebound of 200$
if (waitingForBounce and not signalDisplayed and close >= basDetected + of)
//label.new(bar_index, low, "BUY confirmed", style=label.style_label_up, color=color.green, textcolor=color.white)
signalDisplayed := true
waitingForBounce := false
// if (close[1]==bas[1] and dd[1]>dm[1] and rsiv[1]< rsivb[1] and close[1]+ofb< close)// and m2==false)
if (close==bas and dd>dm and rsiv< rsivb and close+ofb< close[1])// really at the bottom, less than 1 min previous and m2==false)
label.new(bar_index, low, "b", style=label.style_label_up, color=close>haute[13]?color.green:color.rgb(0,122,0), textcolor=color.white)
//alert("The price is low, possibility to buy? ", alert.freq_once)
alert("LOW SIGNAL",freq=alert.freq_once_per_bar_close)
// allows to eliminate some false signals
// not all because if it hits multiple times or trends upward, we don't sell ( requires advanced algo, I will do it in c)
// if (close[1]==haut[1] and dm[1]>dd[1] and rsiv[1] > rsivh[1] and close[1]-of > close)// and m2)
if (close==haut and dm>dd and rsiv > rsivh and close-of > close[1])// at the peak, above 1 min previous, and m2)
label.new(bar_index, high, "h", style=label.style_label_down, color=close<base[13]?color.red:color.rgb(255,55,55), textcolor=color.white)
//alert("The price is high, possibility to sell? ", alert.freq_once)
alert("HIGH SIGNAL",freq=alert.freq_once_per_bar_close)
// anti rugPull protection
// define the RANGE of prices
// we could say between last peaks
// low and high, but last peaks
// 2) but also last high peak - rugPullValue
lastPeaks= ta.highest(close,333)
// we will look for it more to avoid
// soft rugPulls
rugPullValue = input.float(3,"Anti RugPull Protection, maximum price loss value at 333 minutes")
bool AntiRugPull = close < lastPeaks-rugPullValue?false:true
// if the asset drops too much by 3 dollars compared to its high at 333 minutes we stop
// too many false signals
valsma = input.int(100,"CLOSING SMA")
sma100 = ta.sma(close,valsma)
plot(sma100,color=color.yellow,linewidth=3)
rugPullValue = input.float(0.1 , "distance from the sma to filter false signals")
// if the price is below the sma
// we buy otherwise, we
// does not buy ( price too high or close to the sma )
buyingPrice = sma100-valEloign
///////////////// closing signals
valclotu= input.int(13,"closing rsi")//7,17
rsivd = ta.rsi(close,valclotu)
closure = input.bool(false,"Trade started closing alerts")
// set the stop loss signal at 7% leverage 100 and 17% leverage 200
// ultimate weapon against Rugpull
// define a range
Session = input.float(0,"MINIMAL for a Session without losses( see 15 or 45 min if we are at a bottom)")
if (close< buyingPrice and close> Session and closure==true and close[1]==bas[1] and dd[1]>dm[1] and rsivd[1]< rsivb[1] and close[1]+ofb< close and AntiRugPull)// and m2==false)
// for the bot
//if (closure==true and close==bas and dd>dm and rsivd< rsivb )// and m2==false)
label.new(bar_index, low, "☠", style=label.style_label_down, color=close>haute[13]?color.green:color.rgb(0,122,0), textcolor=color.white)
alert("close the short?",freq=alert.freq_once_per_bar_close)
if (close> sma100+rugPullValue and closure and close[1]==haut[1] and dm[1]>dd[1] and rsivd[1] > rsivh[1] and close[1]-of > close and AntiRugPull)// and m2)
//f (closure and close==high and dm>dd and rsivd > rsivh )// and m2)
label.new(bar_index, high, "💀", style=label.style_label_up, color=close<base[13]?color.red:color.rgb(255,55,55), textcolor=color.white)
alert("close the long",freq=alert.freq_once_per_bar_close)
float tp=0
if (bar_index > 0)
for i=0 to 83
mp = close[i]-close[i+1]>=0?true:false
dp = math.abs(close[i]-close[i+1])
tp := mp ? tp+dp: tp-dp
grandt = tp<=0?false: true
tp :=0
if (bar_index > 0)
for i=0 to 33
mp = close[i]-close[i+1]>=0?true:false
dp = math.abs(close[i]-close[i+1])
tp := mp ? tp+dp: tp-dp
peti= tp<=0?false: true
tp :=0
plot ( ema666, color= grandt ? peti ? color.green:color.blue: peti==false? color.red:color.yellow)
supportRes = input.int(83,"supports Resistances")
//r i= 0 to supportRes by 33
hhaut = ta.highest(high,supportRes)
bbas = ta.lowest(low,supportRes)
box.new( bar_index-1233, hhaut, bar_index+253,hhaut,border_color = color.rgb(2,55,225,43),border_width=4,bgcolor=color.rgb(255,255,255,255))
box.new( bar_index-1233, bbas, bar_index+253,bbas,border_color = color.rgb(2,55,225,43),border_width=4,bgcolor=color.rgb(255,255,255,255))
plot (hhaut,color=color.green,offset=-1)
plot (bbas, color= color.green,offset=1)
plot(bbas+((hhaut-bbas)/3), color= color.red)
plot( hhaut- ((hhaut-bbas)/3) , color=color.yellow )
// the condition for a buy after a buy zone, that it remains above the green
plot ( ta.sma(close,13), color=color.black)
// sma 13, if we exceed it, we enter a buy
// calculation of the next investment levels
// basically: risk of crash,
// if we just came from a peak and it drops
// of more than 2000 : spiral.
buyingPrice = close//input.int(100000,"Buying Price")
pallier = input.int(1000,"DCA levels")
g = input.float(1.1,"geometric")
// we can decompose
// the purchases ( 1 each time)
// by level around
// from a support
plot ( buyingPrice, color= color.black)
plot( buyingPrice-pallier, color=color.black)
plot( buyingPrice-pallier*2*g, color=color.black)
plot( buyingPrice-pallier*3*g, color=color.black)
plot( buyingPrice-pallier*4*g, color=color.black)
plot( buyingPrice-pallier*5*g, color=color.black)
plot( buyingPrice-pallier*6*g, color=color.black)
plot( buyingPrice-pallier*7*g, color=color.black)
// trailing stop
stop = input.float(200,"drop triggering the stop")
somm = input.int(13,"stop peak precision")
trailingStop = ta.highest(close,somm)
// investment
invest = input.float(100,"3 buy orders levels")
smoothingFactor= input.float(1.1," offset")
plot( close-invest*smoothingFactor, color=color.red)
plot( close-invest*2*smoothingFactor, color=color.red)
plot( close-invest*3*smoothingFactor, color= color.red)
takeProfit = input.float(0.02, "% take profit")
plot( close+( close*takeProfit), color=color.purple)
leverage = input.int(58,"leverage")
// calculation of the average price
// we know where we stand ( how many levels crossed)
//( close > trailingStop-stop and close < trailingStop )
// label.new(bar_index, high, "stop", style=label.style_label_down, color=close<base[13]?color.red:color.rgb(255,55,55), textcolor=color.white)
// calculation of the average price