Pine Script v4 · Strategy
EMA_HMA_RSI_Strategy
A Pine Script v4 strategy built on RSI (close, 13), EMA (close, 200) and Highestbars (high, length+1). It has 5 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 commits 10000 in cash and pays no commission. 4 settings; defaults include EMA and HMA Length 200, RSI Length 13 and Stop Loss% 8.
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 EMA_HMA_RSI_Strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did EMA_HMA_RSI_Strategy do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings; it opened a long position that was still open on the last bar, so there is no result to report. On ETHUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Can EMA_HMA_RSI_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 EMA_HMA_RSI_Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does EMA_HMA_RSI_Strategy run in Zeal Terminal?
- Yes
- It compiles in 17 ms and runs 1,000 bars in 57 ms, in the browser.
BTCUSDT · 1D · default settings
- HULL 200
- EMA 200
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 1.78%
- −$178.35
One run with the author's default settings, $10,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.
-
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 48, 60, 65, 66. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 45
transp = on line 45. v5 folds the transparency into the colour with color.new(c, transp).
-
Note
Uses long =, which v5 renamed line 48
long = on line 48, 53. 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 wma → ta.wma, round → math.round, sqrt → math.sqrt, rsi → ta.rsi, ema → ta.ema, highestbars → ta.highestbars, lowestbars → ta.lowestbars, crossover → ta.crossover, abs → math.abs, tostring → str.tostring, crossunder → ta.crossunder.
- 4 strategy calls use the when = argument (line 48, 60, 65, 66). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 3 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 12: wma → ta.wma
- Line 12: wma → ta.wma
- Line 12: wma → ta.wma
- Line 12: round → math.round
- Line 12: sqrt → math.sqrt
18 more edits
- Line 21: rsi → ta.rsi
- Line 22: ema → ta.ema
- Line 27: highestbars → ta.highestbars
- Line 28: lowestbars → ta.lowestbars
- Line 45: transp = 25 → color.new(hullColor, 25)
- Line 48: long = true → direction = strategy.long
- Line 50: crossover → ta.crossover
- Line 50: crossover → ta.crossover
- Line 53: long = true → direction = strategy.long
- Line 55: abs → math.abs
- Line 60: tostring → str.tostring
- Line 60: abs → math.abs
- Line 60: crossunder → ta.crossunder
- Line 65: tostring → str.tostring
- Line 65: abs → math.abs
- Line 66: tostring → str.tostring
- Line 66: abs → math.abs
- Line 66: crossunder → ta.crossunder
⋯// © mohanee-//@version=4+//@version=5strategy(title="EMA_HMA_RSI_Strategy", overlay=true, pyramiding=2, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed, ⋯//HMA-HMA(src1, length1) => wma(2 * wma(src1, length1/2) - wma(src1, length1), round(sqrt(length1)))+HMA(src1, length1) => ta.wma(2 * ta.wma(src1, length1/2) - ta.wma(src1, length1), math.round(math.sqrt(length1)))var stopLossVal=0.00⋯//RSI -rsi13=rsi(close,rsiLength)+rsi13=ta.rsi(close,rsiLength)-ema200=ema(close,length)+ema200=ta.ema(close,length)hma200=HMA(close,length)⋯//Aroon oscillator-arronUpper = 100 * (highestbars(high, length+1) + length)/length+arronUpper = 100 * (ta.highestbars(high, length+1) + length)/length-aroonLower = 100 * (lowestbars(low, length+1) + length)/length+aroonLower = 100 * (ta.lowestbars(low, length+1) + length)/lengtharoonOsc = arronUpper - aroonLower⋯hullColor = hma200 > hma200[2] ? #00ff00 : #ff0000-plot(hma200, title="HULL 200", color=hullColor, transp=25)+plot(hma200, title="HULL 200", color=color.new(hullColor, 25))plot(ema200, title="EMA 200", color=color.orange)//Entry---strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, long=true, when=strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 ) // // aroonOsc<0+strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, direction = strategy.long, when=strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 ) // // aroonOsc<0//Add-if(strategy.position_size>=1 and close < strategy.position_avg_price and ( crossover(rsi13,30) or crossover(rsi13,40) ) ) // hma200 < ema200 and hma200 > hma200[2] and hma200[2] < hma200[3] ) //and crossover(rsi13,30) aroonOsc<0 //and hma200 > hma200[2] and hma200[2] <= hma200[3] //crossover(rsi13,30)+if(strategy.position_size>=1 and close < strategy.position_avg_price and ( ta.crossover(rsi13,30) or ta.crossover(rsi13,40) ) ) // hma200 < ema200 and hma200 > hma200[2] and hma200[2] < hma200[3] ) //and crossover(rsi13,30) aroonOsc<0 //and hma200 > hma200[2] and hma200[2] <= hma200[3] //crossover(rsi13,30) qty1=(strategy.initial_capital * 0.10)/close //stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 - strategy.entry(id="Long Entry", comment="Add", qty=qty1, long=true ) //crossover(close,ema34) //and close>ema34 //crossover(rsi5Val,rsiBuyLine) -- SL="+tostring(stopLossVal, "####.##")+ strategy.entry(id="Long Entry", comment="Add", qty=qty1, direction = strategy.long ) //crossover(close,ema34) //and close>ema34 //crossover(rsi5Val,rsiBuyLine) -- SL="+tostring(stopLossVal, "####.##")//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-0.5) : 0.00 -stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 +stopLossVal:= math.abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 //stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-stopLoss*0.01) : 0.00⋯if(takePartialProfits==true)- strategy.close(id="Long Entry", comment="Partial X points="+tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 , when=abs(strategy.position_size)>=1 and crossunder(rsi13, 80) and close > strategy.position_avg_price ) //close<ema55 and rsi5Val<20 //ema34<ema55+ strategy.close(id="Long Entry", comment="Partial X points="+str.tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 , when=math.abs(strategy.position_size)>=1 and ta.crossunder(rsi13, 80) and close > strategy.position_avg_price ) //close<ema55 and rsi5Val<20 //ema34<ema55//close All⋯//close All on stop loss-strategy.close(id="Long Entry", comment="Stoploss X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89+strategy.close(id="Long Entry", comment="Stoploss X points="+str.tostring(close - strategy.position_avg_price, "####.##"), when=math.abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89-strategy.close(id="Long Entry", comment="hmaXema X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close > strategy.position_avg_price and crossunder(hma200,ema200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89+strategy.close(id="Long Entry", comment="hmaXema X points="+str.tostring(close - strategy.position_avg_price, "####.##"), when=math.abs(strategy.position_size)>=1 and close > strategy.position_avg_price and ta.crossunder(hma200,ema200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89Same 3 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 15: input() → input.int()
- Line 16: input() → input.int()
- Line 17: input() → input.bool()
- Line 18: input() → input.int()
- Line 48: when = strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 → if block
- Line 60: when = math.abs(strategy.position_size)>=1 and ta.crossunder(rsi13, 80) and close > strategy.position_avg_price → if block
- Line 65: when = math.abs(strategy.position_size)>=1 and close < stopLossVal → if block
- Line 66: when = math.abs(strategy.position_size)>=1 and close > strategy.position_avg_price and ta.crossunder(hma200,ema200) → if block
⋯//variables BEGIN-length=input(200,title="EMA and HMA Length") //square root of 13+length=input.int(200,title="EMA and HMA Length") //square root of 13-rsiLength=input(13, title="RSI Length")+rsiLength=input.int(13, title="RSI Length")-takePartialProfits = input(true, title="Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) ")+takePartialProfits = input.bool(true, title="Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) ")-stopLoss = input(title="Stop Loss%", defval=8, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=8, minval=1)//variables END⋯//Entry---strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, direction = strategy.long, when=strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 ) // // aroonOsc<0+if strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70+ strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, direction = strategy.long ) // // aroonOsc<0//Add⋯if(takePartialProfits==true)- strategy.close(id="Long Entry", comment="Partial X points="+str.tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 , when=math.abs(strategy.position_size)>=1 and ta.crossunder(rsi13, 80) and close > strategy.position_avg_price ) //close<ema55 and rsi5Val<20 //ema34<ema55+ if math.abs(strategy.position_size)>=1 and ta.crossunder(rsi13, 80) and close > strategy.position_avg_price+ strategy.close(id="Long Entry", comment="Partial X points="+str.tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 ) //close<ema55 and rsi5Val<20 //ema34<ema55//close All⋯//close All on stop loss-strategy.close(id="Long Entry", comment="Stoploss X points="+str.tostring(close - strategy.position_avg_price, "####.##"), when=math.abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89+if math.abs(strategy.position_size)>=1 and close < stopLossVal+ strategy.close(id="Long Entry", comment="Stoploss X points="+str.tostring(close - strategy.position_avg_price, "####.##") ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89-strategy.close(id="Long Entry", comment="hmaXema X points="+str.tostring(close - strategy.position_avg_price, "####.##"), when=math.abs(strategy.position_size)>=1 and close > strategy.position_avg_price and ta.crossunder(hma200,ema200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89+if math.abs(strategy.position_size)>=1 and close > strategy.position_avg_price and ta.crossunder(hma200,ema200)+ strategy.close(id="Long Entry", comment="hmaXema X points="+str.tostring(close - strategy.position_avg_price, "####.##") ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89Does it run in Pine Script v6?
Yes
Same 3 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
⋯// © mohanee-//@version=5+//@version=6strategy(title="EMA_HMA_RSI_Strategy", overlay=true, pyramiding=2, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed, ⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| EMA and HMA Length | 200 | int | ema200 hma200 arronUpper aroonLower |
| RSI Length | 13 | int | rsi13 |
| Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) | true | bool | close Long Entry line 59 |
| Stop Loss% | 8 | int · min 1 | stopLossVal |
What it calculates
- RSI (
rsi,ta.rsiin v5)close, RSI Length (13)rsi13 · line 21 - EMA (
ema,ta.emain v5)close, EMA and HMA Length (200)ema200 · line 22 - Highestbars (
highestbars,ta.highestbarsin v5)high, length+1arronUpper · line 27 - Lowestbars (
lowestbars,ta.lowestbarsin v5)low, length+1aroonLower · line 28
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long Entry long | strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 | On | 48 |
| Open Long Entry long | (strategy.position_size>=1 and close < strategy.position_avg_price and ( crossover(rsi13,30) or crossover(rsi13,40) ) ) | On | 53 |
| Close Long Entry | abs(strategy.position_size)>=1 and crossunder(rsi13, 80) and close > strategy.position_avg_price | On | 60 |
| Close Long Entry | abs(strategy.position_size)>=1 and close < stopLossVal | On | 65 |
| Close Long Entry | abs(strategy.position_size)>=1 and close > strategy.position_avg_price and crossunder(hma200,ema200) | On | 66 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 1.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 2.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 9.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.2% | +8.4% | 3 | 33% | 1.09 | 2.4% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +14.6% | +16.7% | 14 | 57% | 3.50 | 3.9% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +9.5% | +21.5% | 9 | 78% | 7.31 | 2.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +10.6% | +148.3% | 10 | 80% | 8.50 | 1.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +4.2% | +17.1% | 6 | 67% | 3.84 | 2.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| EMA_HMA_RSI_Strategy this page | — | v4 strategy | 0.0% | 0 | 1.8% |
| Aroon Oscillator Strategy by mohanee | rsi ema highestbars lowestbars | v4 strategy | No trades on this market | ||
| RSI Cross [xaurr] by livetrend | rsi ema | v4 strategy | +24.4% | 53 | 35.3% |
| Bitpanda Coinrule Template by joshuajcoop01 | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrule | rsi ema | v5 strategy | −2.8% | 4 | 4.6% |
| RSI of VWAP by mohanee | rsi ema | v4 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | With a workaround 1,000 bars in 57 ms | Not measured |
| PineTS | No 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 48, 53) 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="EMA_HMA_RSI_Strategy", overlay=true, pyramiding=2, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD) //default_qty_value=10, default_qty_type=strategy.fixed, //longCondition = crossover(sma(close, 14), sma(close, 28))//if (longCondition) //strategy.entry("My Long Entry Id", strategy.long)//shortCondition = crossunder(sma(close, 14), sma(close, 28))//if (shortCondition) // strategy.entry("My Short Entry Id", strategy.short)//HMAHMA(src1, length1) => wma(2 * wma(src1, length1/2) - wma(src1, length1), round(sqrt(length1)))var stopLossVal=0.00//variables BEGINlength=input(200,title="EMA and HMA Length") //square root of 13rsiLength=input(13, title="RSI Length")takePartialProfits = input(true, title="Take Partial Profits (if this selected, RSI 13 higher reading over 80 is considered for partial closing ) ")stopLoss = input(title="Stop Loss%", defval=8, minval=1)//variables END//RSI rsi13=rsi(close,rsiLength)ema200=ema(close,length)hma200=HMA(close,length)//exitOnAroonOscCrossingDown = input(true, title="Exit when Aroon Osc cross down zero ")// Drawings//Aroon oscillatorarronUpper = 100 * (highestbars(high, length+1) + length)/lengtharoonLower = 100 * (lowestbars(low, length+1) + length)/lengtharoonOsc = arronUpper - aroonLoweraroonMidpoint = 0//oscPlot = plot(aroonOsc, color=color.green)//midLine= plot(aroonMidpoint, color=color.green)//topLine = plot(90,style=plot.style_circles, color=color.green)//bottomLine = plot(-90,style=plot.style_circles, color=color.red)//fill(oscPlot, midLine, color=aroonOsc>0?color.green:color.red, transp=50)//fill(topLine,bottomLine, color=color.blue)//fill(topLine,oscPlot, color=aroonOsc>90?color.purple:na, transp=25)// RSI //plot(rsi13, title="RSI", linewidth=2, color=color.purple)//hline(50, title="Middle Line", linestyle=hline.style_dotted)//obLevel = hline(80, title="Overbought", linestyle=hline.style_dotted)//osLevel = hline(30, title="Oversold", linestyle=hline.style_dotted)//fill(obLevel, osLevel, title="Background", color=rsi13 >=30 ? color.green:color.purple, transp=65) // longTermRSI >=50hullColor = hma200 > hma200[2] ? #00ff00 : #ff0000plot(hma200, title="HULL 200", color=hullColor, transp=25)plot(ema200, title="EMA 200", color=color.orange)//Entry--strategy.entry(id="Long Entry", comment="LE", qty=(strategy.initial_capital * 0.10)/close, long=true, when=strategy.position_size<1 and hma200 < ema200 and hma200 > hma200[2] and rsi13<70 ) // // aroonOsc<0//Addif(strategy.position_size>=1 and close < strategy.position_avg_price and ( crossover(rsi13,30) or crossover(rsi13,40) ) ) // hma200 < ema200 and hma200 > hma200[2] and hma200[2] < hma200[3] ) //and crossover(rsi13,30) aroonOsc<0 //and hma200 > hma200[2] and hma200[2] <= hma200[3] //crossover(rsi13,30) qty1=(strategy.initial_capital * 0.10)/close //stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 strategy.entry(id="Long Entry", comment="Add", qty=qty1, long=true ) //crossover(close,ema34) //and close>ema34 //crossover(rsi5Val,rsiBuyLine) -- SL="+tostring(stopLossVal, "####.##")//stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-0.5) : 0.00 stopLossVal:= abs(strategy.position_size)>1 ? ( (close > close[1] and close > open and close>strategy.position_avg_price) ? close[1]*(1-stopLoss*0.01) : stopLossVal ) : 0.00 //stopLossVal:= abs(strategy.position_size)>1 ? strategy.position_avg_price*(1-stopLoss*0.01) : 0.00barcolor(color=strategy.position_size>=1? rsi13>80 ? color.purple: color.blue:na)//close partialif(takePartialProfits==true) strategy.close(id="Long Entry", comment="Partial X points="+tostring(close - strategy.position_avg_price, "####.##"), qty_percent=20 , when=abs(strategy.position_size)>=1 and crossunder(rsi13, 80) and close > strategy.position_avg_price ) //close<ema55 and rsi5Val<20 //ema34<ema55//close All//if(exitOnAroonOscCrossingDown) // strategy.close(id="Long Entry", comment="Exit All points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and crossunder(aroonOsc, 0) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89//close All on stop lossstrategy.close(id="Long Entry", comment="Stoploss X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close < stopLossVal ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89strategy.close(id="Long Entry", comment="hmaXema X points="+tostring(close - strategy.position_avg_price, "####.##"), when=abs(strategy.position_size)>=1 and close > strategy.position_avg_price and crossunder(hma200,ema200) ) //close<ema55 and rsi5Val<20 //ema34<ema55 //close<ema89