Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (29)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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.
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

Differs

Trades 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

Verified

Same 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.

SettingDefaultType and rangeFeeds
From Day1int · min 1 · max 31startDate
From Month1int · min 1 · max 12startDate
From Year2000int · min 1970startDate
To Day1int · min 1 · max 31finishDate
To Month8int · min 1 · max 12finishDate
To Year2021int · min 1970finishDate
Length3int · min 1smma sma1
Sourcehl2sourcesmma sma1
Length6int · min 1smma2 sma2
Sourcehl2sourcesmma2 sma2
Length9int · min 1smma3 sma3
Sourcehl2sourcesmma3 sma3
Length50int · min 1smma4 sma4
Sourceclosesourcesmma4 sma4
Length200int · min 1out5
Sourceclosesourceout5
Fast Length12int (written input.integer)fast_ma
Slow Length26int (written input.integer)slow_ma
Sourceclosesourcefast_ma slow_ma
Signal Smoothing9int (written input.integer) · min 1 · max 50signal
Simple MA(Oscillator)falseboolfast_ma slow_ma
Simple MA(Signal Line)falseboolsignal
ATR Length14ints
Percentage Multiplier (for ex., 0.7 = 70%)1.0float · min 0.1 · max 5.0 · step 0.1s
Show actual ATRfalsebools
tp300intexit closelong exit closeshort
sl300inttemp02 exit closelong exit closeshort
Risk %3floattemp01
max entries2intline 98

What it calculates

  • SMA (sma, ta.sma in v5)Source (hl2), Length (3)sma1 · line 22
  • SMA (sma, ta.sma in v5)Source (hl2), Length (6)sma2 · line 27
  • SMA (sma, ta.sma in v5)Source (hl2), Length (9)sma3 · line 32
  • SMA (sma, ta.sma in v5)Source (close), Length (50)sma4 · line 37
  • EMA (ema, ta.ema in v5)Source (close), Length (200)out5 · line 41
  • SMA / EMA (sma, ta.sma in v5)Source (close), Fast Length (12)fast_ma · line 53
  • SMA / EMA (sma, ta.sma in v5)Source (close), Slow Length (26)slow_ma · line 54
  • SMA / EMA (sma, ta.sma in v5)macd, Signal Smoothing (9)signal · line 56
  • ATR (atr, ta.atr in 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.

hl2hl2price datalenLengthsetting · 3len2Lengthsetting · 6len3Lengthsetting · 9closecloseprice datalen4Lengthsetting · 50len5Lengthsetting · 200fast_lengthFast Lengthsetting · 12slow_lengthSlow Lengthsetting · 26signal_lengthSignal Smoothingsetting · 9high · low · closehigh · low · closeprice datalengthATR Lengthsetting · 14multPercentage Multiplier (…setting · 1.0fromYearFrom Yearsetting · 2000fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1toYearTo Yearsetting · 2021toMonthTo Monthsetting · 8toDayTo Daysetting · 1riskRisk %setting · 3slslsetting · 300timetimeprice datasma1SMA→ sma1sma2SMA→ sma2sma3SMA→ sma3sma4SMA→ sma4out5EMA→ out5fast_maSMA / EMA→ fast_maslow_maSMA / EMA→ slow_masignalSMA / EMA→ signalsATR→ sstartDatestartDatevaluefinishDatefinishDatevaluesmmasmmavaluesmma2smma2valuesmma3smma3valuesmma4smma4valuelondon, londonEntry, balance, floatinglondon · londonEntry +24 valuesmacdmacdvaluehisthistvaluetemp01temp01valuetemp02temp02valuetemp03temp03valuesizesizevaluelongCondlongCondconditionshortCondshortCondconditiontime_condtime_condconditioniiiiconditionentry:longOpen longstrategy.entryexit:closelongexit closelongstrategy.exitentry:shortOpen shortstrategy.entryexit:closeshortexit closeshortstrategy.exitclose_all:close_all strategy.close_all

Order rules

OrderFires whenBy defaultLine
Open long longlongCondclose > 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>out5On90
Exit closelong stop and limitevery barOn91
Open short shortshortCondclose < 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<out5On93
Exit closeshort stop and limitevery barOn94
Close not londonOn96

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−15,453.3%+5.5%2540%0.6621,453.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+81,742.5%+8.4%3253%2.8018,422.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−800,074.0%+21.5%2348%0.222,120.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−73,655.2%+17.1%3358%0.443,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.

Before 26 Dec 2025 · in-sample
ATR Length ↓ · Length →100120140170200240280340
70%0%0%0%0%0%0%0%
80%0%0%0%0%0%0%0%
100%0%0%0%0%0%0%0%
120%0%0%0%0%0%0%0%
140%0%0%0%0%0%0%0%
170%0%0%0%0%0%0%0%
200%0%0%0%0%0%0%0%
240%0%0%0%0%0%0%0%
From 26 Dec 2025 · out-of-sample
ATR Length ↓ · Length →100120140170200240280340
70%0%0%0%0%0%0%0%
80%0%0%0%0%0%0%0%
100%0%0%0%0%0%0%0%
120%0%0%0%0%0%0%0%
140%0%0%0%0%0%0%0%
170%0%0%0%0%0%0%0%
200%0%0%0%0%0%0%0%
240%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.

ScriptSharesTypeNetTradesMax drawdown
Koala System EURUSD 15min this page—v4 strategy0.0%00.0%
ATR with EOM and VORTEX by SoftKill21atr ema smav4 strategy+66.2%2229.9%
cATRpillar Strategy by Obi-wanClintobeatr sma emav4 strategy+1.02827e+24%2788,097.2%
Optimized Zhaocaijinbao strategy by fzj20020403sma ema atrv5 strategy+15.6%129.8%
EMA & Supertrend by bhavikmotaema sma atrv4 strategy+2,123.6%13980.9%
Buy&Sell Bullish Engulfing - The Quant Science by thequantsciencesma ema atrv5 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msWith a workaround 1,000 bars in 80 msNot measured
PineTSNo 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)