// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © wppqqppq //@version=5 indicator('Prop Firm Passed 5m Scalping', 'PFP', overlay = true, max_labels_count = 500, max_lines_count = 500) intraTf = timeframe.isintraday ////// Inputs ////// gpBs = '' maxLv = input.int(5, 'Max Levels to Show', tooltip = 'Max number of lines to show on each side.', minval = 1, maxval = 100, group = gpBs) lookback = input.int(300, 'Lookback Bars', minval = 1, maxval = 5000, group = gpBs) bullLvCor = input.color(color.aqua, 'Level Color Bullish', group = gpBs, inline = 'l') bearLvCor = input.color(color.rgb(233, 30, 99), 'Bearish', group = gpBs, inline = 'l') lvStyle = input.string('Solid', 'Line Style', options = ['Solid', 'Dotted', 'Dashed'], group = gpBs, inline = '1') lvWid = input.int(1, 'Width', group = gpBs, inline = '1') showLeg = input.bool(true, 'Show Leg Number', group = gpBs) gpBias = 'Curret Bias' showBias = input.bool(true, 'Show Current Bias', group = gpBias) biasTbPos = input.string("Top Right", "Location", ["Top Right" , "Middle Right" , "Bottom Right" , "Top Center", "Middle Center" , "Bottom Center", "Top Left" , "Middle Left" , "Bottom Left" ], group = gpBias, inline = "b") biasTbSize = input.string("Auto", "Size", ["Auto", "Huge", "Large", "Normal", "Small", "Tiny"], group = gpBias, inline = "b") biasBullCor = input.color(color.new(color.aqua, 80), 'Background Color Bullish', group = gpBias, inline = "c") biasBearCor = input.color(color.new(color.rgb(233, 30, 99), 80), 'Bearish', group = gpBias, inline = "c") gpSetup = 'Setup' showEt = input.bool(true, 'Show Entry Level', group = gpSetup) etCor = input.color(color.orange, 'Color', group = gpSetup, inline = '1') etStyle = input.string('Dashed', 'Style', options = ['Solid', 'Dotted', 'Dashed'], group = gpSetup, inline = '1') etWid = input.int(1, 'Width', group = gpSetup, inline = '1') showEtBar = input.bool(true, 'Show Entry Bar', group = gpSetup) gpFix = 'Fixing' fxLookback = input.int(2, 'Lookback Days', group = gpFix, minval = 1, maxval = 10) highlightCurFx = input.bool(true, 'Highlight Most Recent', group = gpFix, inline = '0') and fxLookback > 1 showFxLb = input.bool(true, 'Show Label', group = gpFix, inline = '0') and intraTf showTkFx = input(true, 'Tokyo Fix', group = gpFix, inline = '1') and intraTf tkFxCor = input.color(color.blue, 'Color', group = gpFix, inline = '1') tkFxStyle = input.string('Dotted', 'Style', options = ['Solid', 'Dotted', 'Dashed'], group = gpFix, inline = '1') tkFxWid = input.int(1, 'Width', group = gpFix, inline = '1') showLdnFx = input(true, 'London Fix', group = gpFix, inline = '2') and intraTf ldnFxCor = input.color(color.rgb(26, 128, 0), 'Color', group = gpFix, inline = '2') ldnFxStyle = input.string('Dotted', 'Style', options = ['Solid', 'Dotted', 'Dashed'], group = gpFix, inline = '2') ldnFxWid = input.int(1, 'Width', group = gpFix, inline = '2') gpTm = 'Time Windows' noWeekendSessions = ':23456' onlyInSession = input.bool(false, 'Filter with Market Sessions', group = gpTm) and intraTf useGmt = input.string('GMT+8', 'Timezone', group = gpTm, options = ['GMT-12','GMT-11','GMT-10','GMT-9','GMT-8','GMT-7','GMT-6','GMT-5','GMT-4','GMT-3','GMT-2','GMT-1','GMT+0','GMT+1','GMT+2','GMT+3','GMT+4','GMT+5','GMT+5:30','GMT+5:45','GMT+6','GMT+6:30','GMT+7','GMT+8','GMT+9','GMT+10','GMT+11','GMT+12','GMT+13','GMT+14']) useAsSess = input.bool(true, 'Asian Session', group = gpTm, inline = 'a') userAsSess = input.session('0700-1600', 'Time', group = gpTm, inline = 'a') + noWeekendSessions showAsBg = input.bool(true, 'Show Asian Session Background', group = gpTm, inline = 'a2') asBgCor = input.color(color.new(color.red, 90), 'Color', group = gpTm, inline = 'a2') useLdnSess = input.bool(true, 'London Session', group = gpTm, inline = 'l') userLdnSess = input.session('1500-0000', 'Time', group = gpTm, inline = 'l') + noWeekendSessions showLdnBg = input.bool(true, 'Show London Session Background', group = gpTm, inline = 'l2') ldnBgCor = input.color(color.new(color.yellow, 90), 'Color', group = gpTm, inline = 'l2') useNySess = input.bool(true, 'New York Session', group = gpTm, inline = 'n') userNySess = input.session('2000-0500', 'Time', group = gpTm, inline = 'n') + noWeekendSessions showNyBg = input.bool(true, 'Show New York Session Background', group = gpTm, inline = 'n2') nyBgCor = input.color(color.new(color.aqua, 90), 'Color', group = gpTm, inline = 'n2') gpAlt = 'Alert' altLv = input.bool(true, 'Alert on Level Formed', group = gpAlt) altReb = input.bool(true, 'Alert on Rebalanced', group = gpAlt) altEt = input.bool(true, 'Alert on Entry Occured', group = gpAlt) ////// Types ////// type leg int _dir float _price int _num ////// Constants ////// var NONE_COLOR = color.new(color.white, 100) var BULL_DIR = 1 var BEAR_DIR = -1 var NONE_DIR = 0 var LINE_OFFSET = 10 var MAX_LINE = 100 // 100 on each side = 200 lines in total var MAX_BEAR_CD_LOOKBACK = 2 var GMT = 'GMT+0' var GMT_DST = 'GMT+1' var AS_SESS = '2300-0900' var LDN_SESS = '0700-1600' var NY_SESS = '1300-2200' var TOKYO_FIX = '0055-0100' // 9:55am Tokyo time(GMT+9) var LONDON_FIX = '1600-1601' // 4pm London time(if DST: GMT+1, else: GMT+0) var LEG_ORIGIN_TXT = '★' var DEBUG = false ////// Variables ////// labelOffset = time_close + 7 * timeframe.multiplier * 60 * 1000 ////// Functions ////// IsTimeInRange(sess, tz) => not na(time("1", sess, tz)) LineStyle(str) => switch str "Solid" => line.style_solid "Dotted" => line.style_dotted "Dashed" => line.style_dashed CandleDir(i=0) => close[i] > open[i] ? BULL_DIR : (close[i] < open[i] ? BEAR_DIR : NONE_DIR) IsBullDir(dir) => dir == BULL_DIR IsBearDir(dir) => dir == BEAR_DIR IsNeutralDir(dir) => dir == NONE_DIR IsBullCandle(i=0) => IsBullDir(CandleDir(i)) IsBearCandle(i=0) => IsBearDir(CandleDir(i)) IsNeutralCandle(i=0) => IsNeutralDir(CandleDir(i)) IsLineExpired(line ln) => bar_index - line.get_x1(ln) > lookback IsDst()=> int previousSunday = dayofmonth - dayofweek + 1 bool nyDST = na bool ukDST = na bool sydDST = na if month < 3 or month > 11 nyDST := false ukDST := false sydDST := true else if month > 4 and month < 10 nyDST := true ukDST := true sydDST := false else if month == 3 nyDST := previousSunday >= 8 ukDST := previousSunday >= 24 sydDST := true else if month == 4 nyDST := true ukDST := true sydDST := previousSunday <= 0 else if month == 10 nyDST := true ukDST := previousSunday <= 24 sydDST := previousSunday >= 0 else // month == 11 nyDST := previousSunday <= 0 ukDST := false sydDST := true [nyDST, ukDST, sydDST] TrimLineArr(array arr, max) => if arr.size() > max ln = arr.shift() line.delete(ln) TrimLabelArr(array