이 전략은 트렌드 추적을 위해 트렌드 방향을 식별하기 위해 여러 시간 프레임에 걸쳐 기술 지표의 조합을 사용합니다. 그것은 기준을 충족하는 결합 신호를 찾기 위해 1 분, 5 분, 15 분, 1 시간, 4 시간 및 1 일 시간 프레임에 걸쳐 RSI, Stoch, Stoch RSI, CCI 및 기타 지표를 결합하여 전체 현재 트렌드 방향을 판단합니다.
이 전략의 핵심 논리는 서로 다른 시간 프레임에 걸쳐 지표의 조합을 판단하는 데 있다. 각 시간 프레임에 대해 전략은 RSI, Stoch, Stoch RSI, CCI 등과 같은 지표가 설정된 범위 내에서 있고 상승 추세에 있는지 여부를 검사한다. 시간 프레임의 모든 지표가 기준을 충족하면 그 시간 프레임이
1분, 5분, 15분, 1시간, 4시간, 1일 기간 내에서 지나가는 모든 시간 프레임은 전체 트렌드를 추적하기 위한 긍정적 신호를 제공합니다. 1분, 5분, 15분, 1시간, 4시간, 1일 기간을 포함한 모든 시간 프레임이
즉, 기간의 모든 시간 프레임에 대한 트렌드 판단이 정확하다면 전체 트렌드 판단이 매우 신뢰할 수 있으며, 그 때 지위가 오랫동안 열릴 것입니다. 여러 시간 프레임에 대한 지표에서 결합된 트렌드 신호를 판단함으로써 잘못된 신호를 필터링하고 거래 빈도를 줄여 전체 트렌드를 더 정확하게 결정할 수 있습니다.
여러 시간 프레임에 걸쳐 지표의 신호를 결합하여 잘못된 신호를 현저히 줄이고 거래 빈도를 줄일 수 있습니다.
여러 단기 및 장기 기간에 걸쳐 동향의 일관성을 관찰함으로써 전체 동향 방향이 더 정확하게 결정될 수 있습니다.
합리적 인 매개 변수 설정 은 어느 정도 인출을 제어 할 수 있습니다. 중지 손실 및 이익 취득 설정 은 부분적 인 이윤 을 차단 할 수 있으며 위험을 줄일 수 있습니다.
지표 매개 변수들의 조정 가능한 조합을 허용함으로써 다양한 시장에 대한 조정이 적응력을 향상시킵니다.
이 전략은 전체적인 경향을 추적하기 때문에, 트렌드가 역전될 때, 적절한 시간에 포지션을 종료하지 못할 수 있으며, 상당한 마감 위험을 야기할 수 있습니다.
부적절한 매개 변수 설정은 트렌드 기회를 놓칠 수 있거나 거래 빈도를 증가시킬 수 있습니다. 매개 변수를 최적화하기 위해 광범위한 백테스트가 필요합니다.
여러 시간 프레임에 대한 판단은 단기 트렌드 기회를 놓칠 수 있습니다. 최적화는 일부 시간 프레임에서 기준이 완전히 충족되지 않더라도 신호를 허용함으로써 도움이 될 수 있습니다.
최적의 조합을 찾기 위해 각 시간 프레임에 대한 기술 지표의 매개 변수를 최적화하십시오.
일부 시간 프레임의 판단에 기초한 신호를 허용하는 효과를 테스트하십시오. 예를 들어, 1 분과 15 분의 정렬은 구매에 충분할 수 있습니다.
여러 시간 프레임 판단에 사용되는 지표의 유형을 풍부하게하기 위해 새로운 기술적 지표를 통합하십시오. MACD, KD, 볼링거 밴드 등을 고려 할 수 있습니다.
스톱 손실을 테스트하고 최적의 매개 변수를 찾기 위해 수익 수준을 취하십시오. 스톱 손실 범위가 너무 작다면 스톱 손실 위험이 증가 할 수 있습니다. 너무 넓다면 수익 기회가 놓칠 수 있습니다.
이 전략의 주요 혁신은 전반적인 트렌드 방향을 결정하기 위해 여러 시간 프레임에 걸쳐 기술 지표에서 결합된 신호를 활용하는 데 있다. 입시 시기를 선택하기 전에 단기 및 장기 트렌드 정렬을 보장하면 잘못된 신호를 크게 줄이고 트렌드 거래 기회를 포착 할 수 있다. 매개 변수 최적화를 통해 뛰어난 드라우다운 메트릭을 얻을 수 있다. 전반적으로 이것은 장기 보유에 적합한 비교적 안정적이고 낮은 위험 트렌드 추적 전략이다.
/*backtest start: 2023-01-11 00:00:00 end: 2024-01-17 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("Intellitrader - Buy - BACKTESTER", overlay = true) //study("APEX - Tester - Buy/Sell Strategies - Basic ", overlay = true) source_main = close ///////////////////////////////////////////////// // BUY STRATEGIES - SELECTION ///////////////////////////////////////////////// puppy_sep = input(false, title=" INTELLITRADER BACKTESTER ") buy1_sep = input(false, title="▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔" ) /// ******************* Percentage Change *************************** pc_pc = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ PC ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") pc_Use = input(false, title="Use Percent Change (On / Off)") pc_min_1m = input(-200, title="Perc.Change - 1m - Min") pc_max_1m = input(200, title="Perc.Change - 1m - Max") pc_min_5m = input(-200, title="Perc.Change - 5m - Min") pc_max_5m = input(200, title="Perc.Change - 5m - Max") pc_min_15m = input(-200, title="Perc.Change - 15m - Min") pc_max_15m = input(200, title="Perc.Change - 15m - Max") pc_min_1h = input(-200, title="Perc.Change - 1h - Min") pc_max_1h = input(200, title="Perc.Change - 1h - Max") pc_min_4h = input(-200, title="Perc.Change - 4h - Min") pc_max_4h = input(200, title="Perc.Change - 4h - Max") pc_min_1d = input(-200, title="Perc.Change - 1d - Min") pc_max_1d = input(200, title="Perc.Change - 1d - Max") pc_1m = request.security(syminfo.tickerid, "1", close-close[1]/close[1]*100 ) pc_5m = request.security(syminfo.tickerid, "5", close-close[1]/close[1]*100 ) pc_15m = request.security(syminfo.tickerid, "15", close-close[1]/close[1]*100 ) pc_1h = request.security(syminfo.tickerid, "60", close-close[1]/close[1]*100 ) pc_4h = request.security(syminfo.tickerid, "240", close-close[1]/close[1]*100 ) pc_1d = request.security(syminfo.tickerid, "1440", close-close[1]/close[1]*100 ) pc_1m_switch = pc_min_1m <= pc_1m and pc_max_1m >= pc_1m pc_5m_switch = pc_min_5m <= pc_5m and pc_max_5m >= pc_5m pc_15m_switch = pc_min_15m <= pc_15m and pc_max_15m >= pc_15m pc_1h_switch = pc_min_1h <= pc_1h and pc_max_1h >= pc_1h pc_4h_switch = pc_min_4h <= pc_4h and pc_max_4h >= pc_4h pc_1d_switch = pc_min_1d <= pc_1d and pc_max_1d >= pc_1d pc_logic = true if pc_Use pc_logic := false if pc_1m_switch and pc_5m_switch and pc_15m_switch and pc_1h_switch and pc_4h_switch and pc_1d_switch pc_logic := true /// ******************* 1m *************************** ma_sep_1m = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 1m ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_1m = input(20, title="RSI 7 - Min") rsi7_max_1m = input(80, title="RSI 7 - Max") rsi7_Use_1m = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_1m = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_1m = input(20, title="RSI 14 - Min") rsi14_max_1m = input(80, title="RSI 14 - Max") rsi14_Use_1m = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_1m = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_1m = input(20, title="STOCH 14 3 3 - Min") stoch_max_1m = input(80, title="STOCH 14 3 3 - Max") stoch_Use_1m = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_1m = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_1m = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_1m = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_1m = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_1m = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_1m = input(20, title="CCI 20 - Min") cci_max_1m = input(80, title="CCI 20 - Max") cci_Use_1m = input(false, title="CCI 20 ? (On / Off)") cci_Raising_1m = input(false, title="CCII 20 Raising? (On / Off)") rsi14_1m = request.security(syminfo.tickerid, "1", rsi(close,14) ) rsi7_1m = request.security(syminfo.tickerid, "1", rsi(close,7) ) stoch_1m = request.security(syminfo.tickerid, "1", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_1m = request.security(syminfo.tickerid, "1", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_1m = request.security(syminfo.tickerid, "1", cci(close,20) ) rsi7_1m_logic = true rsi7_1m_raisinglogic = true if rsi7_Use_1m rsi7_1m_logic = false rsi7_1m_raisinglogic = rsi7_Raising_1m?rising(rsi7_1m,1):true if rsi7_1m>rsi7_min_1m and rsi7_1m<rsi7_max_1m and rsi7_1m_raisinglogic rsi7_1m_logic = true rsi14_1m_logic = true rsi14_1m_raisinglogic = true if rsi14_Use_1m rsi14_1m_logic = false rsi14_1m_raisinglogic = rsi14_Raising_1m?rising(rsi14_1m,1):true if rsi14_1m>rsi14_min_1m and rsi14_1m<rsi14_max_1m and rsi14_1m_raisinglogic rsi14_1m_logic = true stoch_1m_logic = true stoch_1m_raisinglogic = true if stoch_Use_1m stoch_1m_logic = false stoch_1m_raisinglogic = stoch_Raising_1m?rising(stoch_1m,1):true if stoch_1m>stoch_min_1m and stoch_1m<stoch_max_1m and stoch_1m_raisinglogic stoch_1m_logic = true stochrsi_1m_logic = true stochrsi_1m_raisinglogic = true if stochrsi_Use_1m stochrsi_1m_logic = false stochrsi_1m_raisinglogic = stochrsi_Raising_1m?rising(stochrsi_1m,1):true if stochrsi_1m>stochrsi_min_1m and stochrsi_1m<stochrsi_max_1m and stochrsi_1m_raisinglogic stochrsi_1m_logic = true cci_1m_logic = true cci_1m_raisinglogic = true if cci_Use_1m cci_1m_logic = false cci_1m_raisinglogic = cci_Raising_1m?rising(cci_1m,1):true if cci_1m>cci_min_1m and cci_1m<cci_max_1m and cci_1m_raisinglogic cci_1m_logic = true bool_1m = false bool_1m := rsi7_1m_logic and rsi7_1m_raisinglogic and rsi14_1m_logic and rsi14_1m_raisinglogic and stoch_1m_logic and stoch_1m_raisinglogic and stochrsi_1m_logic and stochrsi_1m_raisinglogic and cci_1m_logic and cci_1m_raisinglogic if not rsi7_Use_1m and not rsi14_Use_1m and not stoch_Use_1m and not stochrsi_Use_1m and not cci_Use_1m bool_1m = false /// ******************* 5m *************************** ma_sep_5m = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 5m ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_5m = input(20, title="RSI 7 - Min") rsi7_max_5m = input(80, title="RSI 7 - Max") rsi7_Use_5m = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_5m = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_5m = input(20, title="RSI 14 - Min") rsi14_max_5m = input(80, title="RSI 14 - Max") rsi14_Use_5m = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_5m = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_5m = input(20, title="STOCH 14 3 3 - Min") stoch_max_5m = input(80, title="STOCH 14 3 3 - Max") stoch_Use_5m = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_5m = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_5m = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_5m = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_5m = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_5m = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_5m = input(20, title="CCI 20 - Min") cci_max_5m = input(80, title="CCI 20 - Max") cci_Use_5m = input(false, title="CCI 20 ? (On / Off)") cci_Raising_5m = input(false, title="CCII 20 Raising? (On / Off)") rsi14_5m = request.security(syminfo.tickerid, "5", rsi(close,14) ) rsi7_5m = request.security(syminfo.tickerid, "5", rsi(close,7) ) stoch_5m = request.security(syminfo.tickerid, "5", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_5m = request.security(syminfo.tickerid, "5", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_5m = request.security(syminfo.tickerid, "5", cci(close,20) ) rsi7_5m_logic = true rsi7_5m_raisinglogic = true if rsi7_Use_5m rsi7_5m_logic = false rsi7_5m_raisinglogic = rsi7_Raising_5m?rising(rsi7_5m,1):true if rsi7_5m>rsi7_min_5m and rsi7_5m<rsi7_max_5m and rsi7_5m_raisinglogic rsi7_5m_logic = true rsi14_5m_logic = true rsi14_5m_raisinglogic = true if rsi14_Use_5m rsi14_5m_logic = false rsi14_5m_raisinglogic = rsi14_Raising_5m?rising(rsi14_5m,1):true if rsi14_5m>rsi14_min_5m and rsi14_5m<rsi14_max_5m and rsi14_5m_raisinglogic rsi14_5m_logic = true stoch_5m_logic = true stoch_5m_raisinglogic = true if stoch_Use_5m stoch_5m_logic = false stoch_5m_raisinglogic = stoch_Raising_5m?rising(stoch_5m,1):true if stoch_5m>stoch_min_5m and stoch_5m<stoch_max_5m and stoch_5m_raisinglogic stoch_5m_logic = true stochrsi_5m_logic = true stochrsi_5m_raisinglogic = true if stochrsi_Use_5m stochrsi_5m_logic = false stochrsi_5m_raisinglogic = stochrsi_Raising_5m?rising(stochrsi_5m,1):true if stochrsi_5m>stochrsi_min_5m and stochrsi_5m<stochrsi_max_5m and stochrsi_5m_raisinglogic stochrsi_5m_logic = true cci_5m_logic = true cci_5m_raisinglogic = true if cci_Use_5m cci_5m_logic = false cci_5m_raisinglogic = cci_Raising_5m?rising(cci_5m,1):true if cci_5m>cci_min_5m and cci_5m<cci_max_5m and cci_5m_raisinglogic cci_5m_logic = true bool_5m = false bool_5m := rsi7_5m_logic and rsi7_5m_raisinglogic and rsi14_5m_logic and rsi14_5m_raisinglogic and stoch_5m_logic and stoch_5m_raisinglogic and stochrsi_5m_logic and stochrsi_5m_raisinglogic and cci_5m_logic and cci_5m_raisinglogic if not rsi7_Use_5m and not rsi14_Use_5m and not stoch_Use_5m and not stochrsi_Use_5m and not cci_Use_5m bool_5m = false /// ******************* 15m *************************** ma_sep_15m = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 15m ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_15m = input(20, title="RSI 7 - Min") rsi7_max_15m = input(80, title="RSI 7 - Max") rsi7_Use_15m = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_15m = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_15m = input(20, title="RSI 14 - Min") rsi14_max_15m = input(80, title="RSI 14 - Max") rsi14_Use_15m = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_15m = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_15m = input(20, title="STOCH 14 3 3 - Min") stoch_max_15m = input(80, title="STOCH 14 3 3 - Max") stoch_Use_15m = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_15m = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_15m = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_15m = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_15m = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_15m = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_15m = input(20, title="CCI 20 - Min") cci_max_15m = input(80, title="CCI 20 - Max") cci_Use_15m = input(false, title="CCI 20 ? (On / Off)") cci_Raising_15m = input(false, title="CCII 20 Raising? (On / Off)") rsi14_15m = request.security(syminfo.tickerid, "15", rsi(close,14) ) rsi7_15m = request.security(syminfo.tickerid, "15", rsi(close,7) ) stoch_15m = request.security(syminfo.tickerid, "15", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_15m = request.security(syminfo.tickerid, "15", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_15m = request.security(syminfo.tickerid, "15", cci(close,20) ) rsi7_15m_logic = true rsi7_15m_raisinglogic = true if rsi7_Use_15m rsi7_15m_logic = false rsi7_15m_raisinglogic = rsi7_Raising_15m?rising(rsi7_15m,1):true if rsi7_15m>rsi7_min_15m and rsi7_15m<rsi7_max_15m and rsi7_15m_raisinglogic rsi7_15m_logic = true rsi14_15m_logic = true rsi14_15m_raisinglogic = true if rsi14_Use_15m rsi14_15m_logic = false rsi14_15m_raisinglogic = rsi14_Raising_15m?rising(rsi14_15m,1):true if rsi14_15m>rsi14_min_15m and rsi14_15m<rsi14_max_15m and rsi14_15m_raisinglogic rsi14_15m_logic = true stoch_15m_logic = true stoch_15m_raisinglogic = true if stoch_Use_15m stoch_15m_logic = false stoch_15m_raisinglogic = stoch_Raising_15m?rising(stoch_15m,1):true if stoch_15m>stoch_min_15m and stoch_15m<stoch_max_15m and stoch_15m_raisinglogic stoch_15m_logic = true stochrsi_15m_logic = true stochrsi_15m_raisinglogic = true if stochrsi_Use_15m stochrsi_15m_logic = false stochrsi_15m_raisinglogic = stochrsi_Raising_15m?rising(stochrsi_15m,1):true if stochrsi_15m>stochrsi_min_15m and stochrsi_15m<stochrsi_max_15m and stochrsi_15m_raisinglogic stochrsi_15m_logic = true cci_15m_logic = true cci_15m_raisinglogic = true if cci_Use_15m cci_15m_logic = false cci_15m_raisinglogic = cci_Raising_15m?rising(cci_15m,1):true if cci_15m>cci_min_15m and cci_15m<cci_max_15m and cci_15m_raisinglogic cci_15m_logic = true bool_15m = false bool_15m := rsi7_15m_logic and rsi7_15m_raisinglogic and rsi14_15m_logic and rsi14_15m_raisinglogic and stoch_15m_logic and stoch_15m_raisinglogic and stochrsi_15m_logic and stochrsi_15m_raisinglogic and cci_15m_logic and cci_15m_raisinglogic if not rsi7_Use_15m and not rsi14_Use_15m and not stoch_Use_15m and not stochrsi_Use_15m and not cci_Use_15m bool_15m = false /// ******************* 1h *************************** ma_sep_1h = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 1h ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_1h = input(20, title="RSI 7 - Min") rsi7_max_1h = input(80, title="RSI 7 - Max") rsi7_Use_1h = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_1h = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_1h = input(20, title="RSI 14 - Min") rsi14_max_1h = input(80, title="RSI 14 - Max") rsi14_Use_1h = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_1h = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_1h = input(20, title="STOCH 14 3 3 - Min") stoch_max_1h = input(80, title="STOCH 14 3 3 - Max") stoch_Use_1h = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_1h = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_1h = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_1h = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_1h = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_1h = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_1h = input(20, title="CCI 20 - Min") cci_max_1h = input(80, title="CCI 20 - Max") cci_Use_1h = input(false, title="CCI 20 ? (On / Off)") cci_Raising_1h = input(false, title="CCII 20 Raising? (On / Off)") rsi14_1h = request.security(syminfo.tickerid, "60", rsi(close,14) ) rsi7_1h = request.security(syminfo.tickerid, "60", rsi(close,7) ) stoch_1h = request.security(syminfo.tickerid, "60", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_1h = request.security(syminfo.tickerid, "60", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_1h = request.security(syminfo.tickerid, "60", cci(close,20) ) rsi7_1h_logic = true rsi7_1h_raisinglogic = true if rsi7_Use_1h rsi7_1h_logic = false rsi7_1h_raisinglogic = rsi7_Raising_1h?rising(rsi7_1h,1):true if rsi7_1h>rsi7_min_1h and rsi7_1h<rsi7_max_1h and rsi7_1h_raisinglogic rsi7_1h_logic = true rsi14_1h_logic = true rsi14_1h_raisinglogic = true if rsi14_Use_1h rsi14_1h_logic = false rsi14_1h_raisinglogic = rsi14_Raising_1h?rising(rsi14_1h,1):true if rsi14_1h>rsi14_min_1h and rsi14_1h<rsi14_max_1h and rsi14_1h_raisinglogic rsi14_1h_logic = true stoch_1h_logic = true stoch_1h_raisinglogic = true if stoch_Use_1h stoch_1h_logic = false stoch_1h_raisinglogic = stoch_Raising_1h?rising(stoch_1h,1):true if stoch_1h>stoch_min_1h and stoch_1h<stoch_max_1h and stoch_1h_raisinglogic stoch_1h_logic = true stochrsi_1h_logic = true stochrsi_1h_raisinglogic = true if stochrsi_Use_1h stochrsi_1h_logic = false stochrsi_1h_raisinglogic = stochrsi_Raising_1h?rising(stochrsi_1h,1):true if stochrsi_1h>stochrsi_min_1h and stochrsi_1h<stochrsi_max_1h and stochrsi_1h_raisinglogic stochrsi_1h_logic = true cci_1h_logic = true cci_1h_raisinglogic = true if cci_Use_1h cci_1h_logic = false cci_1h_raisinglogic = cci_Raising_1h?rising(cci_1h,1):true if cci_1h>cci_min_1h and cci_1h<cci_max_1h and cci_1h_raisinglogic cci_1h_logic = true bool_1h = false bool_1h := rsi7_1h_logic and rsi7_1h_raisinglogic and rsi14_1h_logic and rsi14_1h_raisinglogic and stoch_1h_logic and stoch_1h_raisinglogic and stochrsi_1h_logic and stochrsi_1h_raisinglogic and cci_1h_logic and cci_1h_raisinglogic if not rsi7_Use_1h and not rsi14_Use_1h and not stoch_Use_1h and not stochrsi_Use_1h and not cci_Use_1h bool_1h = false /// ******************* 4h *************************** ma_sep_4h = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 4h ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_4h = input(20, title="RSI 7 - Min") rsi7_max_4h = input(80, title="RSI 7 - Max") rsi7_Use_4h = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_4h = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_4h = input(20, title="RSI 14 - Min") rsi14_max_4h = input(80, title="RSI 14 - Max") rsi14_Use_4h = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_4h = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_4h = input(20, title="STOCH 14 3 3 - Min") stoch_max_4h = input(80, title="STOCH 14 3 3 - Max") stoch_Use_4h = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_4h = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_4h = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_4h = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_4h = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_4h = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_4h = input(20, title="CCI 20 - Min") cci_max_4h = input(80, title="CCI 20 - Max") cci_Use_4h = input(false, title="CCI 20 ? (On / Off)") cci_Raising_4h = input(false, title="CCII 20 Raising? (On / Off)") rsi14_4h = request.security(syminfo.tickerid, "240", rsi(close,14) ) rsi7_4h = request.security(syminfo.tickerid, "240", rsi(close,7) ) stoch_4h = request.security(syminfo.tickerid, "240", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_4h = request.security(syminfo.tickerid, "240", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_4h = request.security(syminfo.tickerid, "240", cci(close,20) ) rsi7_4h_logic = true rsi7_4h_raisinglogic = true if rsi7_Use_4h rsi7_4h_logic = false rsi7_4h_raisinglogic = rsi7_Raising_4h?rising(rsi7_4h,1):true if rsi7_4h>rsi7_min_4h and rsi7_4h<rsi7_max_4h and rsi7_4h_raisinglogic rsi7_4h_logic = true rsi14_4h_logic = true rsi14_4h_raisinglogic = true if rsi14_Use_4h rsi14_4h_logic = false rsi14_4h_raisinglogic = rsi14_Raising_4h?rising(rsi14_4h,1):true if rsi14_4h>rsi14_min_4h and rsi14_4h<rsi14_max_4h and rsi14_4h_raisinglogic rsi14_4h_logic = true stoch_4h_logic = true stoch_4h_raisinglogic = true if stoch_Use_4h stoch_4h_logic = false stoch_4h_raisinglogic = stoch_Raising_4h?rising(stoch_4h,1):true if stoch_4h>stoch_min_4h and stoch_4h<stoch_max_4h and stoch_4h_raisinglogic stoch_4h_logic = true stochrsi_4h_logic = true stochrsi_4h_raisinglogic = true if stochrsi_Use_4h stochrsi_4h_logic = false stochrsi_4h_raisinglogic = stochrsi_Raising_4h?rising(stochrsi_4h,1):true if stochrsi_4h>stochrsi_min_4h and stochrsi_4h<stochrsi_max_4h and stochrsi_4h_raisinglogic stochrsi_4h_logic = true cci_4h_logic = true cci_4h_raisinglogic = true if cci_Use_4h cci_4h_logic = false cci_4h_raisinglogic = cci_Raising_4h?rising(cci_4h,1):true if cci_4h>cci_min_4h and cci_4h<cci_max_4h and cci_4h_raisinglogic cci_4h_logic = true bool_4h = false bool_4h := rsi7_4h_logic and rsi7_4h_raisinglogic and rsi14_4h_logic and rsi14_4h_raisinglogic and stoch_4h_logic and stoch_4h_raisinglogic and stochrsi_4h_logic and stochrsi_4h_raisinglogic and cci_4h_logic and cci_4h_raisinglogic if not rsi7_Use_4h and not rsi14_Use_4h and not stoch_Use_4h and not stochrsi_Use_4h and not cci_Use_4h bool_4h = false /// ******************* 1d *************************** ma_sep_1d = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ 1d ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") rsi7_min_1d = input(20, title="RSI 7 - Min") rsi7_max_1d = input(80, title="RSI 7 - Max") rsi7_Use_1d = input(false, title="RSI 7 ? (On / Off)") rsi7_Raising_1d = input(false, title="RSI 7 Raising? (On / Off)") rsi14_min_1d = input(20, title="RSI 14 - Min") rsi14_max_1d = input(80, title="RSI 14 - Max") rsi14_Use_1d = input(false, title="RSI 14 ? (On / Off)") rsi14_Raising_1d = input(false, title="RSI 14 Raising? (On / Off)") stoch_min_1d = input(20, title="STOCH 14 3 3 - Min") stoch_max_1d = input(80, title="STOCH 14 3 3 - Max") stoch_Use_1d = input(false, title="STOCH 14 3 3 ? (On / Off)") stoch_Raising_1d = input(false, title="STOCH 14 3 3 Raising? (On / Off)") stochrsi_min_1d = input(20, title="STOCHRSI 14 14 3 3 - Min") stochrsi_max_1d = input(80, title="STOCHRSI 14 14 3 3 - Max") stochrsi_Use_1d = input(false, title="STOCHRSI 14 14 3 3 ? (On / Off)") stochrsi_Raising_1d = input(false, title="STOCHRSI 14 14 3 3 Raising? (On / Off)") cci_min_1d = input(20, title="CCI 20 - Min") cci_max_1d = input(80, title="CCI 20 - Max") cci_Use_1d = input(false, title="CCI 20 ? (On / Off)") cci_Raising_1d = input(false, title="CCII 20 Raising? (On / Off)") rsi14_1d = request.security(syminfo.tickerid, "1440", rsi(close,14) ) rsi7_1d = request.security(syminfo.tickerid, "1440", rsi(close,7) ) stoch_1d = request.security(syminfo.tickerid, "1440", sma(sma(stoch(close, high, low, 14), 3), 3)) stochrsi_1d = request.security(syminfo.tickerid, "1440", sma(sma(stoch(rsi(close,14), rsi(close,14), rsi(close,14), 14), 3), 3)) cci_1d = request.security(syminfo.tickerid, "1440", cci(close,20) ) rsi7_1d_logic = true rsi7_1d_raisinglogic = true if rsi7_Use_1d rsi7_1d_logic = false rsi7_1d_raisinglogic = rsi7_Raising_1d?rising(rsi7_1d,1):true if rsi7_1d>rsi7_min_1d and rsi7_1d<rsi7_max_1d and rsi7_1d_raisinglogic rsi7_1d_logic = true rsi14_1d_logic = true rsi14_1d_raisinglogic = true if rsi14_Use_1d rsi14_1d_logic = false rsi14_1d_raisinglogic = rsi14_Raising_1d?rising(rsi14_1d,1):true if rsi14_1d>rsi14_min_1d and rsi14_1d<rsi14_max_1d and rsi14_1d_raisinglogic rsi14_1d_logic = true stoch_1d_logic = true stoch_1d_raisinglogic = true if stoch_Use_1d stoch_1d_logic = false stoch_1d_raisinglogic = stoch_Raising_1d?rising(stoch_1d,1):true if stoch_1d>stoch_min_1d and stoch_1d<stoch_max_1d and stoch_1d_raisinglogic stoch_1d_logic = true stochrsi_1d_logic = true stochrsi_1d_raisinglogic = true if stochrsi_Use_1d stochrsi_1d_logic = false stochrsi_1d_raisinglogic = stochrsi_Raising_1d?rising(stochrsi_1d,1):true if stochrsi_1d>stochrsi_min_1d and stochrsi_1d<stochrsi_max_1d and stochrsi_1d_raisinglogic stochrsi_1d_logic = true cci_1d_logic = true cci_1d_raisinglogic = true if cci_Use_1d cci_1d_logic = false cci_1d_raisinglogic = cci_Raising_1d?rising(cci_1d,1):true if cci_1d>cci_min_1d and cci_1d<cci_max_1d and cci_1d_raisinglogic cci_1d_logic = true bool_1d = false bool_1d := rsi7_1d_logic and rsi7_1d_raisinglogic and rsi14_1d_logic and rsi14_1d_raisinglogic and stoch_1d_logic and stoch_1d_raisinglogic and stochrsi_1d_logic and stochrsi_1d_raisinglogic and cci_1d_logic and cci_1d_raisinglogic if not rsi7_Use_1d and not rsi14_Use_1d and not stoch_Use_1d and not stochrsi_Use_1d and not cci_Use_1d bool_1d = false //// Big old logic buy = bool_1m and bool_5m and bool_15m and bool_1h and bool_4h and bool_1d and pc_logic sell = false ////////////////////////////////////////////////////////////////////////////////////////// //*** This Trade Management Section of code is a modified version of that found in ***// //*** "How to automate this strategy for free using a chrome extension" by CryptoRox ***// //*** Modifications and tradeState engine by JustUncleL. ***// ////////////////////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////// //* Backtesting Period Selector | Component *// /////////////////////////////////////////////// //* https://www.tradingview.com/script/eCC1cvxQ-Backtesting-Period-Selector-Component *// //* https://www.tradingview.com/u/pbergden/ *// //* Modifications made by JustUncleL*// testStartYear = input(2018, "Backtest Start Year",minval=1980) testStartMonth = input(9, "Backtest Start Month",minval=1,maxval=12) testStartDay = input(15, "Backtest Start Day",minval=1,maxval=31) testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0) testStopYear = input(9999, "Backtest Stop Year",minval=1980) testStopMonth = input(12, "Backtest Stop Month",minval=1,maxval=12) testStopDay = input(31, "Backtest Stop Day",minval=1,maxval=31) testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0) testPeriod() => true ////////////////////////// //* Strategy Component *// ////////////////////////// high_ = high low_ = low AQUA = #00FFFFFF BLUE = #0000FFFF RED = #FF0000FF LIME = #00FF00FF GRAY = #808080FF DARKRED = #8B0000FF DARKGREEN = #006400FF // //fastExit = input(false,title="Use Opposite Trade as a Close Signal") //clrBars = input(true,title="Colour Candles to Trade Order state") fastExit = true clrBars = false //orderType = input("LongsOnly",title="What type of Orders", options=["Longs+Shorts","LongsOnly","ShortsOnly","Flip"]) orderType = "LongsOnly" // isLong = (orderType != "ShortsOnly") isShort = (orderType != "LongsOnly") ////////////////////////////////////////////////// //* Put Entry and special Exit conditions here *// ////////////////////////////////////////////////// ////////////////////////// //* tradeState Engine *// INACTIVE = 0 // No trades open ACTIVELONG = 1 // Long Trade Started ACTIVESHORT = -1 // Short Trade Started // ////////////////////////// // Keep track of current trade state longClose = false, longClose := nz(longClose[1],false) shortClose = false, shortClose := nz(shortClose[1],false) tradeState = INACTIVE, tradeState := nz(tradeState[1]) tradeState := tradeState==INACTIVE ? buy==1 and (barstate.isconfirmed or barstate.ishistory) and isLong and not longClose and not shortClose? ACTIVELONG : sell==1 and (barstate.isconfirmed or barstate.ishistory) and isShort and not longClose and not shortClose? ACTIVESHORT : tradeState : tradeState //Entry Triggers, this happens when tradeState changes from neutral to active longCondition = false shortCondition = false longCondition := change(tradeState) and tradeState==ACTIVELONG shortCondition := change(tradeState) and tradeState==ACTIVESHORT if orderType=="Flip" temp = longCondition longCondition := shortCondition shortCondition := temp //end if //SPECIAL Exit Condition. // Exit on Average Fast/Slow MA cross over, force no repaint longExitC = sell ? 1 : 0 shortExitC = 0 // Exit Trigger without SL set and trade Actine longExit = change(longExitC) and longExitC==1 and tradeState==1 shortExit = change(shortExitC) and shortExitC==1 and tradeState==-1 // -- debugs //plotchar(tradeState,"tradeState at Event",location=location.bottom, color=na) //plotchar(longCondition, title="longCondition",color=na) //plotchar(shortCondition, title="shortCondition",color=na) //plotchar(tradeState, title="tradeState",color=na) // -- /debugs ///////////////////////////////////// //======[ Deal Entry Prices ]======// ///////////////////////////////////// last_open_longCondition = na last_open_shortCondition = na last_open_longCondition := longCondition ? close : nz(last_open_longCondition[1]) last_open_shortCondition := shortCondition ? close : nz(last_open_shortCondition[1]) ////////////////////////////////// //======[ Position State ]======// ////////////////////////////////// in_longCondition = tradeState == ACTIVELONG in_shortCondition = tradeState == ACTIVESHORT ///////////////////////////////// //======[ Trailing Stop ]======// ///////////////////////////////// // This Trailing Stop Starts as soon as trade is Started isTS = input(false, "Trailing Stop") ts = input(3.0, "Trailing Stop (%)", minval=0,step=0.1, type=float) /100 // Initialise and track highs and lows short_ts = false, long_ts = false last_high = 0.0, last_high := nz(last_high[1],na) last_low = 0.0, last_low := nz(last_low[1],na) last_high_short = 0.0, last_high_short := nz(last_high_short[1],na) last_low_long = 0.0, last_low_long := nz(last_low_long[1],na) // LONGS TSL if in_longCondition == true last_high := (na(last_high) or high_ > last_high) ? high_ : last_high last_low_long := (na(last_low_long) or low_ < last_low_long) ? low_ : last_low_long long_ts := isTS and (low_ <= last_high - last_high * ts) //else if in_longCondition == false long_ts := false last_high := na last_low_long := na //end if //SHORTS TSL if in_shortCondition == true last_low := (na(last_low) or low_ < last_low) ? low_ : last_low last_high_short := (na(last_high_short) or high_ > last_high_short) ? high_ : last_high_short short_ts := isTS and (high_ >= last_low + last_low * ts) if in_shortCondition == false short_ts := false last_low := na last_high_short := na //end if /////////////////////////////// //======[ Take Profit ]======// /////////////////////////////// isTP = input(true, "Take Profit") tp = input(1.0, "Take Profit (%)",minval=0,step=0.1,type=float) / 100 ttp = input(0.0, "Trailing Profit (%)",minval=0,step=0.1,type=float) / 100 ttp := ttp>tp ? tp : ttp long_tp = isTP and in_longCondition and (last_high >= last_open_longCondition + last_open_longCondition * tp) and (low_ <= last_high - last_high * ttp) short_tp = isTP and in_shortCondition and (last_low <= last_open_shortCondition - last_open_shortCondition * tp) and (high_ >= last_low + last_low * ttp) ///////////////////////////// //======[ Stop Loss ]======// ///////////////////////////// isSL = input(true, "Stop Loss") sl = input(3.0, "Stop Loss (%)", minval=0,step=0.1, type=float) / 100 long_sl = isSL and in_longCondition and (low_ <= last_open_longCondition - last_open_longCondition * sl) short_sl = isSL and in_shortCondition and (high_ >= last_open_shortCondition + last_open_shortCondition * sl) //////////////////////////////////// //======[ Stop on Opposite ]======// //////////////////////////////////// //NOTE Short exit signal is non-repainting, no need to force it, if Pyramiding keep going long_sos = (fastExit or (not isTS and not isSL)) and longExit and in_longCondition short_sos = (fastExit or (not isTS and not isSL)) and shortExit and in_shortCondition ///////////////////////////////// //======[ Close Signals ]======// ///////////////////////////////// // Create a single close for all the different closing conditions, all conditions here are non-repainting longClose := isLong and (long_tp or long_sl or long_ts or long_sos) and not longCondition shortClose := isShort and (short_tp or short_sl or short_ts or short_sos) and not shortCondition /////////////////////////////// //======[ Plot Colors ]======// /////////////////////////////// longCloseCol = na shortCloseCol = na longCloseCol := long_tp ? green : long_sl ? maroon : long_ts ? purple : long_sos ? orange :longCloseCol[1] shortCloseCol := short_tp ? green : short_sl ? maroon : short_ts ? purple : short_sos ? orange : shortCloseCol[1] // tpColor = isTP and in_longCondition ? lime : isTP and in_shortCondition ? lime : na slColor = isSL and in_longCondition ? red : isSL and in_shortCondition ? red : na ////////////////////////////////// //======[ Strategy Plots ]======// ////////////////////////////////// //LONGS plot(isTS and in_longCondition? last_high - last_high * ts : na, "Buy Trailing", fuchsia, style=2, linewidth=1,offset=1) plot(isTP and in_longCondition and last_high < last_open_longCondition + last_open_longCondition * tp ? last_open_longCondition + last_open_longCondition * tp : na, "Long TP Active", tpColor, style=3,join=false, linewidth=1,offset=1) plot(isTP and in_longCondition and last_high >= last_open_longCondition + last_open_longCondition * tp ? last_high - last_high * ttp : na, "Buy Trailing", black, style=2, linewidth=1,offset=1) plot(isSL and in_longCondition and last_low_long > last_open_longCondition - last_open_longCondition * sl ? last_open_longCondition - last_open_longCondition * sl : na, "Long SL", slColor, style=3,join=false, linewidth=1,offset=1) //SHORTS plot(isTS and in_shortCondition? last_low + last_low * ts : na, "Short Trailing", fuchsia, style=2, linewidth=1,offset=1) plot(isTP and in_shortCondition and last_low > last_open_shortCondition - last_open_shortCondition * tp ? last_open_shortCondition - last_open_shortCondition * tp : na, "Short TP Active", tpColor, style=3,join=false, linewidth=1,offset=1) plot(isTP and in_shortCondition and last_low <= last_open_shortCondition - last_open_shortCondition * tp ? last_low + last_low * ttp : na, "Short Trailing", black, style=2, linewidth=1,offset=1) plot(isSL and in_shortCondition and last_high_short < last_open_shortCondition + last_open_shortCondition * sl ? last_open_shortCondition + last_open_shortCondition * sl : na, "Short SL", slColor, style=3,join=false, linewidth=1,offset=1) // Colour code the candles for Profit/Loss: Profit=LIGHT colour, Loss=DARK colour bclr = not clrBars ? na : tradeState==INACTIVE ? GRAY : in_longCondition ? close<last_open_longCondition? DARKGREEN : LIME : in_shortCondition ? close>last_open_shortCondition? DARKRED : RED : GRAY barcolor(bclr,title="Trade State Bar Colouring") /////////////////////////////// //======[ Alert Plots ]======// /////////////////////////////// //BUY SELL APEX //plotshape(longCondition?close:na, title="Buy", color=green, textcolor=green, transp=0, // style=shape.triangleup, location=location.belowbar, size=size.small,text="Buy",offset=0) //plotshape(longClose?close:na, title="Sell", color=longCloseCol, textcolor=white, transp=0, // style=shape.labeldown, location=location.abovebar, size=size.small,text="Sell",offset=0) // //SHORTS // plotshape(shortCondition?close:na, title="Short", color=red, textcolor=red, transp=0, // style=shape.triangledown, location=location.abovebar, size=size.small,text="SHORT",offset=0) // plotshape(shortClose?close:na, title="Short Close", color=shortCloseCol, textcolor=white, transp=0, // style=shape.labelup, location=location.belowbar, size=size.small,text="Short",offset=0) // Autoview alert syntax - This assumes you are trading coins BUY and SELL on Binance Exchange // WARNING*** Only use Autoview to automate a strategy after you've sufficiently backtested and forward tested the strategy. // You can learn more about the syntax here: // http://autoview.with.pink/#syntax and you can watch this video here: https://www.youtube.com/watch?v=epN5Tjinuxw // For the opens you will want to trigger BUY orders on LONGS (eg ETHBTC) with alert option "Once Per Bar Close" // and SELL orders on SHORTS (eg BTCUSDT) // b=buy q=0.001 e=binance s=ethbtc u=currency t=market ( LONG ) // or b=sell q=0.001 e=binance s=btcusdt t=market ( SHORT ) alerts = input(false, title="Turn ON Tradingview Alerts ? ") alertcondition(alerts?longCondition:na, "Buy", "BUY") //alertcondition(shortCondition, "Open Short", "SHORT") // For the closes you will want to trigger these alerts on condition with alert option "Once Per Bar" // (NOTE: with Renko you can only use "Once Per Bar Close" option) // b=sell q=99% e=binance s=ethbtc t=market ( CLOSE LONGS ) // or b=buy q=99% e=binance s=btcusdt u=currency t=market ( CLOSE SHORTS ) // This gets it as it happens and typically results in a better exit live than in the backtest. // It works really well for counteracting some market slippage alertcondition(alerts?longClose:na, "Sell", "SELL") //alertcondition(shortClose, "Close Shorts", "CLOSE SHORTS") //////////////////////////////////////////// //======[ Strategy Entry and Exits ]======// //////////////////////////////////////////// if testPeriod() and isLong strategy.entry("Long", 1, when=longCondition) strategy.close("Long", when=longClose ) //if testPeriod() and isShort // strategy.entry("Short", 0, when=shortCondition) // strategy.close("Short", when=shortClose ) // --- Debugs //plotchar(longExit,title="longExit",location=location.bottom,color=na) //plotchar(longCondition,title="longCondition",location=location.bottom,color=na) //plotchar(in_longCondition,title="in_longCondition",location=location.bottom,color=na) //plotchar(longClose,title="longClose",location=location.bottom,color=na,color=na) //plotchar(buy,title="buy",location=location.bottom,color=na) // --- /Debugs /////////////////////////////////// //======[ Reset Variables ]======// /////////////////////////////////// if longClose or shortClose tradeState := INACTIVE in_longCondition := false in_shortCondition := false last_low := na last_low_long := na last_high := na last_high_short := na // EOF //-- SUPPORT/RESISTANCE LINES by:ByDipsOnly and Allcoast ----------------------------------------------------------------------------- sr_sep = input(false, title="⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ S/R Lines ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻") show_SPlines_input = input(false, "Show S/R Lines") tf = timeframe.period vamp = input(title="VolumeMA", defval=6) vam = sma(volume, vamp) upside = high[3]>high[4] and high[4]>high[5] and high[2]<high[3] and high[1]<high[2] and volume[3]>vam[3] downside = low[3]<low[4] and low[4]<low[5] and low[2]>low[3] and low[1]>low[2] and volume[3]>vam[3] calcup() => fractalup = na fractalup := upside ? high[3] : fractalup[1] calcdown() => fractaldown = na fractaldown := downside ? low[3] : fractaldown[1] fuptf = request.security(syminfo.tickerid,tf == "current" ? period : tf, calcup()) fdowntf = request.security(syminfo.tickerid,tf == "current" ? period : tf, calcdown()) plotup = show_SPlines_input==true?fuptf:na plotdown = show_SPlines_input==true?fdowntf:na plot(plotup, "FractalUp", color=yellow, linewidth=1, style=cross, transp=0, offset =-3, join=false) plot(plotdown, "FractalDown", color=blue, linewidth=1, style=cross, transp=0, offset=-3, join=false) fractalupalert = na fractalup = na fractalup := upside ? high[3] : fractalup[1] fractalupalert := high[3] > open or fractalup[1] > open alertcondition(show_SPlines_input?fractalupalert:na, title="R Line", message='R Line') //-- END SUPPORT/RESISTANCE LINES -------------------------------------------------------------------------------------------