Pine Script v4 · Strategy
Koala System EURUSD 15min
A Pine Script v4 strategy built on SMA (hl2, 3), EMA (close, 200) and SMA or EMA (close, 12). It has 5 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays 0.000065 commission. 29 settings; defaults include From Day 1, From Month 1 and From Year 2000.
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 Koala System EURUSD 15min repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did Koala System EURUSD 15min 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, so there is no result to report. Its code limits trading to a date window, which can leave this period out. On BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Can Koala System EURUSD 15min be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does Koala System EURUSD 15min use a stop loss?
- Yes
- strategy.exit sets a stop on line 91, 94.
- Does Koala System EURUSD 15min run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 80 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- SMA
- SMA
- SMA
- EMA
- SMA
- SMA
- SMA
- ATR
- 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
- 0.00%
- $0.00
One run with the author's default settings, $1,000 starting capital, commission as the script sets it. 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.
-
Note
Uses an argument v6 removed
when = on line 90, 93, 96. The upgraded version below moves each call inside an if block.
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 sma → ta.sma, ema → ta.ema, atr → ta.atr.
- 3 strategy calls use the when = argument (line 90, 93, 96). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
DiffersTrades differ: 25 before, 34 after on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 22: sma → ta.sma
- Line 27: sma → ta.sma
- Line 32: sma → ta.sma
- Line 37: sma → ta.sma
- Line 41: ema → ta.ema
17 more edits
- Line 46: input(type = input.integer) → input.int()
- Line 47: input(type = input.integer) → input.int()
- Line 48: input(type = input.source) → input.source()
- Line 49: input(type = input.integer) → input.int()
- Line 50: input(type = input.bool) → input.bool()
- Line 51: input(type = input.bool) → input.bool()
- Line 53: sma → ta.sma
- Line 53: ema → ta.ema
- Line 54: sma → ta.sma
- Line 54: ema → ta.ema
- Line 56: sma → ta.sma
- Line 56: ema → ta.ema
- Line 66: atr → ta.atr
- Line 66: atr → ta.atr
- Line 82: input(type = input.float) → input.float()
- Line 90: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 93: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
⋯// © SoftKill21-//@version=4+//@version=5strategy("Koala Script",initial_capital=1000, ⋯smma = 0.0-sma1 = sma(src, len)+sma1 = ta.sma(src, len)smma := na(smma[1]) ? sma1 : (smma[1] * (len - 1) + src) / len⋯smma2 = 0.0-sma2 = sma(src2, len2)+sma2 = ta.sma(src2, len2)smma2 := na(smma2[1]) ? sma2 : (smma2[1] * (len2 - 1) + src2) / len2⋯smma3 = 0.0-sma3 = sma(src3, len3)+sma3 = ta.sma(src3, len3)smma3 := na(smma3[1]) ? sma3 : (smma3[1] * (len3 - 1) + src3) / len3⋯smma4 = 0.0-sma4 = sma(src4, len4)+sma4 = ta.sma(src4, len4)smma4 := na(smma4[1]) ? sma4 : (smma4[1] * (len4 - 1) + src4) / len4⋯src5 = input(close, title="Source")-out5 = ema(src5, len5)+out5 = ta.ema(src5, len5)timeinrange(res, sess) => time(res, sess) != 0⋯time_cond = time >= startDate and time <= finishDate and londonEntry-fast_length = input(title="Fast Length", type=input.integer, defval=12)+fast_length = input.int(title="Fast Length", defval=12)-slow_length = input(title="Slow Length", type=input.integer, defval=26)+slow_length = input.int(title="Slow Length", defval=26)-srcc = input(title="Source", type=input.source, defval=close)+srcc = input.source(title="Source", defval=close)-signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)+signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)-sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)+sma_source = input.bool(title="Simple MA(Oscillator)", defval=false)-sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)+sma_signal = input.bool(title="Simple MA(Signal Line)", defval=false)// Calculating-fast_ma = sma_source ? sma(srcc, fast_length) : ema(srcc, fast_length)+fast_ma = sma_source ? ta.sma(srcc, fast_length) : ta.ema(srcc, fast_length)-slow_ma = sma_source ? sma(srcc, slow_length) : ema(srcc, slow_length)+slow_ma = sma_source ? ta.sma(srcc, slow_length) : ta.ema(srcc, slow_length)macd = fast_ma - slow_ma-signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)+signal = sma_signal ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)hist = macd - signal⋯ii=syminfo.pointvalue==0-s=ii?na:oa?atr(length):(syminfo.pointvalue * mult * atr(length))+s=ii?na:oa?ta.atr(length):(syminfo.pointvalue * mult * ta.atr(length))tp=input(300,title="tp")⋯floating = strategy.openprofit //floating profit/loss-risk = input(3,type=input.float,title="Risk %")/100 //risk % per trade+risk = input.float(3,title="Risk %")/100 //risk % per trade //Calculate the size of the next trade⋯ size := 10000 //Set min. lot size-strategy.entry("long",1,size,when=longCond )+strategy.entry("long",strategy.long,size,when=longCond )strategy.exit("closelong","long", profit=tp,loss=sl)//strategy.close("long",when= crossunder(close[4],smma4) and close[4] > close[3] and close[3]>close[2] and close[2] > close[1] and close[1] > close)-strategy.entry("short",0,size,when=shortCond )+strategy.entry("short",strategy.short,size,when=shortCond )strategy.exit("closeshort","short", profit=tp,loss=sl)⋯Clean v5
VerifiedSame 34 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 13: input() → input.int()
- Line 14: input() → input.int()
- Line 15: input() → input.int()
19 more edits
- Line 19: input() → input.int()
- Line 20: input() → input.source()
- Line 24: input() → input.int()
- Line 25: input() → input.source()
- Line 29: input() → input.int()
- Line 30: input() → input.source()
- Line 34: input() → input.int()
- Line 35: input() → input.source()
- Line 39: input() → input.int()
- Line 40: input() → input.source()
- Line 62: input() → input.int()
- Line 63: input() → input.float()
- Line 64: input() → input.bool()
- Line 67: input() → input.int()
- Line 68: input() → input.int()
- Line 90: when = longCond → if block
- Line 93: when = shortCond → if block
- Line 96: when = not london → if block
- Line 97: input() → input.int()
⋯ slippage=3)-fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)+fromDay = input.int(defval = 1, title = "From Day", minval = 1, maxval = 31)-fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)+fromMonth = input.int(defval = 1, title = "From Month", minval = 1, maxval = 12)-fromYear = input(defval = 2000, title = "From Year", minval = 1970)+fromYear = input.int(defval = 2000, title = "From Year", minval = 1970) // To Date Inputs-toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)+toDay = input.int(defval = 1, title = "To Day", minval = 1, maxval = 31)-toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)+toMonth = input.int(defval = 8, title = "To Month", minval = 1, maxval = 12)-toYear = input(defval = 2021, title = "To Year", minval = 1970)+toYear = input.int(defval = 2021, title = "To Year", minval = 1970) ⋯finishDate = timestamp(toYear, toMonth, toDay, 00, 00)-len = input(3, minval=1, title="Length")+len = input.int(3, minval=1, title="Length")-src = input(hl2, title="Source")+src = input.source(hl2, title="Source")smma = 0.0⋯smma := na(smma[1]) ? sma1 : (smma[1] * (len - 1) + src) / len-len2 = input(6, minval=1, title="Length")+len2 = input.int(6, minval=1, title="Length")-src2 = input(hl2, title="Source")+src2 = input.source(hl2, title="Source")smma2 = 0.0⋯smma2 := na(smma2[1]) ? sma2 : (smma2[1] * (len2 - 1) + src2) / len2-len3 = input(9, minval=1, title="Length")+len3 = input.int(9, minval=1, title="Length")-src3 = input(hl2, title="Source")+src3 = input.source(hl2, title="Source")smma3 = 0.0⋯smma3 := na(smma3[1]) ? sma3 : (smma3[1] * (len3 - 1) + src3) / len3-len4 = input(50, minval=1, title="Length")+len4 = input.int(50, minval=1, title="Length")-src4 = input(close, title="Source")+src4 = input.source(close, title="Source")smma4 = 0.0⋯smma4 := na(smma4[1]) ? sma4 : (smma4[1] * (len4 - 1) + src4) / len4-len5 = input(200, minval=1, title="Length")+len5 = input.int(200, minval=1, title="Length")-src5 = input(close, title="Source")+src5 = input.source(close, title="Source")out5 = ta.ema(src5, len5)⋯//shortCond2 = crossunder(close,out5) and crossunder(close,smma4) and crossunder(close,smma3) and crossunder(close,smma2) and crossunder(close,smma) and time_cond-length=input(14, title="ATR Length")+length=input.int(14, title="ATR Length")-mult=input(1.0, title="Percentage Multiplier (for ex., 0.7 = 70%)", step=0.1, minval=0.1, maxval=5.0)+mult=input.float(1.0, title="Percentage Multiplier (for ex., 0.7 = 70%)", step=0.1, minval=0.1, maxval=5.0)-oa=input(false, title="Show actual ATR")+oa=input.bool(false, title="Show actual ATR")ii=syminfo.pointvalue==0s=ii?na:oa?ta.atr(length):(syminfo.pointvalue * mult * ta.atr(length))-tp=input(300,title="tp")+tp=input.int(300,title="tp")-sl=input(300,title="sl")+sl=input.int(300,title="sl")//tp = s*10000⋯ size := 10000 //Set min. lot size-strategy.entry("long",strategy.long,size,when=longCond )+if longCond+ strategy.entry("long",strategy.long,size )strategy.exit("closelong","long", profit=tp,loss=sl)//strategy.close("long",when= crossunder(close[4],smma4) and close[4] > close[3] and close[3]>close[2] and close[2] > close[1] and close[1] > close)-strategy.entry("short",strategy.short,size,when=shortCond )+if shortCond+ strategy.entry("short",strategy.short,size )strategy.exit("closeshort","short", profit=tp,loss=sl)//strategy.close("short",when= crossover(close[4],smma4) and close[4] < close[3] and close[3]< close[2] and close[2] < close[1] and close[1] < close)-strategy.close_all(when = not london)+if not london+ strategy.close_all()-maxEntry=input(2,title="max entries")+maxEntry=input.int(2,title="max entries")strategy.risk.max_intraday_filled_orders(maxEntry)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: 34 before, 0 after on BTCUSDT 4h, 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.
⋯// © SoftKill21-//@version=5+//@version=6strategy("Koala Script",initial_capital=1000, ⋯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 |
|---|---|---|---|
| From Day | 1 | int · min 1 · max 31 | startDate |
| From Month | 1 | int · min 1 · max 12 | startDate |
| From Year | 2000 | int · min 1970 | startDate |
| To Day | 1 | int · min 1 · max 31 | finishDate |
| To Month | 8 | int · min 1 · max 12 | finishDate |
| To Year | 2021 | int · min 1970 | finishDate |
| Length | 3 | int · min 1 | smma sma1 |
| Source | hl2 | source | smma sma1 |
| Length | 6 | int · min 1 | smma2 sma2 |
| Source | hl2 | source | smma2 sma2 |
| Length | 9 | int · min 1 | smma3 sma3 |
| Source | hl2 | source | smma3 sma3 |
| Length | 50 | int · min 1 | smma4 sma4 |
| Source | close | source | smma4 sma4 |
| Length | 200 | int · min 1 | out5 |
| Source | close | source | out5 |
| Fast Length | 12 | int (written input.integer) | fast_ma |
| Slow Length | 26 | int (written input.integer) | slow_ma |
| Source | close | source | fast_ma slow_ma |
| Signal Smoothing | 9 | int (written input.integer) · min 1 · max 50 | signal |
| Simple MA(Oscillator) | false | bool | fast_ma slow_ma |
| Simple MA(Signal Line) | false | bool | signal |
| ATR Length | 14 | int | s |
| Percentage Multiplier (for ex., 0.7 = 70%) | 1.0 | float · min 0.1 · max 5.0 · step 0.1 | s |
| Show actual ATR | false | bool | s |
| tp | 300 | int | exit closelong exit closeshort |
| sl | 300 | int | temp02 exit closelong exit closeshort |
| Risk % | 3 | float | temp01 |
| max entries | 2 | int | line 98 |
What it calculates
- SMA (
sma,ta.smain v5)Source (hl2), Length (3)sma1 · line 22 - SMA (
sma,ta.smain v5)Source (hl2), Length (6)sma2 · line 27 - SMA (
sma,ta.smain v5)Source (hl2), Length (9)sma3 · line 32 - SMA (
sma,ta.smain v5)Source (close), Length (50)sma4 · line 37 - EMA (
ema,ta.emain v5)Source (close), Length (200)out5 · line 41 - SMA / EMA (
sma,ta.smain v5)Source (close), Fast Length (12)fast_ma · line 53 - SMA / EMA (
sma,ta.smain v5)Source (close), Slow Length (26)slow_ma · line 54 - SMA / EMA (
sma,ta.smain v5)macd, Signal Smoothing (9)signal · line 56 - ATR (
atr,ta.atrin v5)ATR Length (14)s · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | longCondclose > out5 and close > smma4 and close > smma3 and close > smma2 and close > smma and londonEntry and smma > smma2 and smma2>smma3 and smma3>smma4 and smma4>out5 | On | 90 |
| Exit closelong stop and limit | every bar | On | 91 |
| Open short short | shortCondclose < out5 and close < smma4 and close < smma3 and close < smma2 and close < smma and londonEntry and smma < smma2 and smma2<smma3 and smma3<smma4 and smma4<out5 | On | 93 |
| Exit closeshort stop and limit | every bar | On | 94 |
| Close | not london | On | 96 |
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% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −15,453.3% | +5.5% | 25 | 40% | 0.66 | 21,453.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +81,742.5% | +8.4% | 32 | 53% | 2.80 | 18,422.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −800,074.0% | +21.5% | 23 | 48% | 0.22 | 2,120.2% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −73,655.2% | +17.1% | 33 | 58% | 0.44 | 3,020.5% | 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 (Length 100, ATR Length 7) made 0.0% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 0% of the 64 combinations made money in-sample and 0% out-of-sample.
| ATR Length ↓ · Length → | 100 | 120 | 140 | 170 | 200 | 240 | 280 | 340 |
|---|---|---|---|---|---|---|---|---|
| 7 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 8 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 10 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 12 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 14 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 17 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 20 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 24 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| ATR Length ↓ · Length → | 100 | 120 | 140 | 170 | 200 | 240 | 280 | 340 |
|---|---|---|---|---|---|---|---|---|
| 7 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 8 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 10 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 12 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 14 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 17 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 20 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 24 | 0% | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
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.
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 |
|---|---|---|---|---|---|
| Koala System EURUSD 15min this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| ATR with EOM and VORTEX by SoftKill21 | atr ema sma | v4 strategy | +66.2% | 22 | 29.9% |
| cATRpillar Strategy by Obi-wanClintobe | atr sma ema | v4 strategy | +1.02827e+24% | 27 | 88,097.2% |
| Optimized Zhaocaijinbao strategy by fzj20020403 | sma ema atr | v5 strategy | +15.6% | 12 | 9.8% |
| EMA & Supertrend by bhavikmota | ema sma atr | v4 strategy | +2,123.6% | 13 | 980.9% |
| Buy&Sell Bullish Engulfing - The Quant Science by thequantscience | sma ema atr | v5 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | With a workaround 1,000 bars in 80 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 90, 93) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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/// © SoftKill21//@version=4strategy("Koala Script",initial_capital=1000, commission_type=strategy.commission.cash_per_contract, commission_value=0.000065, slippage=3)fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31)fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12)fromYear = input(defval = 2000, title = "From Year", minval = 1970) // To Date InputstoDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31)toMonth = input(defval = 8, title = "To Month", minval = 1, maxval = 12)toYear = input(defval = 2021, title = "To Year", minval = 1970) startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)len = input(3, minval=1, title="Length")src = input(hl2, title="Source")smma = 0.0sma1 = sma(src, len)smma := na(smma[1]) ? sma1 : (smma[1] * (len - 1) + src) / lenlen2 = input(6, minval=1, title="Length")src2 = input(hl2, title="Source")smma2 = 0.0sma2 = sma(src2, len2)smma2 := na(smma2[1]) ? sma2 : (smma2[1] * (len2 - 1) + src2) / len2len3 = input(9, minval=1, title="Length")src3 = input(hl2, title="Source")smma3 = 0.0sma3 = sma(src3, len3)smma3 := na(smma3[1]) ? sma3 : (smma3[1] * (len3 - 1) + src3) / len3len4 = input(50, minval=1, title="Length")src4 = input(close, title="Source")smma4 = 0.0sma4 = sma(src4, len4)smma4 := na(smma4[1]) ? sma4 : (smma4[1] * (len4 - 1) + src4) / len4len5 = input(200, minval=1, title="Length")src5 = input(close, title="Source")out5 = ema(src5, len5)timeinrange(res, sess) => time(res, sess) != 0london=timeinrange(timeframe.period, "0300-1045")londonEntry=timeinrange(timeframe.period, "0300-0845")time_cond = time >= startDate and time <= finishDate and londonEntryfast_length = input(title="Fast Length", type=input.integer, defval=12)slow_length = input(title="Slow Length", type=input.integer, defval=26)srcc = input(title="Source", type=input.source, defval=close)signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=false)sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)// Calculatingfast_ma = sma_source ? sma(srcc, fast_length) : ema(srcc, fast_length)slow_ma = sma_source ? sma(srcc, slow_length) : ema(srcc, slow_length)macd = fast_ma - slow_masignal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)hist = macd - signallongCond = close > out5 and close > smma4 and close > smma3 and close > smma2 and close > smma and londonEntry and smma > smma2 and smma2>smma3 and smma3>smma4 and smma4>out5 shortCond = close < out5 and close < smma4 and close < smma3 and close < smma2 and close < smma and londonEntry and smma < smma2 and smma2<smma3 and smma3<smma4 and smma4<out5 //longCond2 = crossover(close,out5) and crossover(close,smma4) and crossover(close,smma3) and crossover(close,smma2) and crossover(close,smma) and time_cond//shortCond2 = crossunder(close,out5) and crossunder(close,smma4) and crossunder(close,smma3) and crossunder(close,smma2) and crossunder(close,smma) and time_condlength=input(14, title="ATR Length")mult=input(1.0, title="Percentage Multiplier (for ex., 0.7 = 70%)", step=0.1, minval=0.1, maxval=5.0)oa=input(false, title="Show actual ATR")ii=syminfo.pointvalue==0s=ii?na:oa?atr(length):(syminfo.pointvalue * mult * atr(length))tp=input(300,title="tp")sl=input(300,title="sl")//tp = s*10000//sl= s*10000//if(tp>300)// tp:=300//if(sl>300)// sl:=300//if(sl<150)// sl:=150//if(tp<150)// tp:=150//MONEY MANAGEMENT--------------------------------------------------------------balance = strategy.netprofit + strategy.initial_capital //current balancefloating = strategy.openprofit //floating profit/lossrisk = input(3,type=input.float,title="Risk %")/100 //risk % per trade //Calculate the size of the next tradetemp01 = balance * risk //Risk in USDtemp02 = temp01/sl //Risk in lotstemp03 = temp02*100000 //Convert to contractssize = temp03 - temp03%1000 //Normalize to 1000s (Trade size)if(size < 10000) size := 10000 //Set min. lot sizestrategy.entry("long",1,size,when=longCond )strategy.exit("closelong","long", profit=tp,loss=sl)//strategy.close("long",when= crossunder(close[4],smma4) and close[4] > close[3] and close[3]>close[2] and close[2] > close[1] and close[1] > close)strategy.entry("short",0,size,when=shortCond )strategy.exit("closeshort","short", profit=tp,loss=sl)//strategy.close("short",when= crossover(close[4],smma4) and close[4] < close[3] and close[3]< close[2] and close[2] < close[1] and close[1] < close)strategy.close_all(when = not london)maxEntry=input(2,title="max entries")strategy.risk.max_intraday_filled_orders(maxEntry)