Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// Some source borrowed from � LonesomeTheBlue's Expanded Camarilla script
//@version=5
indicator('Camarilla Levels Trading', overlay=true)
mode = input.string(title='HTF Method', defval='Auto', options=['Auto', 'User
Defined'])
HTFm = input.timeframe('D', title='Time Frame (if HTF Method=User Defined)')
showlast = input(title='Show Only Last Period', defval=true)
lstyle = input.string(title='Line Style', options=['Solid', 'Circles', 'Cross'],
defval='Circles')
showCPROnly = input(defval=false, title='Show CPR Only')
showCPR = input(defval=false, title="Show Central Pivot Range")
showhl1 = input(defval=true, title='Show R1/S1')
showhl2 = input(defval=true, title='Show R2/S2')
showPriorScenarios = input(defval=false, title='Show Prior Scenario')
noChangePCT_Threshold = input(defval=0.005, title='No Change Percentage')
//New Day
is_newbar(res, sess) =>
t = time(res, sess)
na(t[1]) and not na(t) or t[1] < t
// Detect New Day
// Line Style
linestyle = lstyle == 'Solid' ? plot.style_line : lstyle == 'Circle' ?
plot.style_circles : plot.style_cross
//Trade
int scenario = switch
(R3 > openValue) and (openValue > S3) => 1
(R3 < openValue) and (openValue < R4) => 2
(S3 > openValue) and (openValue > S4) => 3
(openValue > R4) => 4
(openValue < S4) => 5
longTrigger := ((scenario == 1) and (close[1] < S3) and (high > S3))
or (scenario == 2 and (close[1] < R3) and (high > R3))
or (scenario == 3 and (high > S3))
or (scenario == 5 and (high > S3))
shortTrigger := (scenario == 1 and (close[1] > R3) and (low < R3))
or (scenario == 2 and (close[1] > S3) and (low < S3))
or (scenario == 3 and (low < S4))
or (scenario == 4 and (low < R3))
//Status
priorCentralPivot = request.security(syminfo.tickerid, HTF, centralPivot[1],
lookahead=barmerge.lookahead_on)
priorTopPivot = request.security(syminfo.tickerid, HTF, topPivot[1],
lookahead=barmerge.lookahead_on)
priorBottomPivot = request.security(syminfo.tickerid, HTF, bottomPivot[1],
lookahead=barmerge.lookahead_on)
priorCPRRange = request.security(syminfo.tickerid, HTF, cprRange[1],
lookahead=barmerge.lookahead_on)
priorR4 = request.security(syminfo.tickerid, HTF, R4[1],
lookahead=barmerge.lookahead_on)
priorS4 = request.security(syminfo.tickerid, HTF, S4[1],
lookahead=barmerge.lookahead_on)