0% found this document useful (0 votes)
71 views2 pages

Deepseek Pinescript 20250510 1ff1b0

This document outlines a trading strategy using the Momentum Trend approach with various technical indicators including RSI and EMAs. It defines conditions for buying, selling, being cautious, and adding to positions based on price movements and indicator thresholds. The strategy also includes signal tracking and performance metrics to evaluate trade outcomes.

Uploaded by

munal23
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
0% found this document useful (0 votes)
71 views2 pages

Deepseek Pinescript 20250510 1ff1b0

This document outlines a trading strategy using the Momentum Trend approach with various technical indicators including RSI and EMAs. It defines conditions for buying, selling, being cautious, and adding to positions based on price movements and indicator thresholds. The strategy also includes signal tracking and performance metrics to evaluate trade outcomes.

Uploaded by

munal23
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
You are on page 1/ 2

//@version=6

strategy("Momentum Trend Strategy: Buy/Cautious/Add/Sell with EMA Filter",


overlay=true, margin_long=100, margin_short=100)

// === Technical Indicators ===


rsi = ta.rsi(close, 14)
ema21 = ta.ema(close, 21)
ema50 = ta.ema(close, 50)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)

// 30-week WMA approximated as 150-day WMA


wma30 = ta.wma(close, 150)
plot(wma30, title='30 Week WMA', color=color.rgb(243, 8, 8))

// === Buy Condition: Candle Pattern + RSI + EMA Filter ===


buyTrend = high > high[1] and high[1] > high[2] and low > low[1] and low[1] >
low[2] and close > close[1] and close[1] > close[2] and close > wma30

rsiOk = rsi > 50


emaOk = ema21 > ema50

buyCond = buyTrend and rsiOk and emaOk

// === Sell Condition ===


sellTrend = high < high[1] and high[1] < high[2] and low < low[1] and low[1] <
low[2] and close < close[1] and close[1] < close[2]

sellCond = sellTrend and close < ema21

// === Cautious Condition ===


cautiousCond = high < high[1] and close < close[1] and low < low[1]

// === Add More: bounce after EMA21, after Cautious, not after Sell ===
bounceFromEMA = close > close[1] and close > ema21 and close[1] <= ema21

// === Signal Tracking ===


var string trend = 'none'
var string lastSignal = 'none'

newBuy = buyCond and trend != 'buy'


newSell = sellCond and trend != 'sell'
newCautious = cautiousCond and (trend == 'buy' or trend == 'add') and trend !=
'cautious'
newAdd = buyCond and trend == 'cautious' and lastSignal != 'sell'

// === Update Trend & Signal States ===


if newBuy
trend := 'buy'
lastSignal := 'buy'
else if newAdd
trend := 'add'
lastSignal := 'add'
else if newSell
trend := 'sell'
lastSignal := 'sell'
else if newCautious
trend := 'cautious'
lastSignal := 'cautious'
// === Plot Signals ===
plotshape(newBuy, title='Buy', location=location.belowbar, color=color.green,
style=shape.labelup, text='B', offset=-1)
plotshape(newAdd, title='Add More', location=location.belowbar, color=color.teal,
style=shape.labelup, text='A', offset=-1)
plotshape(newSell, title='Sell', location=location.abovebar, color=color.red,
style=shape.labeldown, text='S', offset=-1)
plotshape(newCautious, title='Cautious', location=location.abovebar,
color=color.orange, style=shape.triangledown, text='⚠️', offset=-1)

// === Strategy Execution ===


// Entry conditions
if (newBuy)
strategy.entry("Main Long", strategy.long)

if (newAdd)
strategy.entry("Add Position", strategy.long)

// Exit condition
if (newSell)
strategy.close_all()

// === Performance Tracking ===


var float entryPrice = na
if (newBuy or newAdd)
entryPrice := close

if (newSell and not na(entryPrice))


profitPct = (close - entryPrice) / entryPrice * 100
label.new(bar_index, high,
text=str.tostring(profitPct, "#.##") + "%",
color=profitPct >= 0 ? color.green : color.red,
style=profitPct >= 0 ? label.style_label_up : label.style_label_down,
yloc=yloc.abovebar)
entryPrice := na

// Optional Risk Management


// strategy.exit("Take Profit/Stop Loss", "Main Long", stop=close*0.98,
limit=close*1.15)
// strategy.exit("Take Profit/Stop Loss", "Add Position", stop=close*0.98,
limit=close*1.15)

You might also like