KEMBAR78
Jason Main Gold Indicator | PDF | Computer Programming
0% found this document useful (0 votes)
686 views5 pages

Jason Main Gold Indicator

Jason Main Gold indicator

Uploaded by

surendracommon
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)
686 views5 pages

Jason Main Gold Indicator

Jason Main Gold indicator

Uploaded by

surendracommon
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/ 5

//@version=5

indicator(title="JASON XAUUSD 15mins 2/2", overlay=true)

len = input.int(60, "VWAP Length", minval=1)


width = input.float(0.01, "Zone Width", step=0.001, minval=0)

vwap = ta.vwap(hlc3)
plot(vwap, "VWAP", color=color.blue, transp=100)

upcross = ta.crossover(close, vwap)


downcross = ta.crossunder(close, vwap)

prev_close = ta.valuewhen(upcross or downcross, close, 1)


prev_vwap = ta.valuewhen(upcross or downcross, vwap, 1)

supply_zone = prev_close > prev_vwap and close < prev_vwap


demand_zone = prev_close < prev_vwap and close > prev_vwap

// Colored zones
bgcolor(supply_zone ? color.red : demand_zone ? color.green : na, transp=100)

// Alert when price enters a supply or demand zone


alertcondition(supply_zone, title="Supply Zone", message="Price has entered a
supply zone")
alertcondition(demand_zone, title="Demand Zone", message="Price has entered a
demand zone")

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

length1 = input.int(20,'CCI length', minval=1, group="CCI Settings")


src1 = input(hlc3, title="Source" , group="CCI Settings")
ma = ta.sma(src1, length1)
cci = (src1 - ma) / (0.015 * ta.dev(src1, length1))

band0 = input.int(-100, "Lower Band" , group="CCI Settings")


band1 = input.int(100, "Upper Band" , group="CCI Settings")
band2= input.int(-150, "Lower Low Band" , group="CCI Settings")
band3= input.int(150, "Upper up Band" , group="CCI Settings")

ma(source1, length1, type) =>


switch type
"SMA" => ta.sma(source1, length1)
"EMA" => ta.ema(source1, length1)
"SMMA (RMA)" => ta.rma(source1, length1)
"WMA" => ta.wma(source1, length1)
"VWMA" => ta.vwma(source1, length1)
timeframe1= input.timeframe('15','First CCI timeframe' , group="CCI Timeframe
Settings")
timeframe2= input.timeframe('60','second CCI timeframe' , group="CCI Timeframe
Settings")

CCI1= request.security(syminfo.tickerid, timeframe1 ,cci,gaps = barmerge.gaps_off)


plot(CCI1, join= true,display= display.none)
CCI2= request.security(syminfo.tickerid, timeframe2,cci,gaps = barmerge.gaps_off)
plot(CCI2, join= true,display= display.none)

///RSI

rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")


rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger
Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="RSI MA Settings")
maLengthInput = input.int(14, title="MA Length", group="RSI MA Settings")
bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev",
group="RSI MA Settings")

up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)


down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsiMA = ma(rsi, maLengthInput, maTypeInput)
isBB = maTypeInput == "Bollinger Bands"

timeframe=input.timeframe('15', "RSI timeframe", group="RSI Settings")


rsi15= request.security(syminfo.tickerid, timeframe,rsi)

plot(rsi, "RSI", color=#7E57C2, display = display.none)


plot(rsiMA, "RSI-based MA", color=color.yellow, display = display.none)
rsiUpperBand = input.int(65, "RSI Upper Band", group="OverBought/OverSold
Settings")
midline=input.int(50, "RSI Middle Band", group="OverBought/OverSold Settings")
rsiLowerBand = input.int(35, "RSI Lower Band", group="OverBought/OverSold
Settings")
bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Upper Bollinger Band", color=color.green, display = display.none)
bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na,
title = "Lower Bollinger Band", color=color.green, display = display.none)
fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na,
title="Bollinger Bands Background Fill", display = display.none)

cross= ta.cross(cci,band0)

// Condition
signal_buy = false
signal_sell = false
if CCI1 < band0 and CCI2 < band2 and rsiMA < rsiLowerBand and rsi15 < midline
signal_buy := true

if CCI1 > band1 and CCI2 > band3 and rsiMA > rsiUpperBand and rsi15 > midline
signal_sell := true

// Plotshapes
plotshape(signal_sell, title="Sell", style=shape.triangledown, color=color.rgb(255,
0, 0, 50), size=size.small, location=location.abovebar, text="Take Profit",
textcolor=color.rgb(56, 90, 202))
plotshape(signal_buy, title="Buy", style=shape.triangleup, color=color.rgb(0, 255,
0, 50), size=size.small, location=location.belowbar, text="Take Profit",
textcolor=color.blue)

//------------------------------------------------------------------------------
// Indicator, Library Import & User Inputs
//------------------------------------------------------------------------------

// Time Zone notation :


// IANA time zone database name (e.g., "continent/city")
// UTC/GMT notation (e.g., "UTC-5", "GMT+0530"), were +- are the STD offsets from
UTC time

time_NY = input.bool(true, title = "plot NEW YORK session")


time_GMT = input.bool(false, title = "plot LONDON session")
// custom session
time_ctm = input.bool(true, title = "plot CUSTOM session")
// to change time , edit the "1200-1201,1500-1501:1234567" session argument
ctm_session = input.timeframe("1200-1201,1500-1501:1234567", title = "User defined
Sesssion",
tooltip = "This is idealy used to identify you custom trading session more
clearly on the chart, rather than manually ploting vertical lines from the drawing
pannel." + "\n" +
"Note To change this defualt custom trading session you must edit the defualt
trading session in the script",
options = ["1200-1201,1500-1501:1234567", "1100-1101,1400-
1401:1234567" ,"1300-1301,1600-1601:1234567"])

//------------------------------------------------------------------------------
// Function construction / definitions
//------------------------------------------------------------------------------
string IANA_NY = "America/New_York" // UTC offset DST - 4:00
string IANA_GMT = "Europe/London" // UTC offset DST + 1:00

ctm_time_session(chart_tfm, ses_ ,IANA_) =>


not na(time(chart_tfm, ses_, IANA_)) ? true : false

// NY
NY = ctm_time_session(timeframe.period, "0730-1200", IANA_NY)
bool NY_new_ses = time_NY == true and NY
//------------------------------------------------------------------------------
// Function plots
//------------------------------------------------------------------------------
bgcolor(NY_new_ses ? color.new(#dad9d2, 44) : na, title = "NY", editable = true)

// ATR Trailing Stop Loss Indicator

atr_p_inp = input.int(5, 'ATR length', 1, 1000000, 1)


atr_m_inp = input.float(3.5, 'ATR mult.', 0.01, 1000000, 0.05)
gold_ent = input.bool(true, 'Gold Entry Directional Confluence', tooltip = 'Requirs
Gold Sell Signals To Be On A Red Bar And Gold Buy Signal To Be On A Green Bar')
atr = ta.atr(atr_p_inp)
ts = atr_m_inp * atr

float atr_ts = na
if (close > nz(atr_ts[1], 0)) and (close[1] > nz(atr_ts[1], 0))
atr_ts := (math.max(nz(atr_ts[1]), close - ts))
else
if (close < nz(atr_ts[1], 0)) and (close[1] < nz(atr_ts[1], 0))
atr_ts := (math.min(nz(atr_ts[1]), close + ts))
else
if (close > nz(atr_ts[1], 0))
atr_ts := (close - ts)
else
atr_ts := (close + ts)

float pos = na
if (close[1] < nz(atr_ts[1], 0)) and (close > nz(atr_ts[1], 0))
pos := (1)
else
if (close[1] > nz(atr_ts[1], 0)) and (close < nz(atr_ts[1], 0))
pos := (-1)
else
pos := (nz(pos[1], 0))

color _color = na
if (pos == -1)
_color := (color.red)
else
if (pos == 1)
_color := (color.green)
else
_color := (color.blue)

plot (atr_ts, color=_color, title="ATR Trailing Stop")


plotshape (pos, 'UP/DOWN', location = location.bottom, color = _color)

long_trig = (close < atr_ts)[1] and (close > atr_ts)


shrt_trig = (close > atr_ts)[1] and (close < atr_ts)
long_gold = (close > atr_ts) and (low < atr_ts) and not ((close > atr_ts) and
(low < atr_ts))[1] and (gold_ent == true ? (close > open) : true)
shrt_gold = (close < atr_ts) and (high > atr_ts) and not ((close < atr_ts) and
(high > atr_ts))[1] and (gold_ent == true ? (close < open) : true)
plotshape (long_trig, 'Long', shape.triangleup, location.belowbar,
color.green, size = size.small)
plotshape (shrt_trig, 'Short', shape.triangledown, location.abovebar,
color.red, size = size.small)
plotshape (long_gold, 'Gold Long', shape.triangleup, location.belowbar,
color.yellow, size = size.small)
plotshape (shrt_gold, 'Gold Short', shape.triangledown, location.abovebar,
color.yellow, size = size.small)

alertcondition (long_trig, 'Long', 'Green Triangles Below Price')


alertcondition (shrt_trig, 'Short', 'Red Triangles Above Price')
alertcondition ( (pos == 1), 'Long Condition', 'Moving In The Bullish Direction')
alertcondition ( (pos == -1), 'Short Condition', 'Moving In The Bearish Direction')
alertcondition (long_gold, 'Gold Long', 'Gold Triangles Below Price')
alertcondition (shrt_gold, 'Gold Short', 'Gold Triangles Above Price')

You might also like