Skip to main content

Reference Supertrend Strategy: Multi-Asset Trend Confirmation for Smarter Trade Entries

Introduction

The Mirrorpip Reference Supertrend Strategy is an advanced trend-following system that enhances the traditional Supertrend indicator by introducing confirmation from a second market. Instead of taking trades solely based on the trend direction of the chart being traded, this strategy requires both the primary symbol and a user-defined reference symbol to agree on trend direction before a trade is executed. This additional layer of confirmation helps filter false signals, reduce noise, and improve trade quality by ensuring multiple markets are moving in the same direction. The strategy can be fully automated through Mirrorpip using TradingView alerts and webhooks.

What Is a Reference Supertrend?

A traditional Supertrend strategy only evaluates the chart currently being traded. For example:
  • Trading Symbol: BTCUSDT
  • Supertrend Turns Bullish
  • Strategy Enters Long
The problem is that the broader market may not support the move. For example:
  • BTC shows Buy
  • ETH shows Sell
This disagreement between major market participants often leads to weaker trends and increased chances of false breakouts. The Reference Supertrend Strategy solves this problem by requiring both symbols to align. here is the source code of the strategy
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MirrorPip

//@version=6
strategy("REFERENCE SUPERTREND", shorttitle="REFERENCE SUPERTREND", overlay=true, default_qty_value=1, process_orders_on_close=false, calc_on_every_tick=true, calc_on_order_fills=false)

////======================================================
paraTradeMode = input.string(title='Trade Mode', defval='Both', options=['Both', 'LongOnly', 'ShortOnly'], group = "Trade Settings")
paraSystemMode = input.session(defval="Positional", title="System Mode", options=["Intraday", "Positional"], group = "Trade Settings")
s = input.session(title='Intraday Start Session:', defval='0915-1445', group='Trade Settings')
e = input.session(title='Intraday End Session:', defval='1500-1515', group='Trade Settings')

paraSTMultiplier = input.float(3, title="ST Multiplier", minval=0.1, group='SuperTrend Settings', inline = "ST")
paraSTPeriod = input.int(10, title="ST Period", minval = 1, group='SuperTrend Settings', inline = "ST")

grpRefST = "Reference SuperTrend Settings"
paraRefSTMode = input.bool(true, title='Reference ST Mode?', inline = "Ref", group = grpRefST)
paraRefSymbol = input.symbol("BINANCE:BTCUSD", "Symbol", inline = "Ref", group = grpRefST)
paraRefSTTF = input.timeframe("15", "Reference Timeframe", group = grpRefST, inline = "Ref1")
paraCustomTFMode = input.bool(false, "Custom?", group = grpRefST, inline = "Ref1")
paraCustomTF = input.int(10, "", minval=1, group = grpRefST, inline = "Ref1")
paraRefSTMultiplier = input.float(3, title="ST Multiplier", minval=0.1, group=grpRefST, inline = "Ref2")
paraRefSTPeriod = input.int(10, title="ST Period", minval = 1, group=grpRefST, inline = "Ref2")

paraTGTMode = input.string(defval="Off", title="Target : ", options=["Off", "%", "Pts"], inline = "TGT", group = "Target Settings")
paraTGT = input.float(20, "Value : ", minval = 0.1, inline = "TGT", group = "Target Settings")

paraSLMode = input.string(defval="Off", title="Stoploss : ", options=["Off", "%", "Pts"], inline = "SL", group = "Stoploss Settings")
paraSL = input.float(10, "Value : ", minval = 0.1, inline = "SL", group = "Stoploss Settings")

paraTSLMode = input.string(defval="Off", title="Trail SL : ", options=["Off", "%", "Pts"], inline = "TSL", group = "TSL Settings")
paraTSL = input.float(1, "Value : ", minval = 0.1, inline = "TSL", group = "TSL Settings")

paraShowDashboard = input.bool(true, "Show Strategy Dashboard")
////======================================================

////======================================================
grpAlgo = "Algo Setup"
paraExchange = input.string(title='Exchange', defval='delta', group=grpAlgo)
paraCode = input.string(title='Code', defval='XXXXXX', group=grpAlgo)
paraSTAG = input.string(title='Strategy Tag', defval='PRO1', group=grpAlgo)
paraPriceType = input.string(title="Price Type", defval='market',options=['market','limit'], group=grpAlgo)
paraQtyType = input.string(title="Quantity Type", defval='Fixed',options=['Fixed','$'], group=grpAlgo)
paraQtyEn = input.float(title='Entry Qty.', defval=1, minval=0, group=grpAlgo, tooltip='Qty in Lots for Futures', inline = "Qty")
paraQtyEx = input.float(title='Exit Qty. ', defval=1, minval=0, group=grpAlgo, tooltip='Qty in Lots for Futures', inline = "Qty")
paraOptMode = input.bool(true, "Options Mode?", group=grpAlgo, inline = "AlgoOpt")
paraOptUnderlying = input.string('BTC', 'Underlying Scrip', group=grpAlgo, inline = "AlgoOpt")
paraOptExpiry = input.string("200925", "Expiry", group=grpAlgo, inline = "AlgoOpt")
paraOptSteps = input.int(1000, 'Strike: Steps (ATM)', group=grpAlgo, tooltip='Options Strikes Steps for ATM', inline = "AlgoOpt1")
paraOptMulti = input.int(0, 'Offset', group=grpAlgo, tooltip='Options Strikes Offset: 0: ATM / <0: ITM / >0: OTM', inline = "AlgoOpt1")
paraOptBuySellMode = input.string("Buyer", "Options Trade Mode", options=['Buyer','Seller'], group=grpAlgo)
////======================================================

////======================================================
[SuperTrend, STTrend] = ta.supertrend(paraSTMultiplier, paraSTPeriod)

checkTF = paraRefSTTF
if (paraCustomTFMode)
    checkTF :=  str.tostring(paraCustomTF, '#') 

[RefSuperTrend, RefSTTrend] = request.security(paraRefSymbol, checkTF, ta.supertrend(paraRefSTMultiplier, paraRefSTPeriod), lookahead = barmerge.lookahead_off)
////======================================================

////======================================================
st = paraSystemMode=="Positional" ? true : not na(time(timeframe.period, s))
et = paraSystemMode=="Positional" ? false : not na(time(timeframe.period, e))

UpC = close > open
DnC = close < open

eBuy1 = STTrend==-1 
eShort1 = STTrend==1 

RefBuy1 = paraRefSTMode ? RefSTTrend == -1 : true
RefShort1 = paraRefSTMode ? RefSTTrend == 1 : true

eSignal = 0
eBuy = st and eBuy1 and RefBuy1
eShort = st and eShort1 and RefShort1
eSell = eShort or eShort1 or et or (paraRefSTMode and not RefBuy1)
eCover = eBuy or eBuy1 or et or (paraRefSTMode and not RefShort1)
eSignal := eBuy ? 1 : eShort ? -1 : eSell and eSignal[1] > 0 ? 0 : eCover and eSignal[1] < 0 ? 0 : eSignal[1]

MainSignal = 0
BuySignal = paraTradeMode!="ShortOnly" and st and eSignal > 0 and eSignal[1] <= 0 and barstate.isconfirmed and (nz(MainSignal[1]) <= 0)
ShortSignal = paraTradeMode!="LongOnly" and st and eSignal < 0 and eSignal[1] >= 0 and barstate.isconfirmed and (nz(MainSignal[1]) >= 0)
SellSignal = (((ShortSignal or eSell) and barstate.isconfirmed) or et) and (nz(MainSignal[1]) == 1)
CoverSignal = (((BuySignal or eCover) and barstate.isconfirmed) or et) and (nz(MainSignal[1]) == -1)
MainSignal := BuySignal ? 1 : ShortSignal ? -1 : SellSignal and MainSignal[1] > 0 ? 0 : CoverSignal and MainSignal[1] < 0 ? 0 : MainSignal[1]
////======================================================

////======================================================
symbol = syminfo.ticker

eBuyPrice = ta.valuewhen(BuySignal, close, 0)
eShortPrice = ta.valuewhen(ShortSignal, close, 0)

BATM = math.round(eBuyPrice/paraOptSteps)*paraOptSteps
SATM = math.round(eShortPrice/paraOptSteps)*paraOptSteps
LEStrike = BATM + (paraOptMulti * paraOptSteps)
SEStrike = SATM - (paraOptMulti * paraOptSteps)

LESym = str.tostring(syminfo.ticker) 
LXSym = str.tostring(syminfo.ticker) 
SESym = str.tostring(syminfo.ticker) 
SXSym = str.tostring(syminfo.ticker) 

var float BuyTradeQty = na
var float ShortTradeQty = na
var float SellTradeQty = na
var float CoverTradeQty = na
var float BuyRisk = na
var float ShortRisk = na
var float eBuySL = na
var float eShortSL = na
var float eBuyTGT = na
var float eShortTGT = na
var string QtySuffix = ""

BuyTradeQty := paraQtyEn
SellTradeQty := paraQtyEx
ShortTradeQty := paraQtyEn
CoverTradeQty := paraQtyEx

if (paraQtyType=="Exposure")
    BuyTradeQty := paraQtyEn / eBuyPrice
    BuyTradeQty := math.round(BuyTradeQty / syminfo.pointvalue) 
    ShortTradeQty := paraQtyEn / eShortPrice
    ShortTradeQty := math.round(ShortTradeQty / syminfo.pointvalue) 

    if (BuyTradeQty < 0)
        BuyTradeQty := 1
    if (ShortTradeQty < 0)
        ShortTradeQty := 1

    SellTradeQty := BuyTradeQty
    CoverTradeQty := ShortTradeQty

if (paraQtyType=="$")
    QtySuffix := "$"

buyData = '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LESym + '", "price_type": "' + paraPriceType + '", "order_type": "BUY", "instrument_type": "NA", "quantity": "' + str.tostring(BuyTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
sellData = '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LXSym + '", "price_type": "' + paraPriceType + '", "order_type": "SELL", "instrument_type": "NA", "quantity": "' + str.tostring(SellTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
shortData = '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SESym + '", "price_type": "' + paraPriceType + '", "order_type": "SHORT", "instrument_type": "NA", "quantity": "' + str.tostring(ShortTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
coverData = '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SXSym + '", "price_type": "' + paraPriceType + '", "order_type": "COVER", "instrument_type": "NA", "quantity": "' + str.tostring(CoverTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'

if (paraOptMode)
    if (paraOptBuySellMode == "Seller")
        LESym := "P-" + paraOptUnderlying + "-" + str.tostring(LEStrike) + "-" + paraOptExpiry
        LXSym := "P-" + paraOptUnderlying + "-" + str.tostring(LEStrike[1]) + "-" + paraOptExpiry
        SESym := "C-" + paraOptUnderlying + "-" + str.tostring(SEStrike) + "-" + paraOptExpiry
        SXSym := "C-" + paraOptUnderlying + "-" + str.tostring(SEStrike[1]) + "-" + paraOptExpiry

        buyData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LESym + '", "price_type": "' + paraPriceType + '", "order_type": "SHORT", "instrument_type": "NA", "quantity": "' + str.tostring(BuyTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        sellData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LXSym + '", "price_type": "' + paraPriceType + '", "order_type": "COVER", "instrument_type": "NA", "quantity": "' + str.tostring(SellTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        shortData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SESym + '", "price_type": "' + paraPriceType + '", "order_type": "SHORT", "instrument_type": "NA", "quantity": "' + str.tostring(ShortTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        coverData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SXSym + '", "price_type": "' + paraPriceType + '", "order_type": "COVER", "instrument_type": "NA", "quantity": "' + str.tostring(CoverTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
    else
        LESym := "C-" + paraOptUnderlying + "-" + str.tostring(LEStrike) + "-" + paraOptExpiry
        LXSym := "C-" + paraOptUnderlying + "-" + str.tostring(LEStrike[1]) + "-" + paraOptExpiry
        SESym := "P-" + paraOptUnderlying + "-" + str.tostring(SEStrike) + "-" + paraOptExpiry
        SXSym := "P-" + paraOptUnderlying + "-" + str.tostring(SEStrike[1]) + "-" + paraOptExpiry

        buyData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LESym + '", "price_type": "' + paraPriceType + '", "order_type": "BUY", "instrument_type": "NA", "quantity": "' + str.tostring(BuyTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        sellData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + LXSym + '", "price_type": "' + paraPriceType + '", "order_type": "SELL", "instrument_type": "NA", "quantity": "' + str.tostring(SellTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        shortData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SESym + '", "price_type": "' + paraPriceType + '", "order_type": "BUY", "instrument_type": "NA", "quantity": "' + str.tostring(ShortTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
        coverData := '{ "exchange": "' + paraExchange + '", "price": "' + str.tostring(close) + '", "chart_symbol": "' + SXSym + '", "price_type": "' + paraPriceType + '", "order_type": "SELL", "instrument_type": "NA", "quantity": "' + str.tostring(CoverTradeQty) + QtySuffix + '", "tp": "50%", "sl": "25%", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
////======================================================

////======================================================
if BuySignal and strategy.position_size < 0 
    strategy.entry('BUY', strategy.long, comment='Buy', qty=BuyTradeQty, alert_message="["+coverData+","+buyData+"]")
else if BuySignal and strategy.position_size == 0 
    strategy.entry('BUY', strategy.long, comment='Buy', qty=BuyTradeQty, alert_message="["+buyData+"]")

if ShortSignal and strategy.position_size > 0 
    strategy.entry('SHORT', strategy.short, comment='Short', qty=ShortTradeQty, alert_message="["+sellData+","+shortData+"]")
else if ShortSignal and strategy.position_size == 0 
    strategy.entry('SHORT', strategy.short, comment='Short', qty=ShortTradeQty, alert_message="["+shortData+"]")

var float BuyPrice = na
var float ShortPrice = na
var float BuyTGT = na
var float ShortTGT = na
var float BuySL = na
var float ShortSL = na
var float BuyTSL = na
var float ShortTSL = na

ut = (paraTGTMode != "Off")
us = (paraSLMode != "Off")

if (strategy.position_size > 0 and strategy.position_size[1] <= 0)
    BuyPrice := strategy.position_avg_price
    if (paraSLMode=="%")
        BuySL := BuyPrice * (1-(paraSL/100))
    else if (paraSLMode=="Pts")
        BuySL := BuyPrice - (paraSL)

    if (paraTGTMode=="%")
        BuyTGT := BuyPrice * (1+(paraTGT/100))
    else if (paraTGTMode=="Pts")
        BuyTGT := BuyPrice + (paraTGT)

if (strategy.position_size < 0 and strategy.position_size[1] >= 0)
    ShortPrice := strategy.position_avg_price
    if (paraSLMode=="%")
        ShortSL := ShortPrice * (1+(paraSL/100))
    else if (paraSLMode=="Pts")
        ShortSL := ShortPrice + (paraSL)

    if (paraTGTMode=="%")
        ShortTGT := ShortPrice * (1-(paraTGT/100))
    else if (paraTGTMode=="Pts")
        ShortTGT := ShortPrice - (paraTGT)

if (paraTSLMode != "Off")
    if (strategy.position_size > 0 and strategy.position_size[1] > 0)
        if (paraTSLMode=="%")
            BuyTSL := high[1] * (1-(paraTSL/100))
        else
            BuyTSL := high[1] - paraTSL
        if (BuySL < BuyTSL)
            BuySL := BuyTSL
    if (strategy.position_size < 0 and strategy.position_size[1] < 0)
        if (paraTSLMode=="%")
            ShortTSL := low[1] * (1+(paraTSL/100))
        else
            ShortTSL := low[1] + paraTSL
        if (ShortSL > ShortTSL)
            ShortSL := ShortTSL

if ut == true and us == false
    if (strategy.position_size > 0)
        strategy.exit(id='LongExit', comment="Exit", from_entry='BUY', limit=BuyTGT, alert_message="["+sellData+"]")
    if (strategy.position_size < 0)
        strategy.exit(id='ShortExit', comment="Exit", from_entry='SHORT', limit=ShortTGT, alert_message="["+coverData+"]")
if us == true and ut == false 
    if (strategy.position_size > 0)
        strategy.exit(id='LongExit', comment="Exit", from_entry='BUY', stop=BuySL, alert_message="["+sellData+"]")
    if (strategy.position_size < 0)
        strategy.exit(id='ShortExit', comment="Exit", from_entry='SHORT', stop=ShortSL, alert_message="["+coverData+"]")
if ut == true and us == true
    if (strategy.position_size > 0)
        strategy.exit(id='LongExit', comment="Exit", from_entry='BUY', limit=BuyTGT, stop=BuySL, alert_message="["+sellData+"]")
    if (strategy.position_size < 0)
        strategy.exit(id='ShortExit', comment="Exit", from_entry='SHORT', limit=ShortTGT, stop=ShortSL, alert_message="["+coverData+"]")

if (et or (SellSignal and (not ShortSignal))) and strategy.position_size > 0 
    strategy.cancel('LongExit')
    strategy.close(id='BUY', comment="Exit", alert_message="["+sellData+"]")

if (et or (CoverSignal and (not BuySignal))) and strategy.position_size < 0 
    strategy.cancel('ShortExit')
    strategy.close(id='SHORT', comment="Exit", alert_message="["+coverData+"]")

if (strategy.position_size <= 0)
    strategy.cancel('LongExit')
if (strategy.position_size >= 0)
    strategy.cancel('ShortExit')
////======================================================

////======================================================
plot(SuperTrend, color = STTrend==-1?color.green:color.red, linewidth = 1)
//plot(paraRefSTMode ? RefSuperTrend : na, color = STTrend==-1?color.green:color.red, linewidth = 3)

plot((strategy.position_size > 0)?BuyPrice:na, color=color.fuchsia, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size > 0)?BuyTGT:na, color=color.blue, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size > 0)?BuySL:na, color=color.orange, linewidth=1, style=plot.style_linebr)

plot((strategy.position_size < 0)?ShortPrice:na, color=color.fuchsia, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size < 0)?ShortTGT:na, color=color.blue, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size < 0)?ShortSL:na, color=color.orange, linewidth=1, style=plot.style_linebr)
////======================================================

////======================================================
totalCols = 2
totalRows = 5 
stgTGTFlag = paraTGTMode != "Off"
stgSLFlag = paraSLMode != "Off"

if stgTGTFlag
    totalRows += 1
if stgSLFlag
    totalRows += 1

var dashtable = table.new(position.bottom_left, totalCols, totalRows,
  frame_color=color.new(#000000,0),
  frame_width=1,
  border_color=color.new(#000000,0),
  border_width=1)

cell_up = #237a27 //input.color(#237a27,'Buy Cell Color'  ,group='Style Settings')
cell_dn = color.red //input.color(color.red,'Sell Cell Color'  ,group='Style Settings')
cell_Neut = color.gray //input.color(color.gray,'Neut Cell Color'  ,group='Style Settings')
txt_col = color.white

table_text_size = size.small

openProfit = strategy.openprofit
lastProfit = strategy.closedtrades.profit(strategy.closedtrades-1)
openProfitColor = openProfit >= 0 ? cell_up : cell_dn
lastProfitColor = lastProfit >= 0 ? cell_up : cell_dn

rowCtr = 0
colCtr = 0

if (barstate.islast and paraShowDashboard)
    table.cell(dashtable, 0, rowCtr, "Dashboard", text_color=txt_col, text_size=table_text_size, bgcolor=color.new(color.blue,80), tooltip="")  
    table.cell(dashtable, 1, rowCtr, '', text_color=txt_col, text_size=table_text_size, bgcolor=color.new(color.blue,80), tooltip="")
    table.merge_cells(dashtable, 0, 0, 1, 0)

    if strategy.position_size > 0
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Buy",text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(strategy.position_avg_price, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Qty.",text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(strategy.position_size, "#"),text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        if (stgTGTFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "TGT",text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
            table.cell(dashtable, 1, rowCtr, str.tostring(BuyTGT, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        if (stgSLFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "SL",text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
            table.cell(dashtable, 1, rowCtr, str.tostring(BuySL, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "P&L",text_color=txt_col,text_size=table_text_size,bgcolor=openProfitColor,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(openProfit, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=openProfitColor,tooltip="")

    if strategy.position_size < 0
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Short",text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(strategy.position_avg_price, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Qty.",text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(strategy.position_size, "#"),text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        if (stgTGTFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "TGT",text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
            table.cell(dashtable, 1, rowCtr, str.tostring(ShortTGT, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_up,tooltip="")
        if (stgSLFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "SL",text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
            table.cell(dashtable, 1, rowCtr, str.tostring(ShortSL, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=cell_dn,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "P&L",text_color=txt_col,text_size=table_text_size,bgcolor=openProfitColor,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(openProfit, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=openProfitColor,tooltip="")

    if strategy.position_size == 0
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "No Trade", text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        table.cell(dashtable, 1, rowCtr, "Relax", text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        table.cell(dashtable, 1, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        if (stgTGTFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
            table.cell(dashtable, 1, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        if (stgSLFlag)
            rowCtr += 1
            table.cell(dashtable, 0, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
            table.cell(dashtable, 1, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")
        table.cell(dashtable, 1, rowCtr, "",text_color=txt_col,text_size=table_text_size,bgcolor=cell_Neut,tooltip="")

    if strategy.position_size <= 0 and strategy.position_size[1] > 0
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Exit Buy",text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(lastProfit, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
    else if strategy.position_size >= 0 and strategy.position_size[1] < 0
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Exit Short",text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(lastProfit, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
    else    
        rowCtr += 1
        table.cell(dashtable, 0, rowCtr, "Last P&L",text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
        table.cell(dashtable, 1, rowCtr, str.tostring(lastProfit, format.mintick),text_color=txt_col,text_size=table_text_size,bgcolor=lastProfitColor,tooltip="")
////======================================================

Core Strategy Logic

The strategy uses two independent Supertrend indicators:

Primary Supertrend

Applied to the chart being traded. Example:
  • BTCUSDT
  • 15 Minute Chart
  • ATR Length = 10
  • Multiplier = 3

Reference Supertrend

Applied to a separate user-defined symbol. Example:
  • ETHUSDT
  • 15 Minute Chart
  • ATR Length = 10
  • Multiplier = 3

A trade is triggered only when both Supertrend indicators point in the same direction.

Long Entry Conditions

A Long position is opened only when: ✓ Primary Symbol Supertrend = Buy AND ✓ Reference Symbol Supertrend = Buy

Example

Trading Symbol: BTCUSDT Current Supertrend Signal: Buy Reference Symbol: ETHUSDT Current Supertrend Signal: Buy Result: ✅ Long Trade Triggered

Short Entry Conditions

A Short position is opened only when: ✓ Primary Symbol Supertrend = Sell AND ✓ Reference Symbol Supertrend = Sell

Example

Trading Symbol: BTCUSDT Current Supertrend Signal: Sell Reference Symbol: ETHUSDT Current Supertrend Signal: Sell Result: ✅ Short Trade Triggered

When Trades Are Blocked

The strategy intentionally ignores conflicting signals.

Example 1

BTC Supertrend = Buy ETH Supertrend = Sell Result: ❌ No Trade

Example 2

BTC Supertrend = Sell ETH Supertrend = Buy Result: ❌ No Trade
This filter helps avoid many low-conviction market conditions where different assets are moving in opposite directions.

Why Reference Confirmation Works

Financial markets are highly correlated. Major cryptocurrencies often move together. Examples include:
  • BTC and ETH
  • ETH and SOL
  • BTC and TOTAL Market Cap
  • NIFTY and BANKNIFTY
  • Gold and Silver
  • Nasdaq and S&P 500
When multiple correlated assets trend in the same direction, the probability of sustained momentum often increases. The Reference Supertrend Strategy attempts to capture these higher-conviction opportunities.

Multi-Timeframe Confirmation

One of the most powerful features of this strategy is independent timeframe selection for the reference symbol. The reference symbol does not need to use the same timeframe as the traded symbol.

Example 1: Trend Alignment

Trading Symbol: BTCUSDT Timeframe: 15 Minutes Reference Symbol: ETHUSDT Reference Timeframe: 4 Hours Trade Logic: Long trades are allowed only when:
  • BTC 15-Minute Supertrend = Buy
  • ETH 4-Hour Supertrend = Buy
This ensures lower timeframe entries align with higher timeframe market structure.

Example 2: Swing Trading Filter

Trading Symbol: SOLUSDT Timeframe: 30 Minutes Reference Symbol: BTCUSDT Reference Timeframe: Daily Trade Logic: SOL trades only in the direction of BTC’s daily trend. This can significantly reduce counter-trend trades.

Independent Supertrend Parameters

Another advanced feature is the ability to configure separate Supertrend settings for both symbols. Most multi-symbol indicators force identical settings. This strategy does not. Users can optimize each market independently.

Example

Primary Symbol

BTCUSDT ATR Length = 10 Multiplier = 3

Reference Symbol

ETHUSDT ATR Length = 20 Multiplier = 4
This flexibility allows traders to adapt to different volatility characteristics of each market.

Practical Examples

Example 1: BTC Confirmed By ETH

Primary Symbol: BTCUSDT Supertrend: 10,3
Reference Symbol: ETHUSDT Supertrend: 10,3
Condition: BTC Buy ETH Buy Result: ✅ Long Position

Example 2: ETH Confirmed By BTC Daily Trend

Primary Symbol: ETHUSDT Timeframe: 15 Minutes
Reference Symbol: BTCUSDT Timeframe: 1 Day
Condition: ETH Buy BTC Daily Buy Result: ✅ Long Position
This setup is commonly used by swing traders who want lower timeframe entries aligned with macro market direction.

Stop Loss Configuration

Users can define custom stop losses. Supported modes include:

Fixed Point Stop Loss

Example: 100 Point Stop Loss

Percentage Stop Loss

Example: 2% Stop Loss
This provides flexibility across crypto, forex, commodities, and equity markets.

Take Profit Configuration

The strategy supports configurable profit targets.

Fixed Point Target

Example: 300 Points

Percentage Target

Example: 5%
Users can combine Supertrend exits with predefined profit objectives.

Best Reference Symbol Combinations

Cryptocurrency Markets

Trading SymbolReference Symbol
BTCUSDTETHUSDT
ETHUSDTBTCUSDT
SOLUSDTBTCUSDT
XRPUSDTBTCUSDT
DOGEUSDTBTCUSDT

Indian Markets

Trading SymbolReference Symbol
BANKNIFTYNIFTY
NIFTYBANKNIFTY
FINNIFTYBANKNIFTY

US Markets

Trading SymbolReference Symbol
QQQSPY
SPYQQQ
Individual StocksS&P 500

Commodities

Trading SymbolReference Symbol
SilverGold
GoldDXY
Crude OilBrent Oil

Benefits of Reference Supertrend

Reduced False Signals

Trades are taken only when both markets agree.

Stronger Trend Confirmation

Helps identify high-conviction market moves.

Multi-Timeframe Filtering

Allows lower timeframe entries while respecting higher timeframe trends.

Better Trade Quality

Fewer trades but often higher-quality setups.

Highly Customizable

Separate:
  • Symbols
  • Timeframes
  • ATR Lengths
  • Multipliers
  • Targets
  • Stop Losses

Risk Management Considerations

While reference confirmation can improve signal quality, no strategy can eliminate losing trades. Traders should:
  • Backtest across multiple market conditions
  • Use proper position sizing
  • Avoid excessive leverage
  • Test different reference symbols
  • Optimize timeframes carefully
Correlations between assets can change over time, so periodic review is recommended.

Mirrorpip Automation Setup

The strategy can be deployed on Mirrorpip in minutes. Workflow: TradingView Strategy → TradingView Alert → Mirrorpip Webhook → Exchange Account → Trade Execution Users can automate the strategy across multiple exchanges while monitoring performance from a single dashboard. Mirrorpip provides detailed analytics including:
  • Win Rate
  • Maximum Drawdown
  • Sharpe Ratio
  • Average Trade Duration
  • Profit Factor
  • Equity Curve Analysis

Conclusion

The Mirrorpip Reference Supertrend Strategy takes the classic Supertrend indicator to the next level by introducing multi-asset and multi-timeframe confirmation. By requiring trend alignment between a primary trading symbol and a user-selected reference symbol, the strategy seeks to filter weak signals and participate only in higher-conviction market moves. With support for independent Supertrend settings, separate reference timeframes, customizable targets and stop losses, and full Mirrorpip automation support, traders gain a powerful framework for trend-following across crypto, stocks, indices, forex, and commodities.