Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Forex Fractal EMA Scalper

A Pine Script v5 strategy built on EMA (hl2, 10). It has 4 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 no commission. 7 settings; defaults include Period Fractals 2, Source for EMA's hl2 and Length EMA 1 10.

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 Forex Fractal EMA Scalper repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 34 of 34 trades.
How did Forex Fractal EMA Scalper do on BTCUSDT 1D with default settings?
−0.00%
From 26 Jan 2024 to 21 Oct 2026, over 97 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Forex Fractal EMA Scalper 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: 97 before, 70 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Forex Fractal EMA Scalper use a stop loss?
Yes
strategy.exit sets a stop on line 54, 55.
Does Forex Fractal EMA Scalper run in Zeal Terminal?
Yes
It compiles in 27 ms and runs 1,000 bars in 83 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • EMA
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$999,973$2,025,273Equity from $1,000,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.
Net profit
−0.00%
−$27.50
Buy and hold
+102.5%
same period
Closed trades
97
43 won · 54 lost
Profitable
44.3%
of closed trades
Profit factor
0.80
gross profit ÷ gross loss
Max drawdown
0.00%
−$30.00

One run with the author's default settings, $1,000,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.

  • 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 50, 51. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Optimization Parameters
Period Fractals2int · min 2upflagDownFrontier upflagUpFrontier0 upflagUpFrontier1 upflagUpFrontier2 upflagUpFrontier3 upflagUpFrontier4 downflagDownFrontier downflagUpFrontier0 downflagUpFrontier1 downflagUpFrontier2 downflagUpFrontier3 downflagUpFrontier4 line 21 line 37
Source for EMA'shl2sourceout1 out2 out3
Length EMA 110int · min 1out1
Length EMA 220int · min 1out2
Length EMA 3100int · min 1out3
Risk Management
TP in PIPS25intexit X_long exit x_short
SL in PIPS25intexit X_long exit x_short

What it calculates

  • EMASource for EMA's (hl2), Length EMA 1 (10)out1 · line 9
  • EMASource for EMA's (hl2), Length EMA 2 (20)out2 · line 11
  • EMASource for EMA's (hl2), Length EMA 3 (100)out3 · line 13

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 datalen1Length EMA 1setting · 10len2Length EMA 2setting · 20len3Length EMA 3setting · 100highhighprice datanPeriod Fractalssetting · 2lowlowprice dataout1EMA→ out1out2EMA→ out2out3EMA→ out3longlongconditionshortshortconditionupflagDownFrontierupflagDownFrontierconditionupflagUpFrontier0upflagUpFrontier0conditionupflagUpFrontier1upflagUpFrontier1conditionupflagUpFrontier2upflagUpFrontier2conditionupflagUpFrontier3upflagUpFrontier3conditionupflagUpFrontier4upflagUpFrontier4conditionflagUpFrontierflagUpFrontierconditionupFractalupFractalconditiondownflagDownFrontierdownflagDownFrontierconditiondownflagUpFrontier0downflagUpFrontier0conditiondownflagUpFrontier1downflagUpFrontier1conditiondownflagUpFrontier2downflagUpFrontier2conditiondownflagUpFrontier3downflagUpFrontier3conditiondownflagUpFrontier4downflagUpFrontier4conditionflagDownFrontierflagDownFrontierconditiondownFractaldownFractalconditionentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:X_longexit X_longstrategy.exitexit:x_shortexit x_shortstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open long longshortout1 < out2 and out2<out3 and downFractalOn50
Open short shortlongout1 > out2 and out2>out3 and upFractalOn51
Exit X_long stop and limitevery barOn54
Exit x_short stop and limitevery barOn55

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.

34/34trades 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−0.0%+102.5%9744%0.800.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%9752%1.060.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%8952%1.070.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%10657%1.300.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%9549%0.980.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%6351%1.030.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%9250%1.000.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%10045%0.820.0%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 EMA 1 12, Length EMA 2 10) made +0.0% before 26 Dec 2025 and +0.0% after it, against −0.0% for the defaults. 9% of the 64 combinations made money in-sample and 31% out-of-sample.

Before 26 Dec 2025 · in-sample
Length EMA 2 ↓ · Length EMA 1 →567910121417
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%
28−0%−0%−0%−0%−0%−0%−0%−0%
34−0%−0%−0%−0%−0%−0%−0%−0%
From 26 Dec 2025 · out-of-sample
Length EMA 2 ↓ · Length EMA 1 →567910121417
10+0%+0%+0%+0%0%+0%+0%+0%
12+0%+0%+0%+0%+0%0%+0%+0%
140%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%
28−0%−0%−0%−0%−0%−0%−0%−0%
34−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.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market2938%−$17.50
Sideways market4149%−$2.50
Falling market2744%−$7.50

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

How bad could the drawdown be?

0.0%

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

0%1%
All 97 trades
SideEntryExitBarsP&L
short24 May 2024 67,969.7024 May 2024 67,972.200−$2.50
short30 May 2024 67,652.4030 May 2024 67,649.900$2.50
short10 Jun 2024 69,648.1010 Jun 2024 69,645.600$2.50
short13 Jun 2024 68,264.0013 Jun 2024 68,266.500−$2.50
long1 Jul 2024 62,772.001 Jul 2024 62,769.500−$2.50
long8 Jul 2024 55,857.808 Jul 2024 55,855.300−$2.50
long11 Jul 2024 57,725.8011 Jul 2024 57,723.300−$2.50
long15 Jul 2024 60,797.9015 Jul 2024 60,795.400−$2.50
short25 Jul 2024 65,376.0025 Jul 2024 65,378.500−$2.50
short1 Aug 2024 64,628.001 Aug 2024 64,630.500−$2.50
long8 Aug 2024 55,133.808 Aug 2024 55,131.300−$2.50
long15 Aug 2024 58,683.4015 Aug 2024 58,685.900$2.50
long18 Aug 2024 59,492.0018 Aug 2024 59,494.500$2.50
long22 Aug 2024 61,156.0022 Aug 2024 61,158.500$2.50
long9 Sep 2024 54,869.909 Sep 2024 54,867.400−$2.50
short30 Sep 2024 65,602.0030 Sep 2024 65,604.500−$2.50
short10 Oct 2024 60,636.0010 Oct 2024 60,638.500−$2.50
short24 Oct 2024 66,668.6024 Oct 2024 66,666.100$2.50
short27 Oct 2024 67,092.8027 Oct 2024 67,090.300$2.50
short1 Nov 2024 70,292.001 Nov 2024 70,294.500−$2.50
short16 Nov 2024 91,032.1016 Nov 2024 91,034.600−$2.50
short25 Nov 2024 97,900.1025 Nov 2024 97,902.600−$2.50
short2 Dec 2024 97,185.202 Dec 2024 97,187.700−$2.50
short8 Dec 2024 99,832.008 Dec 2024 99,829.500$2.50
short20 Dec 2024 97,461.9020 Dec 2024 97,464.400−$2.50
short23 Jan 2025 103,707.0023 Jan 2025 103,704.000$2.50
short27 Jan 2025 102,620.0027 Jan 2025 102,623.000−$2.50
short2 Feb 2025 100,636.002 Feb 2025 100,638.000−$2.50
long3 Mar 2025 94,270.003 Mar 2025 94,272.500$2.50
long7 Mar 2025 89,931.907 Mar 2025 89,934.400$2.50
long14 Mar 2025 81,115.8014 Mar 2025 81,113.300−$2.50
long21 Mar 2025 84,223.4021 Mar 2025 84,225.900$2.50
long3 Apr 2025 82,516.303 Apr 2025 82,513.800−$2.50
long6 Apr 2025 83,538.006 Apr 2025 83,540.500$2.50
long10 Apr 2025 82,615.2010 Apr 2025 82,617.700$2.50
short28 Apr 2025 93,749.3028 Apr 2025 93,746.800$2.50
short1 May 2025 94,172.001 May 2025 94,169.500$2.50
short5 May 2025 94,277.605 May 2025 94,275.100$2.50
short15 May 2025 103,508.0015 May 2025 103,510.000−$2.50
short25 May 2025 107,762.0025 May 2025 107,759.000$2.50
short30 May 2025 105,590.0030 May 2025 105,592.000−$2.50
short6 Jun 2025 101,509.006 Jun 2025 101,506.000$2.50
short12 Jun 2025 108,645.0012 Jun 2025 108,648.000−$2.50
short19 Jun 2025 104,887.0019 Jun 2025 104,889.000−$2.50
short29 Jun 2025 107,297.0029 Jun 2025 107,294.000$2.50
short6 Jul 2025 108,198.006 Jul 2025 108,196.000$2.50
short17 Jul 2025 118,630.0017 Jul 2025 118,628.000$2.50
short20 Jul 2025 117,840.0020 Jul 2025 117,843.000−$2.50
short25 Jul 2025 118,341.0025 Jul 2025 118,343.000−$2.50
short31 Jul 2025 117,840.0031 Jul 2025 117,843.000−$2.50
short17 Aug 2025 117,381.0017 Aug 2025 117,378.000$2.50
short15 Sep 2025 115,268.0015 Sep 2025 115,266.000$2.50
short21 Sep 2025 115,686.0021 Sep 2025 115,688.000−$2.50
short9 Oct 2025 123,306.009 Oct 2025 123,309.000−$2.50
long25 Oct 2025 111,005.0025 Oct 2025 111,002.000−$2.50
long2 Nov 2025 110,098.002 Nov 2025 110,096.000−$2.50
long7 Nov 2025 101,346.007 Nov 2025 101,344.000−$2.50
long24 Nov 2025 86,830.0024 Nov 2025 86,827.500−$2.50
long4 Dec 2025 93,429.904 Dec 2025 93,432.400$2.50
long10 Dec 2025 92,678.8010 Dec 2025 92,676.300−$2.50
long14 Dec 2025 90,240.0014 Dec 2025 90,242.500$2.50
long18 Dec 2025 86,243.2018 Dec 2025 86,240.700−$2.50
long21 Dec 2025 88,360.9021 Dec 2025 88,363.400$2.50
long27 Dec 2025 87,369.6027 Dec 2025 87,367.100−$2.50
long1 Jan 2026 87,648.201 Jan 2026 87,645.700−$2.50
long24 Jan 2026 89,600.3024 Jan 2026 89,602.800$2.50
long28 Jan 2026 89,250.0028 Jan 2026 89,247.500−$2.50
long9 Feb 2026 70,330.409 Feb 2026 70,332.900$2.50
long15 Feb 2026 69,822.9015 Feb 2026 69,825.400$2.50
long22 Feb 2026 67,975.9022 Feb 2026 67,978.400$2.50
long27 Feb 2026 67,485.2027 Feb 2026 67,487.700$2.50
long3 Mar 2026 68,830.103 Mar 2026 68,832.600$2.50
long11 Mar 2026 69,948.6011 Mar 2026 69,946.100−$2.50
long1 Apr 2026 68,284.501 Apr 2026 68,282.000−$2.50
long5 Apr 2026 67,300.405 Apr 2026 67,297.900−$2.50
short9 May 2026 80,193.209 May 2026 80,190.700$2.50
short13 May 2026 80,504.5013 May 2026 80,507.000−$2.50
short17 May 2026 78,148.1017 May 2026 78,150.600−$2.50
long1 Jun 2026 73,674.401 Jun 2026 73,676.900$2.50
long8 Jun 2026 63,332.008 Jun 2026 63,334.500$2.50
long13 Jun 2026 63,580.0013 Jun 2026 63,577.500−$2.50
long21 Jun 2026 64,298.0021 Jun 2026 64,300.500$2.50
long28 Jun 2026 60,029.0028 Jun 2026 60,031.500$2.50
long4 Jul 2026 62,583.304 Jul 2026 62,580.800−$2.50
long9 Jul 2026 62,290.009 Jul 2026 62,287.500−$2.50
long4 Aug 2026 63,520.004 Aug 2026 63,517.500−$2.50
long17 Aug 2026 62,900.0017 Aug 2026 62,897.500−$2.50
short24 Aug 2026 77,734.0024 Aug 2026 77,731.500$2.50
short28 Aug 2026 80,249.6028 Aug 2026 80,252.100−$2.50
short31 Aug 2026 77,682.0031 Aug 2026 77,679.500$2.50
short6 Sep 2026 79,831.806 Sep 2026 79,829.300$2.50
short14 Sep 2026 76,842.0014 Sep 2026 76,839.500$2.50
short17 Sep 2026 76,206.0017 Sep 2026 76,203.500$2.50
short24 Sep 2026 84,397.6024 Sep 2026 84,400.100−$2.50
short5 Oct 2026 86,530.005 Oct 2026 86,532.500−$2.50
short8 Oct 2026 83,321.808 Oct 2026 83,324.300−$2.50
short15 Oct 2026 81,682.0015 Oct 2026 81,684.500−$2.50

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
Forex Fractal EMA Scalper this page—v5 strategy−0.0%970.0%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 2 strategy calls use the when = argument (line 50, 51). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 3 settings use the untyped input() (line 7, 52, 53). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 7: input() → input.source()
  • Line 50: when = short → if block
  • Line 51: when = long → if block
  • Line 52: input() → input.int()
  • Line 53: input() → input.int()
⋯n = input.int(title="Period Fractals", defval=2, minval=2, group="Optimization Parameters")-src = input(hl2, title="Source for EMA's", group="Optimization Parameters")+src = input.source(hl2, title="Source for EMA's", group="Optimization Parameters")len1 = input.int(10, minval=1, title="Length EMA 1", group="Optimization Parameters")⋯short= out1 < out2 and out2<out3 and downFractal-strategy.entry("long",strategy.long,when= short)+if short+    strategy.entry("long",strategy.long)-strategy.entry("short",strategy.short,when=long)+if long+    strategy.entry("short",strategy.short)-tp=input(25, title="TP in PIPS", group="Risk Management")*10+tp=input.int(25, title="TP in PIPS", group="Risk Management")*10-sl=input(25, title="SL in PIPS", group="Risk Management")*10+sl=input.int(25, title="SL in PIPS", group="Risk Management")*10strategy.exit("X_long", "long", profit=tp,  loss=sl  )⋯

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: 97 before, 70 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.

⋯// © exlux99-//@version=5+//@version=6strategy("Forex Fractal EMA Scalper", overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 27 msYes 1,000 bars in 83 msNot measured
PineTSNot testedNot testedNot measured

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

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/// © exlux99//@version=5strategy("Forex Fractal EMA Scalper", overlay=true)// Define "n" as the number of periods and keep a minimum value of 2 for error handling.n = input.int(title="Period Fractals", defval=2, minval=2, group="Optimization Parameters")src = input(hl2, title="Source for EMA's", group="Optimization Parameters")len1 = input.int(10, minval=1, title="Length EMA 1", group="Optimization Parameters")out1 = ta.ema(src, len1)len2 = input.int(20, minval=1, title="Length EMA 2", group="Optimization Parameters")out2 = ta.ema(src, len2)len3 = input.int(100, minval=1, title="Length EMA 3", group="Optimization Parameters")out3 = ta.ema(src, len3)// UpFractalbool upflagDownFrontier = truebool upflagUpFrontier0 = truebool upflagUpFrontier1 = truebool upflagUpFrontier2 = truebool upflagUpFrontier3 = truebool upflagUpFrontier4 = truefor i = 1 to n    upflagDownFrontier := upflagDownFrontier and (high[n-i] < high[n])    upflagUpFrontier0 := upflagUpFrontier0 and (high[n+i] < high[n])    upflagUpFrontier1 := upflagUpFrontier1 and (high[n+1] <= high[n] and high[n+i + 1] < high[n])    upflagUpFrontier2 := upflagUpFrontier2 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+i + 2] < high[n])    upflagUpFrontier3 := upflagUpFrontier3 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+i + 3] < high[n])    upflagUpFrontier4 := upflagUpFrontier4 and (high[n+1] <= high[n] and high[n+2] <= high[n] and high[n+3] <= high[n] and high[n+4] <= high[n] and high[n+i + 4] < high[n])flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4upFractal = (upflagDownFrontier and flagUpFrontier)// downFractalbool downflagDownFrontier = truebool downflagUpFrontier0 = truebool downflagUpFrontier1 = truebool downflagUpFrontier2 = truebool downflagUpFrontier3 = truebool downflagUpFrontier4 = truefor i = 1 to n    downflagDownFrontier := downflagDownFrontier and (low[n-i] > low[n])    downflagUpFrontier0 := downflagUpFrontier0 and (low[n+i] > low[n])    downflagUpFrontier1 := downflagUpFrontier1 and (low[n+1] >= low[n] and low[n+i + 1] > low[n])    downflagUpFrontier2 := downflagUpFrontier2 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+i + 2] > low[n])    downflagUpFrontier3 := downflagUpFrontier3 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+i + 3] > low[n])    downflagUpFrontier4 := downflagUpFrontier4 and (low[n+1] >= low[n] and low[n+2] >= low[n] and low[n+3] >= low[n] and low[n+4] >= low[n] and low[n+i + 4] > low[n])flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4downFractal = (downflagDownFrontier and flagDownFrontier)// plotshape(downFractal, style=shape.triangledown, location=location.belowbar, offset=-n, color=#F44336, size = size.small)// plotshape(upFractal, style=shape.triangleup,   location=location.abovebar, offset=-n, color=#009688, size = size.small)long= out1 > out2 and out2>out3 and upFractalshort= out1 < out2 and out2<out3 and downFractalstrategy.entry("long",strategy.long,when= short)strategy.entry("short",strategy.short,when=long)tp=input(25, title="TP in PIPS", group="Risk Management")*10sl=input(25, title="SL in PIPS", group="Risk Management")*10strategy.exit("X_long", "long", profit=tp,  loss=sl  )strategy.exit("x_short", "short",profit=tp, loss=sl  )