length = input( 100 ) overSold = input( 47 ) overBought = input( 58 ) price = close mode = input(1, minval=0,maxval=1, title="HA == 0 or Renko == 1 ?") rev = input(false, title="Reverse Logic?") short = input(true, title="Do Short?") renko_atr_len = input(15, title="Renko Length", minval=1) //close_ha = security(heikinashi(syminfo.tickerid), timeframe.period, close) close_ha = ohlc4 close_renko = security(renko(syminfo.tickerid, "ATR", renko_atr_len), timeframe.period, close) vrsi = mode == 0 ? rsi(close_ha, length) : rsi(close_renko,length) condition_long = crossover(vrsi, overSold) and rev==false or (crossunder(vrsi, overSold) and rev==true) condition_short = crossunder(vrsi, overBought) and rev==false or (crossover(vrsi, overSold) and rev==true) //preced = co ? 1 : cu ? -1 : 0 if (not na(vrsi)) if (condition_long) strategy.entry("RsiLE", strategy.long, comment="RsiLE") if (condition_short and short==true) strategy.entry("RsiSE", strategy.short, comment="RsiSE") if (condition_short and short==false) strategy.close("RsiLE", comment="Close LNG") //plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr) stop_loss_long_percent = input(4.5, title="Stop Loss Long", minval=0.1, step=0.1) stop_loss_long = (1-stop_loss_long_percent/100)*strategy.position_avg_price take_profit_long_percent = input(6, title="Take Profit Long", minval=0.1, step=0.1) take_profit_long = (1+take_profit_long_percent/100)*strategy.position_avg_price stop_loss_short_percent = input(4.1,title="Stop Loss Short", minval=0.1, step=0.1) stop_loss_short = (1+stop_loss_short_percent/100)*strategy.position_avg_price take_profit_short_percent = input(4.8,title="Take Profit Short", minval=0.1, step=0.1) take_profit_short = (1-take_profit_short_percent/100)*strategy.position_avg_price strategy.exit("TP-SL Long", "RsiLE", limit = take_profit_long , stop = stop_loss_long) //, trail_price = trail_price_long , trail_offset = trail_offset_long) //, trail_offset=tsl_offset_tick, trail_price=tsl_offset_tick) strategy.exit("TP-SL Short", "RsiSE", limit = take_profit_short , stop = stop_loss_short)