0% found this document useful (0 votes)
15 views

Atmos Bitcoin

The document is a Pine Script strategy for trading Bitcoin, incorporating various technical indicators like Ichimoku Cloud and Choppiness Index. It allows users to customize trading days, timeframes, and conditions for entering and exiting trades. The strategy aims for a profit percentile of 49% with a profit factor of 2.9.

Uploaded by

sonwalkaranurag6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Atmos Bitcoin

The document is a Pine Script strategy for trading Bitcoin, incorporating various technical indicators like Ichimoku Cloud and Choppiness Index. It allows users to customize trading days, timeframes, and conditions for entering and exiting trades. The strategy aims for a profit percentile of 49% with a profit factor of 2.9.

Uploaded by

sonwalkaranurag6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 14

//@version=5

strategy("Atmos BITCOIN [SplashAlgo] , Profit Percentile = 49% and profit factor


2.9", overlay = true, max_labels_count = 500, process_orders_on_close = true)

TAR_tf_input = input.string('15', title = "REF Timeframe")

timex = input(true, title = "Intraday Session (On/Off)", group = "Intraday


Session")
s=input.session("0915-1500", title="Take Trades between", group = "Intraday
Session")
e=input.session("1500-1504", title="Close Open Trades between", group = "Intraday
Session")

stt = false
ett = false

if timex
stt := time(timeframe.period,s) and timex
else
stt := true

ab = time(timeframe.period,e)
if timex
ett := time(timeframe.period,e) and timex
else
ett := false

// Days for Trading

sun_S = input.bool(true, title = "Sunday", inline = "1", group = "Days For


Trading")
mon_S = input.bool(true, title = "Monday", inline = "1", group = "Days For
Trading")
tue_S = input.bool(true, title = "Tuesday", inline = "1", group = "Days For
Trading")
wed_S = input.bool(true, title = "Wednesday", inline = "1", group = "Days For
Trading")
thu_S = input.bool(true, title = "Thursday", inline = "2", group = "Days For
Trading")
fri_S = input.bool(true, title = "Friday", inline = "2", group = "Days For
Trading")
sat_S = input.bool(true, title = "Saturday", inline = "2", group = "Days For
Trading")

reverseexit = false //input(true,"Reverse exit on/off",group = "Reverse Exit")


sun = dayofweek(time) == 1
mon = dayofweek(time) == 2
tue = dayofweek(time) == 3
wed = dayofweek(time) == 4
thu = dayofweek(time) == 5
fri = dayofweek(time) == 6
sat = dayofweek(time) == 7

Chart_display = input.bool(true, title = "Chart display", tooltip = "On = default


Values OR off = Calculated lines value")

// Ichimoku Cloud

conversionPeriods = input.int(32, minval=1, title="Conversion Line Length", group =


"Ichimoku Cloud")
basePeriods = input.int(104, minval=1, title="Base Line Length", group = "Ichimoku
Cloud")
laggingSpan2Periods = input.int(208, minval=1, title="Leading Span B Length", group
= "Ichimoku Cloud")
displacement = input.int(104, minval=1, title="Lagging Span", group = "Ichimoku
Cloud")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = math.avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
// plot(Chart_display ? conversionLine : na, color=#2962FF, title="Conversion
Line")
// plot(Chart_display ? baseLine : na, color=#B71C1C, title="Base Line")
// plot(Chart_display ? close : na, offset = -displacement + 1, color=#43A047,
title="Lagging Span")
// p1 = plot(Chart_display ? leadLine1 : na, offset = displacement - 1,
color=#A5D6A7,
// title="Leading Span A")
// p2 = plot(Chart_display ? leadLine2 : na, offset = displacement - 1,
color=#EF9A9A,
// title="Leading Span B")
// plot(Chart_display ? (leadLine1 > leadLine2 ? leadLine1 : leadLine2) : na,
offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none)

// plot(Chart_display ? (leadLine1 < leadLine2 ? leadLine1 : leadLine2) : na,


offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none)

// fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) :
color.rgb(244, 67, 54, 90))

FSSA = leadLine1
FSSB = leadLine2

CSSA = leadLine1[25]
CSSB = leadLine2[25]

PSSA = leadLine1[50]
PSSB = leadLine2[50]

CSC = close[25]
CS = close

TK = conversionLine
KJ = baseLine
// plot(Chart_display==false ? FSSA : na, title = "FSSA", color = color.lime)
// plot(Chart_display==false ? FSSB : na, title = "FSSB", color = #e600cb)
// plot(Chart_display==false ? CSSA : na, title = "CSSA", color = #7fe600)
// plot(Chart_display==false ? CSSB : na, title = "CSSB", color = #d3e600)
// plot(Chart_display==false ? PSSA : na, title = "PSSA", color = #e61f00)
// plot(Chart_display==false ? PSSB : na, title = "PSSB", color = #ff3078)
// plot(Chart_display==false ? CSC : na, title = "CSC", color = #00dee6)
// plot(Chart_display==false ? CS : na, title = "CS", color = #005ce6)
// plot(Chart_display==false ? TK : na, title = "TK", color = #9c12ff)
// plot(Chart_display==false ? KJ : na, title = "KJ", color = #c891ff)

// CHOPPINESS INDEX

length = input.int(14, minval=1, group = "CHOPPINESS INDEX")


ci = 100 * math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) -
ta.lowest(length))) / math.log10(length)
offset = 0 //input.int(0, "Offset", minval = -500, maxval = 500)
plot(ci, "CHOP", color=#2962FF, offset = offset, display = display.data_window)

ATR = ta.atr(input.int(14, title = "ATR Length"))


plot(ATR, title = "atr", display = display.data_window)

TP_Input = input.float(1.00, title = "Target multiplier", group = "TP and SL")


SL_Input = input.float(1.00, title = "Stoploss multiplier", group = "TP and SL")

QTY_buy = input(10, title = "Buy QTY")


QTY_exit_tp = input.int(80, title = "QTY % Exit On TP Hit")

Buffer = syminfo.mintick

int buy = 0
int buy1 = 0
int sell = 0
int short = 0
int short1 = 0
int cover = 0
var bflag = 0
var sflag = 0
var buyprice = 0.00
var shortprice = 0.00
var Long_tp = 0.00
var Long_sl = 0.00
var Long_tsl = 0.00
var Short_tp = 0.00
var Short_sl = 99999999.99
var Short_tsl = 99999999.99
var LTSL_f = 0
var STSL_f = 0
var Long_QTY_EX = 0.00000
var Short_QTY_EX = 0.00000
FL_sell = 0
FL_cover = 0
var LTP_flag = 0
var STP_flag = 0
sell_close = 0
cover_close = 0
tarminbodysize = input.float(9, title = "Min Body Size(TAR)", group = "Candle
Conditions")
tarclosewrtsize = input.float(0.32, title = "Close WRT Size(TAR)", group = "Candle
Conditions")
tarMinbodysize = input.float(0.12, title = "Min Body WRT Size(TAR)", group =
"Candle Conditions")
tarMinbodysurge = input.float(0.12, title = "Max size surge(TAR)", group = "Candle
Conditions")
refminbodysize = input.float(2, title = "Min Body Size(REF)", group = "Candle
Conditions")
refclosewrtsize = input.float(0.12, title = "Close WRT Size(REF)", group = "Candle
Conditions")
refMinbodysize = input.float(0.12, title = "Min Body WRT Size(REF)", group =
"Candle Conditions")
refMinbodysurge = input.float(0.12, title = "Max size surge(REF)", group = "Candle
Conditions")

Open = open
Close = close
High = high
Low = low

LTcon_1 = ((math.abs(Open - Close)/(High - Low) > tarminbodysize) or (Close >= Low


+ (High - Low) * tarclosewrtsize))
LTcon_2 = (math.abs(Open - Close)/(High - Low) > tarMinbodysize)
LTcon_3 = (((High - Low)/Close) <= tarMinbodysurge)[1] and (((High - Low)/Close) <=
tarMinbodysurge)[2] and (((High - Low)/Close) <= tarMinbodysurge)
LTcon_4 = (Close >= Low + ((High - Low) * 0.5052))
LTcon_5 = (CS >= CSC and (CS > (math.max(PSSA, PSSB))) and TK >= KJ and Close > TK
and FSSA > FSSB and Close > CSSA and Close > CSSB and (Low <= (math.max(CSSA,
CSSB)) and (Close[1] <= CSSA[1] or Close[1] <= CSSB[1])))
LTcon_6 = (CS >= CSC and (CS > (math.max(PSSA, PSSB))) and TK >= KJ and Close > TK
and FSSA > FSSB and Close > CSSA and Close > CSSB and Close[1] <= TK[1])
LTcon_7 = ((CS > (math.max(PSSA, PSSB))) and CS[1] < (math.max(PSSA[1], PSSB[1]))
and TK >= KJ and (Close >= TK) and (FSSA > FSSB) and (Close > (math.max(CSSA,
CSSB))))
LTcon_8 = ((CS > (math.max(PSSA, PSSB))) and (TK >= KJ and TK[1] < KJ[1]) and
(Close >= TK) and (FSSA > FSSB) and (Close > (math.max(CSSA, CSSB))))
LTcon_9 = ((CS > (math.max(PSSA, PSSB))) and (TK >= KJ) and (Close >= TK) and
(Close[1] < TK[1]) and (FSSA > FSSB) and (Close > (math.max(CSSA, CSSB))))
LTcon_10 = ((CS > (math.max(PSSA, PSSB))) and (TK >= KJ) and (Close >= TK) and
(FSSA > FSSB) and (FSSA[1] <= FSSB[1]) and (Close > (math.max(CSSA, CSSB))))
LTcon_11 = ((CS > (math.max(PSSA, PSSB))) and (TK >= KJ and Close >= TK) and (FSSA
> FSSB) and (Close > (math.max(CSSA, CSSB))) and Close[1] <= math.max(CSSA[1],
CSSB))
LTcon_12 = (ci < 60 and ci > 40) or (ci < 40 and ci[1] > 40)

LRcon_1 = ((math.abs(Open - Close)/(High - Low) > refminbodysize) or (Close >= Low


+ (High - Low) * refclosewrtsize))
LRcon_2 = (math.abs(Open - Close)/(High - Low) > refMinbodysize)
LRcon_3 = ((High - Low)/Close <= refMinbodysurge)[1] and ((High - Low)/Close <=
refMinbodysurge)[2] and ((High - Low)/Close <= refMinbodysurge)
LRcon_4 = (Close >= Low + ((High - Low) * 0.5052))
LRcon_5 = (CS >= CSC and TK >= KJ and Close > TK and FSSA > FSSB)
LRcon_6 = (CS >= CSC and Close >= KJ and TK >= KJ and ((CS > PSSA and CS < PSSB) or
(CS < PSSA and CS > PSSB)))
LRcon_7 = (CS >= CSC and Close >= KJ and CS > PSSA and CS > PSSB and
math.abs(math.abs(CS - (math.max(PSSA, PSSB))) / ATR) < 3.8 and FSSA < FSSB)
LRcon_8 = (CS >= CSC and Close >= KJ and CS < PSSA and CS < PSSB and
math.abs(math.abs(CS - (math.min(PSSA, PSSB))) / ATR) < 3.8 and FSSA < FSSB)
LRcon_9 = (ci < 60 and ci > 40) or (ci < 40 and ci[1] > 40)

STcon_1 = ((math.abs(Open - Close)/(High - Low) > tarminbodysize) or (Close >= High


- ((High - Low) * tarclosewrtsize)))
STcon_2 = (math.abs(Open - Close)/(High - Low) > tarMinbodysize)
STcon_3 = ((High - Low)/Close <= tarMinbodysurge)[1] and ((High - Low)/Close <=
tarMinbodysurge)[2] and ((High - Low)/Close <= tarMinbodysurge)
STcon_4 = (Close <= High - ((High - Low) * 0.5052))
STcon_5 = (CS <= CSC and (CS < (math.min(PSSA, PSSB))) and TK <= KJ and Close < TK
and FSSA < FSSB and Close < CSSA and Close < CSSB and (High >= (math.min(CSSA,
CSSB)) and (Close[1] >= CSSA[1] or Close[1] >= CSSB[1])))
STcon_6 = (CS <= CSC and (CS < (math.min(PSSA, PSSB))) and TK <= KJ and Close < TK
and FSSA < FSSB and Close < CSSA and Close < CSSB and Close[1] >= TK[1])
STcon_7 = ((CS < (math.min(PSSA, PSSB))) and CS[1] > (math.min(PSSA[1], PSSB[1]))
and TK <= KJ and (Close <= TK) and (FSSA < FSSB) and (Close < (math.min(CSSA,
CSSB))))
STcon_8 = ((CS < (math.min(PSSA, PSSB))) and (TK <= KJ and TK[1] > KJ[1]) and
(Close <= TK) and (FSSA < FSSB) and (Close < (math.min(CSSA, CSSB))))
STcon_9 = ((CS < (math.min(PSSA, PSSB))) and (TK <= KJ) and (Close <= TK) and
(Close[1] > TK[1]) and (FSSA < FSSB) and (Close < (math.min(CSSA, CSSB))))
STcon_10 = ((CS < (math.min(PSSA, PSSB))) and (TK <= KJ) and (Close <= TK) and
(FSSA < FSSB) and (FSSA[1] >= FSSB[1]) and (Close < (math.min(CSSA, CSSB))))
STcon_11 = ((CS < (math.min(PSSA, PSSB))) and (TK <= KJ) and (Close <= TK) and
(FSSA < FSSB) and (Close < (math.min(CSSA, CSSB))) and Close[1] >=
(math.min(CSSA[1], CSSB[1])))
STcon_12 = (ci < 60 and ci > 40) or (ci < 40 and ci[1] > 40)

SRcon_1 = ((math.abs(Open - Close)/(High - Low) > refminbodysize) or (Close >= High


- (High - Low) * refclosewrtsize))
SRcon_2 = (math.abs(Open - Close)/(High - Low) > refMinbodysize)
SRcon_3 = ((High - Low)/Close <= refMinbodysurge)[1] and ((High - Low)/Close <=
refMinbodysurge)[2] and ((High - Low)/Close <= refMinbodysurge)
SRcon_4 = (Close <= High - ((High - Low) * 0.5052))
SRcon_5 = (CS <= CSC and TK <= KJ and Close < TK and FSSA < FSSB)
SRcon_6 = (CS <= CSC and Close <= KJ and TK <= KJ and ((CS > PSSA and CS < PSSB) or
(CS < PSSA and CS > PSSB)))
SRcon_7 = (CS <= CSC and Close <= KJ and CS > PSSA and CS > PSSB and
math.abs(math.abs(CS - (math.max(PSSA, PSSB))) / ATR) < 3.8 and FSSA > FSSB)
SRcon_8 = (CS <= CSC and Close <= KJ and CS < PSSA and CS < PSSB and
math.abs(math.abs(CS - (math.min(PSSA, PSSB))) / ATR) < 3.8 and FSSA > FSSB)
SRcon_9 = (ci < 60 and ci > 40) or (ci < 40 and ci[1] > 40)

[LREF_Con, isciles60, isciles40, iscimor60] = request.security(syminfo.tickerid,


TAR_tf_input, [((LRcon_1[1] and LRcon_2[1] and LRcon_3[1] and LRcon_4[1] and
LRcon_9[1]) and (LRcon_5[1] or LRcon_6[1] or LRcon_7[1] or LRcon_8[1]) and
(close[1] > open[1])), ci < 60, ci < 40, ci > 60], lookahead =
barmerge.lookahead_on)
Long_con = (ci[1] > 60 or iscimor60[1]) ? false : (LTcon_1[1] and LTcon_2[1] and
LTcon_3[1] and LTcon_4[1] and LTcon_12[1]) and (LTcon_5[1] or LTcon_6[1] or
LTcon_7[1] or LTcon_8[1] or LTcon_9[1] or LTcon_10[1] or LTcon_11[1]) and LREF_Con
and close[1] > open[1]

SREF_Con = request.security(syminfo.tickerid, TAR_tf_input, (SRcon_1[1] and


SRcon_2[1] and SRcon_3[1] and SRcon_4[1] and SRcon_9[1]) and (SRcon_5[1] or
SRcon_6[1] or SRcon_7[1] or SRcon_8[1]) and open[1] > close[1], lookahead =
barmerge.lookahead_on)
Short_con = (ci[1] > 60 or iscimor60[1]) ? false : (STcon_1[1] and STcon_2[1] and
STcon_3[1] and STcon_4[1] and STcon_12[1]) and (STcon_5[1] or STcon_6[1] or
STcon_7[1] or STcon_8[1] or STcon_9[1] or STcon_10[1] or STcon_11[1]) and SREF_Con
and open[1] > close[1]

// if Long_con and bflag==0 and sflag==0


// buyprice := high + Buffer
// Long_ref_low := low

// if Short_con and bflag==0 and sflag==0


// shortprice := low - Buffer
// Short_ref_high := high

Long_con_2 = ((Close >= (Low + ((High - Low) * 0.5052))) and (close > Short_sl and
sflag[1]==1) and STP_flag==0)[1]
short_con_2 = ((Close <= (High - ((High - Low)*0.5052))) and (close < Long_sl and
bflag[1]==1) and LTP_flag==0)[1]

// plot(STP_flag ? 1 : LTP_flag ? 2 : 0, display = display.data_window, title =


"Flag")

if (sun_S and sun) or (mon_S and mon) or (tue_S and tue) or (wed_S and wed) or
(thu_S and thu) or (fri_S and fri) or (sat_S and sat)
if high > (high[1] + Buffer) and Long_con and bflag==0 and sflag==0 and stt
buy := 1
bflag := 1
buyprice := (high[1] + Buffer)
Long_tp := High[1] + (ATR[1]*TP_Input)
Long_sl := math.max(High[1] - (ATR[1]*SL_Input), KJ[1])
STP_flag := 0
LTP_flag := 0

// alert("Long Entry")

if (high > Long_tp) and bflag==1 and LTSL_f==0


sell := 1
Long_tp := 99999999.99
LTSL_f := 1
Long_QTY_EX := (QTY_buy*(QTY_exit_tp/100))
LTP_flag := 1

if bflag==1 and LTSL_f==1


Long_tsl := math.max(TK, Long_tsl[1])
if (close < Long_sl) and bflag==1
sell_close := 1
bflag := 0
buyprice := 0.00
Long_tp := 99999999.99
Long_tsl := 0.00
LTSL_f := 0
FL_sell := 1
Long_QTY_EX := QTY_buy - Long_QTY_EX
if (Close > (High - ((High - Low)*0.5052)))
Long_sl := 0.00
else if (close < Long_tsl) and bflag==1
sell_close := 1
bflag := 0
buyprice := 0.00
Long_tp := 99999999.99
Long_sl := 0.00
Long_tsl := 0.00
LTSL_f := 0
FL_sell := 1
Long_QTY_EX := QTY_buy - Long_QTY_EX
else if ett and bflag==1
sell := 1
bflag := 0
buyprice := 0.00
Long_tp := 99999999.99
Long_sl := 0.00
Long_tsl := 0.00
LTSL_f := 0
FL_sell := 1
Long_QTY_EX := QTY_buy - Long_QTY_EX

if low < (low[1] - Buffer) and Short_con and bflag==0 and sflag==0 and stt
short := 1
sflag := 1
shortprice := (low[1] - Buffer)
Short_tp := Low[1] - (ATR[1]*TP_Input)
Short_sl := math.min(Low[1] + (ATR[1]*SL_Input), KJ[1])
STP_flag := 0
LTP_flag := 0

if (low < Short_tp) and sflag==1 and STSL_f==0


cover := 1
Short_tp := 0.00
STSL_f := 1
Short_QTY_EX := (QTY_buy*(QTY_exit_tp/100))
STP_flag := 1

if sflag==1 and STSL_f==1


Short_tsl := math.min(TK, Short_tsl[1])

if (close > Short_sl) and sflag==1


cover_close := 1
sflag := 0
shortprice := 0.00
Short_tp := 0.00
Short_tsl := 99999999.99
STSL_f := 0
FL_cover := 1
Short_QTY_EX := QTY_buy - Short_QTY_EX
if (Close < (Low + ((High - Low) * 0.5052)))
Short_sl := 99999999.99
else if (close > Short_tsl) and sflag==1
cover_close := 1
sflag := 0
shortprice := 0.00
Short_tp := 0.00
Short_sl := 99999999.99
Short_tsl := 99999999.99
STSL_f := 0
FL_cover := 1
Short_QTY_EX := QTY_buy - Short_QTY_EX
else if ett and sflag==1
cover := 1
sflag := 0
shortprice := 0.00
Short_tp := 0.00
Short_sl := 99999999.99
Short_tsl := 99999999.99
STSL_f := 0
FL_cover := 1
Short_QTY_EX := QTY_buy - Short_QTY_EX

if (Long_con_2 and (high > (high[1] + Buffer))) and LTP_flag==0 and bflag==0
and sflag==0 and stt
buy1 := 1
bflag := 1
buyprice := High[1]
Long_tp := buyprice + (ATR[1]*TP_Input)
Long_sl := math.max(buyprice - (ATR[1]*SL_Input), KJ[1])
if Long_sl > buyprice
Long_sl := (buyprice - (ATR[1]*SL_Input))
Short_sl := 99999999.99

if (short_con_2 and (low < (low[1] - Buffer))) and STP_flag==0 and bflag==0 and
sflag==0 and stt
short1 := 1
sflag := 1
shortprice := Low[1]
Short_tp := shortprice - (ATR[1]*TP_Input)
Short_sl := math.min(shortprice + (ATR[1]*SL_Input), KJ[1])
if Short_sl < shortprice
Short_sl := (shortprice + (ATR[1]*SL_Input))
Long_sl := 0.00

if FL_sell[1]==1
Long_QTY_EX := 0

if FL_cover[1]==1
Short_QTY_EX := 0

// plotshape(Long_con or Long_con_2, title = "Buy Ref Candle", color = Long_con ?


color.green : Long_con_2 ? #aa40fb : na, location = location.belowbar, style =
shape.circle, force_overlay = true, offset = -1)
// plotshape(Short_con or short_con_2, title = "Short Ref Candle", color =
Short_con ? color.red : short_con_2 ? #aa40fb : na, location = location.abovebar,
style = shape.circle, force_overlay = true, offset = -1)

hma= ta.sma(high,20)
lma= ta.sma(low,20)
// plotshape(buy==1 ? hma*1.15 : na, title="BUY", text="BUY",
location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.green,
textcolor=color.white, force_overlay = true)
// plotshape(sell==1 ? lma*1.15 : na, title="SELL", text="SELL",
location=location.abovebar, style=shape.labeldown, size=size.tiny, color=color.red,
textcolor=color.white, force_overlay = true)
// plotshape(short==1 ? high : na, title="SHORT", text="SHORT",
location=location.absolute, style=shape.labeldown, size=size.tiny,
color=color.fuchsia, textcolor=color.white, force_overlay = true)
// plotshape(cover==1 ? low : na, title="COVER", text="COVER",
location=location.absolute, style=shape.labelup, size=size.tiny, color=color.blue,
textcolor=color.white, force_overlay = true)

// plot(bflag==1 and buyprice > 0.00 ? buyprice : sflag==1 and shortprice <
99999999.99 and shortprice > 0.00 ? shortprice : na, title = "Entry Price", color =
color.white, style = plot.style_linebr, linewidth = 2, force_overlay = true)
// plot(bflag==1 and Long_tp > 0.00 and Long_tp < 99999999.99 ? Long_tp : sflag==1
and Short_tp > 0.00 ? Short_tp : na, title = "Target", color = color.green, style =
plot.style_linebr, linewidth = 3, force_overlay = true)
// plot(bflag==1 and Long_sl > 0.00 ? Long_sl : sflag==1 and Short_sl > 0.00 and
Short_sl < 99999999.99 ? Short_sl : na, title = "Stoploss", color = color.red,
style = plot.style_linebr, linewidth = 3, force_overlay = true)
// plot(bflag==1 and Long_tsl > 0.00 ? Long_tsl : sflag==1 and Short_tsl > 0.00 and
Short_tsl < 99999999.99 ? Short_tsl : na, title = "Trailing Stoploss", color =
color.rgb(185, 0, 0), style = plot.style_linebr, linewidth = 3, force_overlay =
true)

firstTrail = 8
secondTrail = 2

abc = (sun_S and sun) or (mon_S and mon) or (tue_S and tue) or (wed_S and wed) or
(thu_S and thu) or (fri_S and fri) or (sat_S and sat)
def = (high > (high[1] + Buffer) and Long_con and bflag==0 and sflag==0 and stt)
//
===================================================================================
======================================
// LONG ENTRY
//
===================================================================================
======================================
optionsSymbolCE = "NIFTY03AUG24000"
if buy==1
alert("pineBuy", alert.freq_once_per_bar_close)
// label.new(bar_index, low - (low*0.0001), text = "Buy QTY:" +
str.tostring(QTY_buy), style = label.style_label_up, color = #1a7a1d, textcolor =
color.white, force_overlay = true)
strategy.entry("Long", strategy.long, qty = QTY_buy, alert_message = "{Symbol:"
+ optionsSymbolCE + ", transType : Long" + ",quantity :" + str.tostring(QTY_buy) +
"}" )

if (buy[1]==1) and ((sell[1]==1) or (sell_close[1]==1))


strategy.close("Long", "Long Exit", qty = math.ceil(Long_QTY_EX), alert_message
= "{Symbol:" + optionsSymbolCE + ", transType : Long Exit" + ",quantity :" +
str.tostring(Long_QTY_EX) + "}" )

else if (sell==1) or (sell_close==1)


alert("pineSell", alert.freq_once_per_bar_close)
// label.new(bar_index, high + (high*0.0001), text = "Sell QTY:" +
str.tostring(Long_QTY_EX), style = label.style_label_down, color = color.red,
textcolor = color.white, force_overlay = true)
strategy.close("Long", "Long Exit", qty = math.ceil(Long_QTY_EX), alert_message
= "{Symbol:" + optionsSymbolCE + ", transType : Long Exit" + ",quantity :" +
str.tostring(Long_QTY_EX) + "}" )
// if Long_QTY_EX >=8
// strategy.close("Long", "Long Exit", qty = firstTrail)

//
===================================================================================
======================================
// SHORT ENTRY
//
===================================================================================
======================================
// if (sell==1) or (sell_close==1)
// alert("pineSell", alert.freq_once_per_bar_close)
// // label.new(bar_index, high + (high*0.0001), text = "Sell QTY:" +
str.tostring(Long_QTY_EX), style = label.style_label_down, color = color.red,
textcolor = color.white, force_overlay = true)
// strategy.entry("Short", strategy.short, qty = QTY_buy, alert_message =
"{Symbol:" + optionsSymbolCE + ", transType : Long" + ",quantity :" +
str.tostring(QTY_buy) + "}" )

// if (short==1)
// alert("pineShort", alert.freq_once_per_bar_close)
// // label.new(bar_index, high + (high*0.0001), text = "Short QTY:" +
str.tostring(QTY_buy), style = label.style_label_down, color = color.fuchsia,
textcolor = color.white, force_overlay = true)
// strategy.close("Short", "Short Exit", qty = math.ceil(Long_QTY_EX),
alert_message = "{Symbol:" + optionsSymbolCE + ", transType : Long Exit" +
",quantity :" + str.tostring(Long_QTY_EX) + "}" )

// // alert("Short Entry")
// // alertcondition(short==1, "Short Entry")

// if (cover==1) or (cover_close==1)
// alert("pineCover", alert.freq_once_per_bar_close)
// // label.new(bar_index, low - (low*0.0001), text = "Cover QTY:" +
str.tostring(Short_QTY_EX), style = label.style_label_up, color = color.blue,
textcolor = color.white, force_overlay = true)
// strategy.close("Short", "Short Exit", qty = math.ceil(Short_QTY_EX),
alert_message = "Short Exit")
// if Short_QTY_EX >=8
// strategy.close("Short", "Short Exit", qty = firstTrail)

// if Short_QTY_EX <=2
// strategy.close("Short", "Short Exit", qty = secondTrail)

// alert("Short Exit")
// alertcondition((cover==1) or (cover_close==1), "Short Exit")

// if (short1==1)
// alert("pineRevSHort", alert.freq_once_per_bar_close)
// label.new(bar_index, low - (low*0.0001), text = "RevShort QTY:" +
str.tostring(QTY_buy), style = label.style_label_up, color = #6b05ca, textcolor =
color.white, force_overlay = true)
// strategy.entry("Short", strategy.short, qty = 10)
// alert("Rev Short")
// alertcondition((short1 == 1), "RevShort")

// if (buy1==1)
// alert("pineRevBuy", alert.freq_once_per_bar_close)
// label.new(bar_index, high + (high*0.0001), text = "RevBuy QTY:" +
str.tostring(QTY_buy), style = label.style_label_down, color = #034921, textcolor
= color.white, force_overlay = true)
// strategy.entry("Long", strategy.long, qty = 10)
// alert("Rev Buy")
// alertcondition((buy1 == 1), "Revbuy")
//
===================================================================================
=========================================================
// FROM INTRABLAST
//
===================================================================================
=========================================================
lenn = 98
mult = 2.5
tc = 25

upColor = input.color(color.rgb(18, 180, 163), "Up Color")


downColor = input.color(#ff1100, "Down Color")
plotTextColor = input.color(color.white, "Down Color")

len = lenn

// signal(source) =>
src = close

basis = ta.sma(src, lenn)


upper = basis + ta.stdev(src, len, true)
lower = basis - ta.stdev(src, len, true)

upper1 = basis + ta.stdev(src, len, true) * mult


lower1 = basis - ta.stdev(src, len, true) * mult

var int trend = 0

if src > basis and src > upper


trend := 1
if src < basis and src < lower
trend := -1

// pu = plot(upper, "upper Line", color.new(chart.fg_color, 80), display = c ?


display.all : display.none)
// pl = plot(lower, "lower Line", color.new(chart.fg_color, 80), display = c ?
display.all : display.none)

grad = math.abs(basis - src) / (ta.highest(basis - src, 200)) * 100


grad1 = math.min(grad, 40)
grad1 := 100 - grad1

y = 1 - grad / 100
y := y > 100 ? 100 : y < 0 ? 0 : y
barcolor(src > upper ? upColor : src < lower ? downColor : upColor)

// ===================================
// MOVING AVERAGE
// ===================================
//shorttitle="EMA", overlay=true, timeframe="", timeframe_gaps=false)
lenMA100 = 100
srcMA100 = close
offset1 = 0
out = ta.ema(srcMA100, lenMA100)
plot(out, title="MomentumA", color=color.green, offset=offset1, linewidth=3)

ma(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)

typeMA100 = "SA"
smoothingLength100 =100

smoothingLine100 = ma(out, smoothingLength100, typeMA100)


plot(smoothingLine100, title="Smoothing Line", color=#f37f20, offset=offset1,
display=display.none)

//@version=5
//"Moving Average Exponential 200",
//shorttitle="EMA200", overlay=true, timeframe="", timeframe_gaps=false)
lenMA120 = 120
srcMA120 = close
offset120 = 0
out120 = ta.ema(srcMA120, lenMA120)
plot(out120, title="MomentumB", color=color.red, offset=offset1, linewidth=3)

ma120(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)

typeMA120 = "SP"
smoothingLength120 = 5

smoothingLine120 = ma(out, smoothingLength120, typeMA120)


plot(smoothingLine120, title="Smoothing Line", color=#f37f20, offset=offset1,
display=display.none)

//@version=5
//"Moving Average Exponential 100",
//shorttitle="EMA1000", overlay=true, timeframe="", timeframe_gaps=false)
lenMA1000 = 1000
srcMA1000 = close
offset1000 = 0
out1000 = ta.ema(srcMA1000, lenMA1000)
plot(out1000, title="SupportAndResistance", color=color.purple, offset=offset1,
linewidth=4)

ma1000(source, length, type) =>


switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)

typeMA1000 = "sp"
smoothingLength1000 = 5

smoothingLine1000 = ma1000(out, smoothingLength1000, typeMA1000)


plot(smoothingLine1000, title="Smoothing Line", color=#f37f20, offset=offset1,
display=display.none)

You might also like