100% found this document useful (2 votes)
1K views3 pages

5-Minute Trading Strategy Script

Uploaded by

joel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
1K views3 pages

5-Minute Trading Strategy Script

Uploaded by

joel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//@version=6

strategy("5min Entry System Pro", overlay=true,


initial_capital=10000,
default_qty_type=strategy.percent_of_equity,
default_qty_value=100,
commission_type=[Link],
commission_value=0.04)

// === Inputs ===


higherTF = [Link]("D", "Higher TF")
entryTF = [Link]("5", "Entry TF")
stopLossPips = [Link](25, "Stop Loss", minval=1)
tp1Pips = [Link](35, "TP1", minval=1)
tp2Pips = [Link](70, "TP2", minval=1)
tp3Pips = [Link](100, "TP3", minval=1)
preAlertBars = [Link](3, "Pre-Alert Bars", minval=1)

// === Global Variables ===


var float entryPrice = na
var bool tradeActive = false
var line entryLine = na
var line slLine = na
var line tp1Line = na
var line tp2Line = na
var line tp3Line = na
var label[] alertLabels = array.new_label()

// === Multi-Timeframe Data ===


dailyHigh = [Link]([Link], higherTF, high)
dailyLow = [Link]([Link], higherTF, low)
dailyClose = [Link]([Link], higherTF, close)
dailySMA50 = [Link](dailyClose, 50)

// === 5min Entry Logic ===


m5High = [Link]([Link], entryTF, high)
m5Low = [Link]([Link], entryTF, low)
m5Close = [Link]([Link], entryTF, close)

isUptrend = dailyClose > dailySMA50 and dailyHigh > dailyHigh[1]


isDowntrend = dailyClose < dailySMA50 and dailyLow < dailyLow[1]

potentialBuy = isUptrend and m5Low <= m5Low[1] and m5Close > m5Close[1]
potentialSell = isDowntrend and m5High >= m5High[1] and m5Close < m5Close[1]

// === Pre-Entry Alerts ===


if potentialBuy and not potentialBuy[1]
lbl = [Link](bar_index, low, "▲ POTENTIAL BUY\nMonitor 5min",
color=[Link](#00FF00, 90), style=label.style_label_up,
textcolor=[Link])
[Link](alertLabels, lbl)

if potentialSell and not potentialSell[1]


lbl = [Link](bar_index, high, "▼ POTENTIAL SELL\nMonitor 5min",
color=[Link](#FF0000, 90), style=label.style_label_down,
textcolor=[Link])
[Link](alertLabels, lbl)

// Cleanup old alerts


if [Link](alertLabels) > 0
for i = 0 to [Link](alertLabels)-1
if bar_index - label.get_x([Link](alertLabels, i)) > preAlertBars
[Link]([Link](alertLabels, i))

// === Trade Execution ===


if potentialBuy and not tradeActive
[Link]("BUY", [Link])
entryPrice := close
tradeActive := true
// Create visuals
entryLine := [Link](bar_index, entryPrice, na, na,
color=[Link], width=2, extend=[Link])
slLine := [Link](bar_index, entryPrice - stopLossPips*[Link], na,
na,
color=[Link], style=line.style_dotted, extend=[Link])
tp1Line := [Link](bar_index, entryPrice + tp1Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])
tp2Line := [Link](bar_index, entryPrice + tp2Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])
tp3Line := [Link](bar_index, entryPrice + tp3Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])

if potentialSell and not tradeActive


[Link]("SELL", [Link])
entryPrice := close
tradeActive := true
// Create visuals
entryLine := [Link](bar_index, entryPrice, na, na,
color=[Link], width=2, extend=[Link])
slLine := [Link](bar_index, entryPrice + stopLossPips*[Link], na,
na,
color=[Link], style=line.style_dotted, extend=[Link])
tp1Line := [Link](bar_index, entryPrice - tp1Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])
tp2Line := [Link](bar_index, entryPrice - tp2Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])
tp3Line := [Link](bar_index, entryPrice - tp3Pips*[Link], na, na,
color=[Link], style=line.style_dotted, extend=[Link])

// === Trade Management ===


if tradeActive
// Update lines
line.set_x2(entryLine, bar_index)
line.set_x2(slLine, bar_index)
line.set_x2(tp1Line, bar_index)
line.set_x2(tp2Line, bar_index)
line.set_x2(tp3Line, bar_index)

// Check exit
if strategy.position_size == 0
[Link](entryLine)
[Link](slLine)
[Link](tp1Line)
[Link](tp2Line)
[Link](tp3Line)
entryPrice := na
tradeActive := false

// === Visual Signals ===


plotshape(potentialBuy, "Buy Alert", [Link], [Link],
[Link], 0, "PRE-BUY", size=[Link])
plotshape(potentialSell, "Sell Alert", [Link], [Link],
[Link], 0, "PRE-SELL", size=[Link])

You might also like