declare upper; #FisherTransform input price = hl2; input length = 10; def maxHigh = Highest(price, length); def minLow = Lowest(price, length); def range = maxHigh - minLow; def value = if IsNaN(price) then Double.NaN else if IsNaN(range) then value[1] else if range == 0 then 0 else 0.66 * ((price - minLow) / range - 0.5) + 0.67 * value[1]; def truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value; def fish = 0.5 * (log((1 + truncValue) / (1 - truncValue)) + fish[1]); def FTOneBarBack = fish[1]; def FT = fish; #ChaikinVolatility input ROClength = 10; assert(ROCLength > 0, "'roc length' must be positive: " + ROCLength); def diff2 = high - low; def avg2 = Average(diff2, 10); def CV = if avg2[roclength] == 0 then 100 else (avg2 - avg2[roclength]) / avg2[roclength] * 100; plot up = ftOneBarBack < -2.5 and ft < -2.5 and cv > 500; plot down = ftOneBarBack > 2.5 and ft > 2.5 and cv > 500; up.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP); up.setDefaultColor(Color.BLUE); down.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_DOWN); down.setDefaultColor(color.BLUE); #TAC_ADX def ADX1 = DMI(length = 3).ADX; def ADX2 = DMI(length = 4).ADX; def ADX3 = DMI(length = 5).ADX; def adxmax = max(max(ADX1, ADX2), ADX3); def adxmin = min(min(ADX1,ADX2), ADX3); #Heikin Ashi Candles def openMA = CompoundValue(1, Average(open, 1), open); def closeMA = CompoundValue(1, Average(close, 1), close); def highMA = CompoundValue(1, Average(high, 1), high); def lowMA = CompoundValue(1, Average(low, 1), low); def haOpen2 = CompoundValue(1, ( (haOpen2[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) / 4.0) / 2.0), open);; def haClose2 = ((openMA + highMA + lowMA + closeMA) / 4.0) ;; def haLow = Min(lowMA, haOpen2); def haHigh = Max(highMA, haOpen2); #MACD def Value2 = MovingAverage(averageType = AverageType.EXPONENTIAL, close, 12) - MovingAverage(averageType = AverageType.EXPONENTIAL, close, 26); def Avg = MovingAverage(averageType = AverageType.EXPONENTIAL, Value2, 9); def Diff = Value2 - Avg; #Ichimoku def Tenkan = (Highest(high, 9) + Lowest(low, 9)) / 2; def Kijun = (Highest(high, 26) + Lowest(low, 26)) / 2; def "Span A" = (Tenkan[26] + Kijun[26]) / 2; def "Span B" = (Highest(high[26], 2 * 26) + Lowest(low[26], 2 * 26)) / 2; def Chikou = close[-26]; #SimpleTrendChannelFilter input trendCheck = {default Min}; def avg20 = Average(close, 20); def avg50 = Average(close, 50); def Downtrend3 = close < avg50 and (if trendCheck != trendCheck.Min then avg20 < avg50 else yes); def Uptrend3 = close > avg50 and (if trendCheck != trendCheck.Min then avg20 > avg50 else yes); #HACOLT Assert(1.1 >= 0, "'candle size factor' must not be negative: " + 1.1); def haOpen = CompoundValue(1, (haOpen[1] + ohlc4[1]) / 2, ohlc4); def haClose = (haOpen + Max(high, haOpen) + Min(low, haOpen) + ohlc4) / 4; def temaHaClose = TEMA(haClose, 55); def zeroLagHaClose = 2 * temaHaClose - TEMA(temaHaClose, 55); def temaTypPrice = TEMA(hl2, 55); def zeroLagTypPrice = 2 * temaTypPrice - TEMA(temaTypPrice, 55); def shortCandle = BodyHeight() < (high - low) * 1.1; def keepGreen = haClose >= haOpen or haClose[1] >= haOpen[1] or close >= haClose or high > high[1] or low > low[1] or zeroLagTypPrice >= zeroLagHaClose; def keepGreenAll = keepGreen or (keepGreen[1] and (close >= open or close >= close[1])); def holdLong = shortCandle and high >= low[1]; def utr = keepGreenAll or (keepGreenAll[1] and holdLong); def keepRed = haClose < haOpen or haClose[1] < haOpen[1] or zeroLagTypPrice < zeroLagHaClose; def keepRedAll = keepRed or (keepRed[1] and (close < open or close < close[1])); def holdShort = shortCandle and low <= high[1]; def dtr = keepRedAll or (keepRedAll[1] and holdShort); def upw = !dtr and dtr[1] and utr; def dnw = !utr and utr[1] and dtr; def upwSave = if upw or dnw then upw else upwSave[1]; def buy = upw or (!dnw and upwSave); def longTermSell = close < ExpAverage(close, 60); def neutral = buy or (if longTermSell then no else neutral[1]); def HACOLT = if buy then 100 else if neutral then 50 else 0; #CMF def tmp_var = if high == low then volume else (close - low - (high - close)) / (high - low) * volume ; def sum_close = Sum(tmp_var, length = 21) * 100; def total = Sum(volume, length = 21); def CMF = if total == 0 then 0 else sum_close / total ; #Entry Parameters def upTrend = ohlc4 < "Span A" and ohlc4 < "Span B" and CMF > 0 and Uptrend3 == yes and HACOLT == 100 and Value2 > 0 and Avg > 0 and Diff > 0 and haOpen2 > haLow and haOpen2 < haHigh and adxmin < 30; def neutral1 = ohlc4 < "Span A" and ohlc4 < "Span B" and CMF > 0 and Uptrend3 == yes and HACOLT == 100 and Value2 > 0 and Avg > 0 and Diff > 0 and haOpen2 == haLow and adxmin < 30; def neutral2 = ohlc4 < "Span A" and ohlc4 < "Span B" and CMF > 0 and Uptrend3 == yes and HACOLT == 100 and Value2 > 0 and Avg > 0 and Diff > 0 and haOpen2 == haHigh and adxmin < 30; def downTrend = ohlc4 > "Span A" and ohlc4 > "Span B" and CMF < 0 and Downtrend3 == yes and HACOLT <= 50 and Value2 < 0 and Avg < 0 and Diff < 0 and haOpen2 > haLow and haOpen2 < haHigh and adxmax > 70; def neutral3 = ohlc4 > "Span A" and ohlc4 > "Span B" and CMF < 0 and Downtrend3 == yes and HACOLT <= 50 and Value2 < 0 and Avg < 0 and Diff < 0 and haOpen2 == haHigh and adxmax > 70; def neutral4 = ohlc4 > "Span A" and ohlc4 > "Span B" and CMF < 0 and Downtrend3 == yes and HACOLT <= 50 and Value2 < 0 and Avg < 0 and Diff < 0 and haOpen2 == haLow and adxmax > 70; plot buy1 = upTrend == yes and neutral1[1] == yes; plot buy2 = upTrend == yes and neutral2[1] == yes; plot buy3 = upTrend[1] == yes and neutral1 == yes; plot buy4 = upTrend[1] == yes and neutral2 == yes; plot buy5 = neutral1 == yes and neutral2[1] == yes; plot buy6 = neutral1[1] == yes and neutral2 == yes; plot buy7 = neutral1 == yes and neutral1[1] == yes; plot buy8 = neutral2 == yes and neutral2[1] == yes; plot sell1 = downTrend == yes and neutral3[1] == yes; plot sell2 = downTrend == yes and neutral4[1] == yes; plot sell3 = downTrend[1] == yes and neutral3 == yes; plot sell4 = downTrend[1] == yes and neutral4 == yes; plot sell5 = neutral3 == yes and neutral4[1] == yes; plot sell6 = neutral3[1] == yes and neutral4 == yes; plot sell7 = neutral3 == yes and neutral3[1] == yes; plot sell8 = neutral4 == yes and neutral4[1] == yes; buy1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy1.SetLineWeight(1); buy1.SetDefaultColor(Color.LIGHT_GRAY); buy1.HideTitle(); buy2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy2.SetLineWeight(1); buy2.SetDefaultColor(Color.LIGHT_GRAY); buy2.HideTitle(); buy3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy3.SetLineWeight(1); buy3.SetDefaultColor(Color.LIGHT_GRAY); buy3.HideTitle(); buy4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy4.SetLineWeight(1); buy4.SetDefaultColor(Color.LIGHT_GRAY); buy4.HideTitle(); buy5.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy5.SetLineWeight(1); buy5.SetDefaultColor(Color.LIGHT_GRAY); buy5.HideTitle(); buy6.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy6.SetLineWeight(1); buy6.SetDefaultColor(Color.LIGHT_GRAY); buy6.HideTitle(); buy7.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy7.SetLineWeight(1); buy7.SetDefaultColor(Color.LIGHT_GRAY); buy7.HideTitle(); buy8.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP); buy8.SetLineWeight(1); buy8.SetDefaultColor(Color.LIGHT_GRAY); buy8.HideTitle(); sell1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell1.SetLineWeight(1); sell1.SetDefaultColor(Color.LIGHT_GRAY); sell1.HideTitle(); sell2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell2.SetLineWeight(1); sell2.SetDefaultColor(Color.LIGHT_GRAY); sell2.HideTitle(); sell3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell3.SetLineWeight(1); sell3.SetDefaultColor(Color.LIGHT_GRAY); sell3.HideTitle(); sell4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell4.SetLineWeight(1); sell4.SetDefaultColor(Color.LIGHT_GRAY); sell4.HideTitle(); sell5.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell5.SetLineWeight(1); sell5.SetDefaultColor(Color.LIGHT_GRAY); sell5.HideTitle(); sell6.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell6.SetLineWeight(1); sell6.SetDefaultColor(Color.LIGHT_GRAY); sell6.HideTitle(); sell7.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell7.SetLineWeight(1); sell7.SetDefaultColor(Color.LIGHT_GRAY); sell7.HideTitle(); sell8.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN); sell8.SetLineWeight(1); sell8.SetDefaultColor(Color.LIGHT_GRAY); sell8.HideTitle();