Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

RSI W Pattern strategy

A Pine Script v4 strategy built on RSI (close, 5), EMA (close, 5) and Crossover (myRsi, 75). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 5 settings; defaults include RSI Period 5, look for W pattern bottom edges well below RSI level (BUY) 65 and Long Term EMA 50.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does RSI W Pattern strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
How did RSI W Pattern strategy do on BTCUSDT 1D with default settings?
+27.55%
From 26 Jan 2024 to 21 Oct 2026, over 15 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can RSI W Pattern strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does RSI W Pattern strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI W Pattern strategy run in Zeal Terminal?
Yes
It compiles in 16 ms and runs 1,000 bars in 39 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI
  • Middle Line
  • Overbought
  • Oversold
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (5)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI$130,007$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 35, 37) so the engine trades the way the script says.
Net profit
+27.55%
$27,547.30
Buy and hold
+102.5%
same period
Closed trades
15
11 won · 4 lost
Profitable
73.3%
of closed trades
Profit factor
2.32
gross profit ÷ gross loss
Max drawdown
14.42%
−$16,214.10

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    ema(close, 5) ignores the settings line 19

    Line 19 hard-codes 5 where line 20 uses “Short Term EMA”. Changing those settings moves one band but not this one.

    ema(close,5)ema(close, emaS)
  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 35, 37, 68, 71. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 51

    transp = on line 51, 52, 64. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 35

    long = on line 35, 37. v5 writes it as direction = strategy.long or strategy.short.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames rsi → ta.rsi, ema → ta.ema, crossover → ta.crossover.
  • 4 strategy calls use the when = argument (line 35, 37, 68, 71). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 15 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 16: rsi → ta.rsi
  • Line 19: ema → ta.ema
  • Line 20: ema → ta.ema
  • Line 20: ema → ta.ema
  • Line 35: long = true → direction = strategy.long
7 more edits
  • Line 37: long = true → direction = strategy.long
  • Line 37: crossover → ta.crossover
  • Line 51: transp = 90 → color.new(#9915FF, 90)
  • Line 52: transp = 0 → color.new(color.purple, 0)
  • Line 64: transp = 40 → color.new(strategy.position_size>0?color.green:na, 40)
  • Line 66: crossover → ta.crossover
  • Line 68: crossover → ta.crossover
⋯// © mohanee-//@version=4+//@version=5strategy(title="RSI W Pattern strategy", pyramiding=2, shorttitle="RSI W Pattern", overlay = false)⋯//rsiWp1=false-myRsi = rsi(close,len)+myRsi = ta.rsi(close,len)//longEmaVal=ema(close,emaL)//shortEmaVal=ema(close,emaS)-entryEma=ema(close,5)  // This is used as filetr for BUY+entryEma=ta.ema(close,5)  // This is used as filetr for BUY-isEma20AboveEma50=ema(close,emaS)>ema(close,emaL) ? true : false +isEma20AboveEma50=ta.ema(close,emaS)>ta.ema(close,emaL) ? true : false //W Pattern⋯//initial entry-strategy.entry("RSI_W_LE", comment="Buy" , long=true, when=longCondition  )+strategy.entry("RSI_W_LE", comment="Buy" , direction = strategy.long, when=longCondition  )//legging in to existing -strategy.entry("RSI_W_LE",comment="Add", long=true, when=strategy.position_size>0 and crossover(myRsi,10 ))+strategy.entry("RSI_W_LE",comment="Add", direction = strategy.long, when=strategy.position_size>0 and ta.crossover(myRsi,10 ))//calculate stoploss value⋯osLevel = hline(30, title="Oversold", color=color.purple, linestyle=hline.style_dashed)-fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)+fill(obLevel, osLevel, title="Background", color=color.new(#9915FF, 90))plotshape(⋯     location=location.absolute,-     color=color.purple,+     color=color.new(color.purple, 0),-     textcolor=color.yellow,-     transp=0+     textcolor=color.yellow     )        -bgcolor(strategy.position_size>0?color.green:na, transp=40, title='In Long Position')+bgcolor(color.new(strategy.position_size>0?color.green:na, 40), title='In Long Position')//take profit or close when RSI reaches 75    -takeProfit=crossover(myRsi,75)+takeProfit=ta.crossover(myRsi,75)//close when RSi reaches profit level -strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=crossover(myRsi,75) and close>strategy.position_avg_price )+strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=ta.crossover(myRsi,75) and close>strategy.position_avg_price )//close everything when stoploss hit  ⋯

Clean v5

VerifiedDownload the v5 script

Same 15 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
  • Line 35: when = longCondition → if block
3 more edits
  • Line 37: when = strategy.position_size>0 and ta.crossover(myRsi,10 ) → if block
  • Line 67: when = ta.crossover(myRsi,75) and close>strategy.position_avg_price → if block
  • Line 70: when = longCloseCondition → if block
⋯//Exit when RSI reaches 75 -len = input(title="RSI Period", minval=1, defval=5)+len = input.int(title="RSI Period", minval=1, defval=5)-buyRsiEntry = input(title="look for W pattern bottom edges well below RSI level (BUY) ", minval=10, defval=65, maxval=70)+buyRsiEntry = input.int(title="look for W pattern bottom edges well below RSI level (BUY) ", minval=10, defval=65, maxval=70)//numberOfBars = input(title="Number of Bars in W pattern ", minval=4, defval=4, maxval=6)-emaL = input(title="Long Term EMA", minval=1, defval=50, maxval=200)+emaL = input.int(title="Long Term EMA", minval=1, defval=50, maxval=200)-emaS = input(title="Short Term EMA", minval=1, defval=20, maxval=200)+emaS = input.int(title="Short Term EMA", minval=1, defval=20, maxval=200)-stopLoss = input(title="Stop Loss %", minval=1, defval=8, maxval=10)+stopLoss = input.int(title="Stop Loss %", minval=1, defval=8, maxval=10)//rsiWp1=false⋯//initial entry-strategy.entry("RSI_W_LE", comment="Buy" , direction = strategy.long, when=longCondition  )+if longCondition+    strategy.entry("RSI_W_LE", comment="Buy" , direction = strategy.long  )//legging in to existing -strategy.entry("RSI_W_LE",comment="Add", direction = strategy.long, when=strategy.position_size>0 and ta.crossover(myRsi,10 ))+if strategy.position_size>0 and ta.crossover(myRsi,10 )+    strategy.entry("RSI_W_LE",comment="Add", direction = strategy.long)//calculate stoploss value⋯//close when RSi reaches profit level -strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=ta.crossover(myRsi,75) and close>strategy.position_avg_price )+if ta.crossover(myRsi,75) and close>strategy.position_avg_price+    strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size )//close everything when stoploss hit  longCloseCondition=close<(strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100)  ) //or crossunder(myRsi,30)-strategy.close("RSI_W_LE", comment="SL Exit", qty=strategy.position_size,when=longCloseCondition )+if longCloseCondition+    strategy.close("RSI_W_LE", comment="SL Exit", qty=strategy.position_size )

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 15 before, 7 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © mohanee-//@version=5+//@version=6strategy(title="RSI W Pattern strategy", pyramiding=2, shorttitle="RSI W Pattern", overlay = false)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
RSI Period5int · min 1myRsi
look for W pattern bottom edges well below RSI level (BUY) 65int · min 10 · max 70longCondition
Long Term EMA50int · min 1 · max 200isEma20AboveEma50
Short Term EMA20int · min 1 · max 200isEma20AboveEma50
Stop Loss %8int · min 1 · max 10stopLossValue longCloseCondition

What it calculates

  • RSI (rsi, ta.rsi in v5)close, RSI Period (5)myRsi · line 16
  • EMA (ema, ta.ema in v5)close, 5entryEma · line 19
  • EMA (ema, ta.ema in v5)close, Short Term EMA (20)isEma20AboveEma50 · line 20
  • Crossover (crossover, ta.crossover in v5)myRsi, 75takeProfit · line 66

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

closecloseprice datalenRSI Periodsetting · 5emaSShort Term EMAsetting · 20emaLLong Term EMAsetting · 50stopLossStop Loss %setting · 8buyRsiEntrylook for W pattern bott…setting · 65lowlowprice datamyRsiRSI→ myRsientryEmaEMA→ entryEmaisEma20AboveEma50EMA→ isEma20AboveEma50takeProfitCrossover→ takeProfitstopLossValuestopLossValuevaluelongConditionlongConditionconditionlongCloseConditionlongCloseConditionconditionrsiWp1rsiWp1conditionrsiPlotColorColourrsiPlotColorentry:RSI_W_LEOpen RSI_W_LEstrategy.entryclose:RSI_W_LEClose RSI_W_LEstrategy.closebarcolor:33barcolorbarcolorplot:41RSIplothline:48Middle Linehlinehline:49Overboughthlinehline:50Oversoldhlinefill:BackgroundBackgroundfillplotshape:52W Patternplotshapebgcolor:64In Long Positionbgcolor

Order rules

OrderFires whenBy defaultLine
Open RSI_W_LE longlongConditionisEma20AboveEma50 and rsiWp1 and (myRsi<=buyRsiEntry and myRsi>=30)On35
Open RSI_W_LE longstrategy.position_size>0 and crossover(myRsi,10 )On37
Close RSI_W_LEcrossover(myRsi,75) and close>strategy.position_avg_priceOn68
Close RSI_W_LElongCloseConditionclose<(strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100) )On71

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

3/3trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+27.5%+102.5%1573%2.3214.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+3.3%+5.5%1486%1.3213.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.2%+9.8%1369%1.881.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.4%+8.4%1782%2.200.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%1533%0.310.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1675%1.800.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1573%1.090.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%1675%0.750.2%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (RSI Period 6, Long Term EMA 85) made +48.7% before 26 Dec 2025 and +17.2% after it, against +9.2% for the defaults. 85% of the 48 combinations made money in-sample and 100% out-of-sample.

Before 26 Dec 2025 · in-sample
Long Term EMA ↓ · RSI Period →345679
25+27%+15%+31%+34%+17%−1%
30+31%+10%+26%+29%+12%−6%
35+31%+10%+26%+29%+12%−6%
43+31%+10%+26%+29%+12%−6%
50+33%+5%+18%+21%+7%−7%
60+38%+11%+29%+32%+17%−6%
70+38%+11%+29%+32%+17%−6%
85+33%+28%+46%+49%+28%+5%
From 26 Dec 2025 · out-of-sample
Long Term EMA ↓ · RSI Period →345679
25+10%+11%+9%+17%+17%+17%
30+10%+11%+9%+17%+17%+17%
35+10%+11%+9%+17%+17%+17%
43+10%+11%+9%+17%+17%+17%
50+10%+11%+9%+17%+17%+17%
60+10%+11%+9%+17%+17%+17%
70+10%+11%+9%+17%+17%+17%
85+10%+11%+9%+17%+17%+17%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market771%$17,648.00
Sideways market875%$9,899.23
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

15.7%

The 95th percentile of the worst drawdown when the same 15 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.8% to 15.7%; the tick is what actually happened, 10.3%. Order luck alone moves it this much.

0%18%
All 15 trades
SideEntryExitBarsP&L
long17 Apr 2024 63,793.402 May 2024 58,365.0015−$5,428.43
long19 Apr 2024 63,470.102 May 2024 58,365.0013−$5,105.12
long2 Jun 2024 67,766.805 Jun 2024 70,537.803$2,770.99
long4 Jun 2024 68,809.905 Jun 2024 70,537.801$1,727.94
long23 Oct 2024 67,426.0030 Oct 2024 72,736.407$5,310.40
long25 Oct 2024 68,198.3030 Oct 2024 72,736.405$4,538.14
long4 Dec 2024 95,849.7016 Dec 2024 104,464.0012$8,614.30
long15 Feb 2025 97,500.5026 Feb 2025 88,680.4011−$8,820.08
long16 Jun 2025 105,594.0011 Jul 2025 116,010.0025$10,416.00
long23 Aug 2025 116,936.0012 Sep 2025 115,483.0020−$1,453.31
long29 Aug 2025 112,567.0012 Sep 2025 115,483.0014$2,915.79
long21 Sep 2025 115,686.002 Oct 2025 118,595.0011$2,909.36
long1 Sep 2026 78,581.304 Sep 2026 81,270.403$2,689.07
long6 Sep 2026 79,831.8020 Sep 2026 81,250.0014$1,418.24
long17 Sep 2026 76,206.0020 Sep 2026 81,250.003$5,043.99

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
RSI W Pattern strategy this page—v4 strategy+27.5%1514.4%
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%
Bitpanda Coinrule Template by joshuajcoop01rsi emav5 strategy−2.8%44.6%
RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrulersi emav5 strategy−2.8%44.6%
RSI of VWAP by mohaneersi emav4 strategyNo trades on this market
EMA SCALPEUR + RSi - SHORT by YukalMoonrsi emav5 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 16 msWith a workaround 1,000 bars in 39 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 35, 37) so the engine trades the way the script says.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © mohanee//@version=4strategy(title="RSI W Pattern strategy", pyramiding=2, shorttitle="RSI W Pattern", overlay = false)//Strategy Rules//ema20 is above ema50//RSI5 making W pattern in oversold area  or just below 70 level  , you can define the value for parameter buyRsiEntry --- dont go beyond 70//Exit when RSI reaches 75 len = input(title="RSI Period", minval=1, defval=5)buyRsiEntry = input(title="look for W pattern bottom edges well below RSI level (BUY) ", minval=10, defval=65, maxval=70)//numberOfBars = input(title="Number of Bars in W pattern ", minval=4, defval=4, maxval=6)emaL = input(title="Long Term EMA", minval=1, defval=50, maxval=200)emaS = input(title="Short Term EMA", minval=1, defval=20, maxval=200)stopLoss = input(title="Stop Loss %", minval=1, defval=8, maxval=10)//rsiWp1=falsemyRsi = rsi(close,len)//longEmaVal=ema(close,emaL)//shortEmaVal=ema(close,emaS)entryEma=ema(close,5)  // This is used as filetr for BUYisEma20AboveEma50=ema(close,emaS)>ema(close,emaL) ? true : false //W Pattern//rsiWp1 =  myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4] //This is published onersiWp1 =    myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4] and (low[1]<=low[4] or low[3]<=low[4] ) // looking for recent low//rsiWp1 =  myRsi>myRsi[1] and myRsi>=30 and myRsi[1]<myRsi[2] and myRsi[2]>myRsi[3]  and myRsi[3]<myRsi[4]  //Ths one has 92% win rate and 4.593 prfit factor//long condition filters//1. ema20 > ema50//2. Rsi5 has W pattern//3. current RSI <= 65 (parameter buyRsiEntry)  (dont go beyond 70 , becuase that is already overbought area)//4. current price low/close is below 5 ema --- looking for pullback  -- OptionallongCondition =  isEma20AboveEma50 and rsiWp1   and (myRsi<=buyRsiEntry  and myRsi>=30)  //and (low<entryEma or close<entryEma)  --- if this optional required , add it to above conditionpatternText=" W "barcolor(longCondition?color.yellow:na)//initial entrystrategy.entry("RSI_W_LE", comment="Buy" , long=true, when=longCondition  )//legging in to existing strategy.entry("RSI_W_LE",comment="Add", long=true, when=strategy.position_size>0 and crossover(myRsi,10 ))//calculate stoploss valuestopLossValue=strategy.position_avg_price -  (strategy.position_avg_price*stopLoss/100) rsiPlotColor=longCondition ?color.yellow:color.purpleplot(myRsi, title="RSI", linewidth=2, color=color.purple)//    plot(myRsi, title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)    //plot(myRsi[1], title="RSI", linewidth=2, color=rsiWp1==true?color.yellow:color.purple)    //plot(myRsi[2], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)    //plot(myRsi[3], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)    //plot(myRsi[4], title="RSI", linewidth=2, color=rsiWp1?color.yellow:color.purple)    hline(40, title="Middle Line", color=color.blue, linestyle=hline.style_dashed)obLevel = hline(75, title="Overbought", color=color.red, linestyle=hline.style_dashed)osLevel = hline(30, title="Oversold", color=color.purple, linestyle=hline.style_dashed)fill(obLevel, osLevel, title="Background", color=#9915FF, transp=90)plotshape(     longCondition ? myRsi[1] : na,     offset=-1,     title="W Pattern",     text=patternText,     style=shape.labelup,     location=location.absolute,     color=color.purple,     textcolor=color.yellow,     transp=0     )        bgcolor(strategy.position_size>0?color.green:na, transp=40, title='In Long Position')//take profit or close when RSI reaches 75    takeProfit=crossover(myRsi,75)//close when RSi reaches profit level strategy.close("RSI_W_LE", comment="TP Exit", qty=strategy.position_size,when=crossover(myRsi,75) and close>strategy.position_avg_price )//close everything when stoploss hit  longCloseCondition=close<(strategy.position_avg_price - (strategy.position_avg_price*stopLoss/100)  ) //or crossunder(myRsi,30)strategy.close("RSI_W_LE", comment="SL Exit", qty=strategy.position_size,when=longCloseCondition )