Skip to main content

Black Rock Strategy

Overview

The Black Rock Strategy is a breakout-based trading system designed to capture strong directional moves when price breaks out of a significant rolling high or low. The strategy continuously tracks the highest high and lowest low of the previous rolling 24-hour period (fully configurable by the user) and plots these levels directly on the chart as breakout zones. When price successfully breaks above the rolling high, the strategy enters a Long position. When price breaks below the rolling low, the strategy enters a Short position. To maximize profits during strong trends, the strategy also includes an advanced Pyramiding (Winner Averaging) feature, allowing traders to add to winning positions as additional breakouts occur. The strategy comes with built-in Mirrorpip automation support, enabling fully automated trade execution across supported exchanges. here is the source code
// 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(" MIRRORPIP BLACKROCK", shorttitle="MIRRORPIP BLACKROCK", overlay=true, default_qty_value=1, process_orders_on_close=false, calc_on_every_tick=true, calc_on_order_fills=false, margin_long = 10, margin_short = 10, pyramiding = 99)

////======================================================
paraTradeMode = input.string(defval="all", title="Trade Type : ", options=["all", "long", "short"], 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')

paraCBPeriod = input.int(20, title="Breakout Period", minval = 1, group='Trade Settings', inline = "CB")
paraNoOfPyramids = input.int(5, title="Max. Pyramiding", minval = 0, maxval = 99, group='Trade Settings', inline = "CB")

paraTGTMode = input.string(defval="Off", title="Target : ", options=["Off", "%", "Pts"], inline = "TGT", group = "Target Settings")
paraTGT = input.float(2, "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(1, "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)
////======================================================

////======================================================
CBHH = ta.highest(high, paraCBPeriod)
CBLL = ta.lowest(low, paraCBPeriod)
////======================================================

////======================================================
strategy.risk.allow_entry_in(paraTradeMode)
AlgoBuyCond = paraTradeMode != "short"
AlgoShortCond = paraTradeMode != "long"

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

CBBuy = close > CBHH[1] and barstate.isconfirmed
CBShort = close < CBLL[1] and barstate.isconfirmed

eSignal = 0
eBuyPos = 0
eShortPos = 0
eBuy = st and CBBuy and barstate.isconfirmed
eShort = st and CBShort and barstate.isconfirmed
eSell = et or CBShort
eCover = et or CBBuy
eSignal := eBuy ? 1 : eShort ? -1 : eSell and eSignal[1] > 0 ? 0 : eCover and eSignal[1] < 0 ? 0 : eSignal[1]
eBuyPos := eBuy ? 1 : eSell and eBuyPos[1] > 0 ? 0 : eBuyPos[1]
eShortPos := eShort ? -1 : eCover and eShortPos[1] < 0 ? 0 : eShortPos[1]

MainSignal = 0
BuySignal = AlgoBuyCond and st and eBuy and barstate.isconfirmed and (nz(MainSignal[1]) <= 0) //eSignal > 0 and eSignal[1] <= 0
ShortSignal = AlgoShortCond and st and eShort and barstate.isconfirmed and (nz(MainSignal[1]) >= 0) //eSignal < 0 and eSignal[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]
//MainSignal := BuySignal ? 1 : ShortSignal ? -1 : ((SellSignal and MainSignal[1] > 0) or strategy.position_size == 0) ? 0 : ((CoverSignal and MainSignal[1] < 0) or strategy.position_size == 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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'

if (paraOptMode)
    if (paraOptBuySellMode == "Seller")
        LEStrike := BATM - (paraOptMulti * paraOptSteps)
        SEStrike := SATM + (paraOptMulti * paraOptSteps)

        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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "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": "0", "sl": "0", "code": "'+paraCode+'", "stag": "'+paraSTAG+'"}'
////======================================================

////======================================================
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
var int buyScaleCtr = na
var int shortScaleCtr = na
var int lastBuyScaleBar = na
var int lastShortScaleBar = na

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

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

if (paraNoOfPyramids > 0)

    if (st and CBBuy and strategy.position_size > 0 and buyScaleCtr <= paraNoOfPyramids and bar_index > (lastBuyScaleBar+paraCBPeriod))
        buyScaleCtr += 1
        lastBuyScaleBar := bar_index
        strategy.entry('BUY', strategy.long, comment='Buy', qty=BuyTradeQty, alert_message="["+coverData+","+buyData+"]")

    if (st and CBShort and strategy.position_size < 0 and shortScaleCtr <= paraNoOfPyramids and bar_index > (lastShortScaleBar+paraCBPeriod))
        shortScaleCtr += 1
        lastShortScaleBar := bar_index
        strategy.entry('SHORT', strategy.short, comment='Short', qty=ShortTradeQty, alert_message="["+shortData+"]")

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

if (strategy.position_size > 0 and (strategy.position_size[1] <= 0 or (strategy.position_size > strategy.position_size[1])))

    BuyPrice := strategy.position_avg_price
    if strategy.position_size[1] <= 0
        buyScaleCtr := 0

    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 or (strategy.position_size < strategy.position_size[1])))

    ShortPrice := strategy.position_avg_price
    if strategy.position_size[1] >= 0
        shortScaleCtr := 0

    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) and strategy.position_size > 0 
//     strategy.cancel('LongExit')
//     strategy.close(id='BUY', comment="Exit", alert_message="["+sellData+"]")

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

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

if (et or (CoverSignal and (not BuySignal or not AlgoBuyCond))) 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(CBHH, "Breakout High", color.yellow)
plot(CBLL, "Breakout Low", color.yellow)

plotshape(strategy.position_size<=0?eBuy:false, style=shape.diamond , location=location.belowbar, color=color.green, size=size.tiny)
plotshape(strategy.position_size>=0?eShort:false, style=shape.diamond, location=location.abovebar, color=color.red, size=size.tiny)

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

plot((strategy.position_size < 0)?ShortPrice:na, "ShortPrice", color=color.fuchsia, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size < 0)?ShortTGT:na, "ShortTGT", color=color.blue, linewidth=1, style=plot.style_linebr)
plot((strategy.position_size < 0)?ShortSL:na, "ShortSL", 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="")
////======================================================

Key Features

Dynamic Rolling High & Low Detection

The strategy continuously calculates:
  • Rolling High
  • Rolling Low
based on a user-defined lookback period. By default:
  • Rolling High = Highest price of the last 24 hours
  • Rolling Low = Lowest price of the last 24 hours
These levels automatically update as new candles form.

Visual Breakout Levels

The strategy plots two highly visible yellow lines:

Upper Yellow Line

Represents the rolling high. Acts as a bullish breakout level.

Lower Yellow Line

Represents the rolling low. Acts as a bearish breakout level. These levels help traders clearly identify potential breakout zones on the chart.

Customizable Lookback Period

Although the default setting is 24 hours, traders can configure any lookback period. Examples:
  • 12 Hours
  • 24 Hours
  • 48 Hours
  • 72 Hours
  • Multi-Day Breakouts
This flexibility allows the strategy to adapt to different markets and trading styles.

Long Entry Logic

A Buy signal is generated when:
  • Price closes above the rolling high.
  • The breakout is confirmed by candle close.
Once the breakout occurs:
  • Mirrorpip automatically places a Long order.
  • Trade management begins immediately.

Example

24-Hour High = 100,000 Price closes at 100,250 → Long Position Triggered

Short Entry Logic

A Sell/Short signal is generated when:
  • Price closes below the rolling low.
  • The breakout is confirmed by candle close.
Mirrorpip automatically executes the Short trade on supported exchanges.

Example

24-Hour Low = 95,000 Price closes at 94,800 → Short Position Triggered

Advanced Winner Averaging (Pyramiding)

One of the most powerful features of the Black Rock Strategy is its ability to add to winning positions. Unlike traditional averaging, which increases exposure during losing trades, this strategy allows traders to add only when the market continues moving in their favor.

Long Position Pyramiding

After a Long position is opened:
  • If a new rolling high is created and subsequently broken again,
  • The strategy can add another Long position.
This process can repeat multiple times depending on user settings. Benefits:
  • Increases exposure during strong uptrends.
  • Maximizes gains from powerful breakout moves.
  • Allows systematic position scaling.

Short Position Pyramiding

After a Short position is opened:
  • If a new rolling low is created and subsequently broken again,
  • The strategy can add another Short position.
Benefits:
  • Captures extended downtrends.
  • Builds larger positions only when the trend is working.

Full Control Over Position Sizing

Users can define:

Maximum Pyramid Levels

Examples:
  • 1 Entry Only
  • 2 Entries
  • 3 Entries
  • 5 Entries
  • Unlimited (subject to Pine settings)

Position Size Per Entry

Examples:
  • Fixed Quantity
  • Fixed Capital Allocation
  • Percentage-Based Allocation
This gives traders complete control over risk and exposure.

Dual Profit Targets

The strategy supports two independent profit targets.

Target 1 (T1)

Can be configured in:
  • Percentage (%)
  • Points
Examples:
  • 1%
  • 2%
  • 100 Points

Target 2 (T2)

Can be configured independently in:
  • Percentage (%)
  • Points
Examples:
  • 3%
  • 5%
  • 300 Points
This allows partial profit booking while keeping the remaining position open for larger breakout moves.

Stop Loss Management

Risk management is fully customizable.

Percentage-Based Stop Loss

Examples:
  • 1%
  • 2%
  • 3%

Point-Based Stop Loss

Examples:
  • 50 Points
  • 100 Points
  • 200 Points
Mirrorpip automatically exits positions if the stop loss level is reached.

Trailing Stop Loss (TSL)

The strategy includes dynamic Trailing Stop Loss functionality.

TSL Options

Configure TSL using:
  • Percentage
  • Points
Benefits:
  • Protects profits automatically.
  • Helps capture larger trends.
  • Reduces drawdowns during reversals.

Best Markets for the Black Rock Strategy

The strategy performs particularly well in markets that experience strong directional breakouts. Popular markets include:
  • Bitcoin (BTC)
  • Ethereum (ETH)
  • Crypto Futures
  • Forex Pairs
  • Gold
  • Silver
  • Index Futures
  • Bank Nifty
  • Nifty Futures

Intraday Trading

  • 5 Minute
  • 15 Minute
  • 30 Minute

Swing Trading

  • 1 Hour
  • 4 Hour

Positional Trading

  • Daily
  • Weekly

Fully Automated with Mirrorpip

The strategy comes with built-in Mirrorpip automation support.

Setup Process

  1. Add the Black Rock Strategy to your TradingView chart.
  2. Configure the rolling high/low lookback period.
  3. Set pyramiding levels.
  4. Configure Targets, Stop Loss, and Trailing Stop Loss.
  5. Create a TradingView Alert.
  6. Connect the alert to Mirrorpip.
  7. Mirrorpip automatically executes and manages trades on your exchange account.
No coding knowledge is required.

Supported Exchanges

Mirrorpip supports automated execution on multiple exchanges including:
  • Bybit
  • Binance
  • Delta Exchange
  • CoinSwitch
  • OKX
  • Bitget
  • Gate.io
  • KuCoin
  • Shark Exchange
and many more.

Why Traders Use the Black Rock Strategy

  • Simple breakout-based logic.
  • Fully objective trading rules.
  • Captures powerful trending moves.
  • Dynamic breakout levels.
  • Advanced winner averaging through pyramiding.
  • Complete position sizing control.
  • Works across stocks, futures, forex, and crypto.
  • Fully automated with Mirrorpip.

Risk Disclaimer

Breakout strategies can experience false breakouts and periods of consolidation. Always:
  • Use appropriate stop losses.
  • Configure sensible position sizes.
  • Limit pyramiding according to risk tolerance.
  • Backtest settings before live deployment.
Trading involves risk and no strategy guarantees profits.

Conclusion

The Black Rock Strategy is a powerful breakout trading system that identifies opportunities using rolling high and low levels while providing advanced position-building capabilities through pyramiding. With customizable breakout periods, dual profit targets, flexible stop loss and trailing stop loss management, and seamless Mirrorpip integration, traders can fully automate a disciplined breakout trading approach across virtually any market.