// This Strategy was Created by ©NoobSharks // if you use it and like it, send us some donation: BinancePay ID: 223731148 - Metamask: 0x82782b3ebD1d6bf7faa18a3943fA6f16EBBF3134 // (yes, I might be naive but I trully Believe you will support us) // For more information about this indicator check "https://www.youtube.com/c/NoobSharksLutanoMercadoCripto" and give us a hand following us on YouTube // Check also our website includeing strategies, free indicatores and technical analysis videos: https://www.noobsharks.com //@version=5 strategy(title="[NB] Strategy - Triple Moving Averages Adjustable", shorttitle="[NB]STG.TripleMA.Adj", overlay=true, default_qty_type = strategy.cash, default_qty_value = 10, initial_capital = 100, pyramiding = 0) maType = input.string(defval = "WMA", title="MA Type", options=["SMA","EMA","WMA", "VWMA", "RMA"]) tpMode = input.string(defval = "RR Ratio", title="TP Strategy (check tooltip)", options = ["RR Ratio", "MA Cross", "Fixed Profit %"], tooltip = "Stop Loss will be aways when MA cross the opposite direction of the trade. Longs: stop at Low MA Cross, Shorts: stop at High MA Cross") len = input.int(32, minval=1, title="Length") rrRatio = input.float(defval = 1, step = 0.1, minval = 0.1, title = "Rusk Return Ratio", tooltip = "Valid only for *RR Ratio* take profit mode") fixedProfit = input.float(defval = 1, step = 0.1, title = "Fixed Profit %", minval = 0.1, tooltip = "Valid only for *Fixed Price* take profit mode") / 100 ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "EMA" => ta.ema(source, length) "RMA" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) avgCenter = ma(close,len, maType) avgMax = ma(high,len, maType) avgMin = ma(low,len, maType) plot(avgCenter, title="Center", color=color.white, linewidth = 2) plot(avgMax, title="Center", color=color.green, linewidth = 2) plot(avgMin, title="Center", color=color.red, linewidth = 2) longEntry = ta.crossover(close, avgMax) longStop = ta.crossunder(close, avgMin) shortEntry = ta.crossunder(close, avgMin) shortStop = ta.crossover(close, avgMax) // ----- TP AND SL FOR RR RATIO TP MODE if tpMode == "RR Ratio" if strategy.position_size == 0 if longEntry[1] and close > avgMax strategy.entry(id="buy", direction=strategy.long, comment="GoLong") strategy.exit(id = "exitLong", from_entry = "buy", limit = (((close-avgMin)*rrRatio)+close), stop = avgMin, comment_profit="TPLong", comment_loss="SLLong") if shortEntry[1] and close < avgMin strategy.entry(id="sell", direction=strategy.short, comment = "GoShort") strategy.exit(id = "exitShort", from_entry = "sell", limit = (((close-avgMax)*rrRatio)+close), stop = avgMax, comment_profit="TPShort", comment_loss="SLShort") if tpMode == "MA Cross" if strategy.position_size == 0 if longEntry[1] and close > avgMax strategy.entry(id="buy", direction=strategy.long, comment="GoLong") strategy.exit(id = "exitLong", from_entry = "buy", stop = avgMin, comment_profit="TPLong", comment_loss="SLLong") if shortEntry[1] and close < avgMin strategy.entry(id="sell", direction=strategy.short, comment = "GoShort") strategy.exit(id = "exitShort", from_entry = "sell", stop = avgMax, comment_profit="TPShort", comment_loss="SLShort") if longStop strategy.close(id="buy", comment = "KillLong") if shortStop strategy.close(id="sell", comment = "KillShort") if tpMode == "Fixed Profit %" if strategy.position_size == 0 if longEntry[1] and close > avgMax strategy.entry(id="buy", direction=strategy.long, comment="GoLong") strategy.exit(id = "exitLong", from_entry = "buy", stop = avgMin, comment_profit="TPLong", comment_loss="SLLong") if shortEntry[1] and close < avgMin strategy.entry(id="sell", direction=strategy.short, comment = "GoShort") strategy.exit(id = "exitShort", from_entry = "sell", stop = avgMax, comment_profit="TPShort", comment_loss="SLShort") if strategy.openprofit >= fixedProfit strategy.close_all(comment = strategy.position_size > 0 ? "TPLong" : "TPShort", immediately = true)