Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Coin Flipper Pro with strategy tester

A Pine Script v4 strategy with no technical-analysis calculation. It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 16 settings; defaults include Max Bars between Coin Filps 25.0, Risk in % 5.0 and Risk to Reward Ratio x:1 1.5.

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 Coin Flipper Pro with strategy tester repaint?
No
No repainting patterns were found in the source. The live replay was not measured: the script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script.
How did Coin Flipper Pro with strategy tester do on BTCUSDT 1D with default settings?
−23.07%
From 26 Jan 2024 to 21 Oct 2026, over 57 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Coin Flipper Pro with strategy tester 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 Coin Flipper Pro with strategy tester use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Coin Flipper Pro with strategy tester run in Zeal Terminal?
Yes
It compiles in 28 ms and runs 1,000 bars in 71 ms, in the browser.

BTCUSDT · 1D · default settings

  • short label
  • short label
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$76,930$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. The live re-run is not offered here: the browser bundle did not reproduce the prerendered run.
Net profit
−23.07%
−$23,072.50
Buy and hold
+102.5%
same period
Closed trades
57
23 won · 34 lost
Profitable
40.4%
of closed trades
Profit factor
0.83
gross profit ÷ gross loss
Max drawdown
52.39%
−$64,666.30

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

    4 settings do nothing

    “------- Trade Activity -------”, “------- Position Settings -------”, “------- Plot Options -------”, “------- Back Testing -------” are declared but never read.

  • 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 96, 97, 98, 99. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 82

    transp = on line 82, 83, 84. v5 folds the transparency into the colour with color.new(c, transp).

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 round → math.round, random → math.random, barssince → ta.barssince.
  • 4 strategy calls use the when = argument (line 96, 97, 98, 99). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

Trades differ: 53 before, 53 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 9: input(type = input.float) → input.float()
  • Line 10: input(type = input.float) → input.float()
  • Line 41: round → math.round
  • Line 41: random → math.random
  • Line 43: barssince → ta.barssince
7 more edits
  • Line 45: random → math.random
  • Line 52: round → math.round
  • Line 52: random → math.random
  • Line 52: round → math.round
  • Line 82: transp = 100 → color.new(color.white, 100)
  • Line 83: transp = 100 → color.new(color.white, 100)
  • Line 84: transp = 100 → color.new(color.white, 100)
⋯// © melodicfish-//@version=4+//@version=5strategy("Coin Flipper Pro",overlay=true,max_bars_back=100)⋯h2=input(title="------- Position Settings -------",defval=false)-risk=input(defval=5.0,title="Risk in % ",type=input.float, minval=0.001 ,step=0.1)+risk=input.float(defval=5.0,title="Risk in % ", minval=0.001 ,step=0.1)-ratio= input(defval=1.5,title="Risk to Reward Ratio x:1 ",type=input.float, minval=0.001,step=0.1)+ratio= input.float(defval=1.5,title="Risk to Reward Ratio x:1 ", minval=0.001,step=0.1)h3=input(title="------- Plot Options -------",defval=false)⋯getColor() => -    round(random(1,255))+    math.round(math.random(1,255))// ===== Logic ========-if barssince(flip==true)>barsBetweenflips and posLive==false+if ta.barssince(flip==true)>barsBetweenflips and posLive==false    flip:=true-    coinLabel:=random(1,10)+    coinLabel:=math.random(1,10)    // Candle Colors   ⋯    flip:=false-    barsBetweenflips:=round(random(3,round(maxBars)))+    barsBetweenflips:=math.round(math.random(3,math.round(maxBars)))    posLive:=true⋯// ====== Plots ========-plot1=plot(plotBox and showBox? p1:na,style=plot.style_linebr,color=color.white, transp= 100)+plot1=plot(plotBox and showBox? p1:na,style=plot.style_linebr,color=color.new(color.white, 100))-plot2=plot(plotBox and showBox? p2:na,style=plot.style_linebr,color=color.white, transp= 100)+plot2=plot(plotBox and showBox? p2:na,style=plot.style_linebr,color=color.new(color.white, 100))-plot3=plot(plotBox and showBox? p3:na,style=plot.style_linebr,color=color.white, transp= 100)+plot3=plot(plotBox and showBox? p3:na,style=plot.style_linebr,color=color.new(color.white, 100))fill(plot1,plot2,color= color.green)⋯

Clean v5

Differs

Trades differ: 53 before, 55 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.bool()
  • Line 7: input() → input.float()
  • Line 8: input() → input.bool()
  • Line 11: input() → input.bool()
  • Line 12: input() → input.bool()
  • Line 13: input() → input.bool()
12 more edits
  • Line 14: input() → input.bool()
  • Line 15: input() → input.bool()
  • Line 16: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 20: input() → input.int()
  • Line 21: input() → input.int()
  • Line 22: input() → input.int()
  • Line 96: when = short==true → if block
  • Line 97: when = stoppedOut==true or takeProfit==true → if block
  • Line 98: when = long==true → if block
  • Line 99: when = stoppedOut==true or takeProfit==true → if block
⋯// ======= User Inputs variables=========-h1=input(title="------- Trade Activity -------",defval=false)+h1=input.bool(title="------- Trade Activity -------",defval=false)-maxBars=input(25.0,title="Max Bars between Coin Filps",step=1.0,minval=4.0)+maxBars=input.float(25.0,title="Max Bars between Coin Filps",step=1.0,minval=4.0)-h2=input(title="------- Position Settings -------",defval=false)+h2=input.bool(title="------- Position Settings -------",defval=false)risk=input.float(defval=5.0,title="Risk in % ", minval=0.001 ,step=0.1)ratio= input.float(defval=1.5,title="Risk to Reward Ratio x:1 ", minval=0.001,step=0.1)-h3=input(title="------- Plot Options -------",defval=false)+h3=input.bool(title="------- Plot Options -------",defval=false)-showBox=input(defval=true, title="Show Position Boxes")+showBox=input.bool(defval=true, title="Show Position Boxes")-h4=input(title="------- Back Testing -------",defval=false)+h4=input.bool(title="------- Back Testing -------",defval=false)-runTest=input(defval=true, title="Run Strategy Back Test")+runTest=input.bool(defval=true, title="Run Strategy Back Test")-customTime=input(defval=false, title="Use Custom Date Range for back test")+customTime=input.bool(defval=false, title="Use Custom Date Range for back test")-tsYear = input(2021,minval=1000,maxval=9999,title= "Test Start Year")+tsYear = input.int(2021,minval=1000,maxval=9999,title= "Test Start Year")-tsMonth = input(1,minval=1,maxval=12,title= "Test Start Month")+tsMonth = input.int(1,minval=1,maxval=12,title= "Test Start Month")-tsDay = input(1,minval=1,maxval=31,title= "Test Start Day")+tsDay = input.int(1,minval=1,maxval=31,title= "Test Start Day")start = timestamp(tsYear,tsMonth,tsDay,0,0)-teYear = input(2021,minval=1000,maxval=9999,title=  "Test Stop Year")+teYear = input.int(2021,minval=1000,maxval=9999,title=  "Test Stop Year")-teMonth = input(5,minval=1,maxval=12,title=  "Test Stop Month")+teMonth = input.int(5,minval=1,maxval=12,title=  "Test Stop Month")-teDay = input(1,minval=1,maxval=31,title=  "Test Stop Day")+teDay = input.int(1,minval=1,maxval=31,title=  "Test Stop Day")end = timestamp(teYear,teMonth,teDay,0,0)⋯if runTest==true and customTime==false or runTest==true and customTime==true and time >= start and time <= end -    strategy.entry("Sell", strategy.short,when=short==true)+    if short==true+        strategy.entry("Sell", strategy.short)-    strategy.close("Sell", comment="Close Short", when=stoppedOut==true or takeProfit==true)+    if stoppedOut==true or takeProfit==true+        strategy.close("Sell", comment="Close Short")-    strategy.entry("Long", strategy.long,when=long==true)+    if long==true+        strategy.entry("Long", strategy.long)-    strategy.close("Long",comment="Close Long", when= stoppedOut==true or takeProfit==true )+    if stoppedOut==true or takeProfit==true+        strategy.close("Long",comment="Close Long" )

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: 55 before, 49 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.

⋯// © melodicfish-//@version=5+//@version=6strategy("Coin Flipper Pro",overlay=true,max_bars_back=100)⋯

Settings

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

SettingDefaultType and rangeFeeds
------- Trade Activity -------falseboolunused
Max Bars between Coin Filps25.0float · min 4.0 · step 1.0barsBetweenflips
------- Position Settings -------falseboolunused
Risk in % 5.0float · min 0.001 · step 0.1p1 p3 riskLDEC riskSDEC
Risk to Reward Ratio x:1 1.5float · min 0.001 · step 0.1p1 riskSDEC
------- Plot Options -------falseboolunused
Show Position Boxestrueboolplot1 plot2 plot3 plot
------- Back Testing -------falseboolunused
Run Strategy Back Testtrueboolentry Sell close Sell entry Long close Long line 95
Use Custom Date Range for back testfalseboolentry Sell close Sell entry Long close Long line 95
Test Start Year2021int · min 1000 · max 9999start
Test Start Month1int · min 1 · max 12start
Test Start Day1int · min 1 · max 31start
Test Stop Year2021int · min 1000 · max 9999end
Test Stop Month5int · min 1 · max 12end
Test Stop Day1int · min 1 · max 31end

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

tsYearTest Start Yearsetting · 2021tsMonthTest Start Monthsetting · 1tsDayTest Start Daysetting · 1teYearTest Stop Yearsetting · 2021teMonthTest Stop Monthsetting · 5teDayTest Stop Daysetting · 1maxBarsMax Bars between Coin F…setting · 25.0highhighprice datalowlowprice dataclosecloseprice datariskRisk in % setting · 5.0ratioRisk to Reward Ratio x:…setting · 1.5openopenprice datastartstartvalueendendvaluebarsBetweenflipsbarsBetweenflipsvaluestoppedOutstoppedOutvaluetakeProfittakeProfitvaluep1p1valuep2p2valuep3p3valueriskLDECriskLDECvalueriskSDECriskSDECvaluelong, shortlong · short2 conditionscandleColorColourcandleColorentry:SellOpen Sellstrategy.entryclose:SellClose Sellstrategy.closeentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closebarcolor:49barcolorbarcolorplot:82plotplotplot:83plotplotplot:84plotplotfill:85Fillfill × 2fill:86Fillfill × 2plotshape:87short labelplotshapeplotshape:88short labelplotshape

Order rules

OrderFires whenBy defaultLine
Open Sell shortshort==trueOn96
Close SellstoppedOut==true or takeProfit==trueOn97
Open Long longlong==trueOn98
Close LongstoppedOut==true or takeProfit==trueOn99

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 measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • 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−23.1%+102.5%5740%0.8352.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−3.0%+5.5%1331%0.8922.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−2.1%+9.8%6237%0.642.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.4%+8.4%2030%0.670.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%6365%1.900.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%2446%1.040.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.2%+148.3%5941%1.190.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.1%+17.1%1638%0.690.2%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1844%−$2,001.51
Sideways market2642%−$3,408.97
Falling market1331%−$17,662.00

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

How bad could the drawdown be?

53.1%

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

0%61%
All 57 trades
SideEntryExitBarsP&L
short28 Jan 2024 42,120.608 Feb 2024 44,349.6011−$2,228.97
long19 Feb 2024 52,137.7028 Feb 2024 57,037.309$4,899.67
long5 Mar 2024 68,245.706 Mar 2024 63,724.001−$4,521.70
long16 Mar 2024 69,499.8017 Mar 2024 65,300.601−$4,199.20
long24 Mar 2024 63,990.0026 Mar 2024 69,880.002$5,889.98
long19 Apr 2024 63,470.1023 Apr 2024 66,819.304$3,349.23
short12 May 2024 60,826.0016 May 2024 66,206.504−$5,380.52
short7 Jun 2024 70,799.1015 Jun 2024 66,044.008$4,755.07
long17 Jun 2024 66,676.9025 Jun 2024 60,293.308−$6,383.56
long4 Jul 2024 60,208.605 Jul 2024 57,050.001−$3,158.55
long18 Jul 2024 64,088.0030 Jul 2024 66,784.7012$2,696.69
short2 Aug 2024 65,354.005 Aug 2024 58,161.003$7,193.02
short12 Aug 2024 58,712.6016 Aug 2024 57,541.104$1,171.54
short29 Aug 2024 59,034.907 Sep 2024 53,963.009$5,071.93
short20 Sep 2024 62,948.0027 Sep 2024 65,174.007−$2,225.99
short13 Oct 2024 63,206.2015 Oct 2024 66,084.002−$2,877.77
long7 Nov 2024 75,572.008 Nov 2024 75,857.901$285.90
long15 Nov 2024 87,325.6022 Nov 2024 98,317.107$10,991.50
short7 Dec 2024 99,740.8012 Dec 2024 101,125.005−$1,384.16
short27 Dec 2024 95,791.6031 Dec 2024 92,792.104$2,999.55
short2 Jan 2025 94,591.804 Jan 2025 98,174.202−$3,582.39
short19 Jan 2025 104,556.0021 Jan 2025 102,260.002$2,296.23
short9 Feb 2025 96,444.8026 Feb 2025 88,680.4017$7,764.36
short2 Mar 2025 86,064.503 Mar 2025 94,270.001−$8,205.45
short18 Mar 2025 84,010.0020 Mar 2025 86,845.902−$2,835.91
long1 Apr 2025 82,550.007 Apr 2025 78,430.006−$4,120.00
long10 Apr 2025 82,615.2011 Apr 2025 79,607.301−$3,007.92
long27 Apr 2025 94,628.009 May 2025 103,262.0012$8,633.61
long18 May 2025 103,127.0023 May 2025 111,696.005$8,569.57
long27 May 2025 109,435.001 Jun 2025 104,592.005−$4,842.90
long3 Jun 2025 105,858.0023 Jun 2025 100,964.0020−$4,894.13
short27 Jun 2025 106,947.0011 Jul 2025 116,010.0014−$9,062.95
long21 Jul 2025 117,265.004 Aug 2025 114,209.0014−$3,056.30
short6 Aug 2025 114,130.0012 Aug 2025 118,686.006−$4,556.25
short22 Aug 2025 112,500.003 Oct 2025 120,529.0042−$8,029.35
long5 Oct 2025 122,391.0011 Oct 2025 112,774.006−$9,616.50
long16 Oct 2025 110,763.0018 Oct 2025 106,432.002−$4,331.60
long24 Oct 2025 110,078.0028 Oct 2025 114,108.004$4,029.46
long13 Nov 2025 101,654.0015 Nov 2025 94,594.002−$7,060.37
long28 Nov 2025 91,333.902 Dec 2025 86,286.004−$5,047.93
long11 Dec 2025 92,015.4015 Dec 2025 88,172.204−$3,843.22
short20 Dec 2025 88,136.9023 Dec 2025 88,620.803−$483.84
short6 Jan 2026 93,859.7014 Jan 2026 95,414.008−$1,554.28
short28 Jan 2026 89,250.0031 Jan 2026 84,260.503$4,989.49
short4 Feb 2026 75,770.205 Feb 2026 73,165.801$2,604.37
long26 Feb 2026 67,988.003 Mar 2026 68,830.105$842.02
short14 Mar 2026 70,930.0017 Mar 2026 74,884.703−$3,954.66
long2 Apr 2026 68,113.9011 Apr 2026 72,962.709$4,848.79
long28 Apr 2026 77,371.3024 May 2026 76,752.0026−$619.32
long26 May 2026 77,322.0029 May 2026 73,617.503−$3,704.49
long4 Jun 2026 64,142.805 Jun 2026 63,886.001−$256.76
long20 Jun 2026 63,543.9025 Jun 2026 61,078.005−$2,465.90
long6 Jul 2026 63,650.0020 Aug 2026 69,334.8045$5,684.77
short22 Aug 2026 78,338.0023 Aug 2026 77,074.901$1,263.09
long29 Aug 2026 77,845.9012 Sep 2026 77,225.7014−$620.17
long14 Sep 2026 76,842.0022 Sep 2026 86,620.008$9,778.00
long8 Oct 2026 83,321.809 Oct 2026 81,754.501−$1,567.35

Similar scripts

No other indicator or strategy here shares enough of its calculations.

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 28 msYes 1,000 bars in 71 msNot measured
PineTSNo v5 and v6 only—Not 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. 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/// © melodicfish//@version=4strategy("Coin Flipper Pro",overlay=true,max_bars_back=100)// ======= User Inputs variables=========h1=input(title="------- Trade Activity -------",defval=false)maxBars=input(25.0,title="Max Bars between Coin Filps",step=1.0,minval=4.0)h2=input(title="------- Position Settings -------",defval=false)risk=input(defval=5.0,title="Risk in % ",type=input.float, minval=0.001 ,step=0.1)ratio= input(defval=1.5,title="Risk to Reward Ratio x:1 ",type=input.float, minval=0.001,step=0.1)h3=input(title="------- Plot Options -------",defval=false)showBox=input(defval=true, title="Show Position Boxes")h4=input(title="------- Back Testing -------",defval=false)runTest=input(defval=true, title="Run Strategy Back Test")customTime=input(defval=false, title="Use Custom Date Range for back test")tsYear = input(2021,minval=1000,maxval=9999,title= "Test Start Year")tsMonth = input(1,minval=1,maxval=12,title= "Test Start Month")tsDay = input(1,minval=1,maxval=31,title= "Test Start Day")start = timestamp(tsYear,tsMonth,tsDay,0,0)teYear = input(2021,minval=1000,maxval=9999,title=  "Test Stop Year")teMonth = input(5,minval=1,maxval=12,title=  "Test Stop Month")teDay = input(1,minval=1,maxval=31,title=  "Test Stop Day")end = timestamp(teYear,teMonth,teDay,0,0)// ======= variables =========var barsBetweenflips=25var coinFlipResult=0.0var flip=truevar coinLabel=0.0var stoppedOut= truevar takeProfit=truevar posLive=falsevar p1=0.0var p2=0.0var p3=0.0var plotBox=falsevar posType=0long=falseshort=false// ===== Functions ======getColor() =>     round(random(1,255))// ===== Logic ========if barssince(flip==true)>barsBetweenflips and posLive==false    flip:=true    coinLabel:=random(1,10)    // Candle Colors   candleColor= flip==true and flip[1]==false and barstate.isconfirmed==false?color.rgb(getColor(),getColor(),getColor(),0):flip==false and close>=open?color.green:color.redcandleColor:= barstate.ishistory==true and close>=open?color.green: barstate.ishistory==true and close<open? color.red:candleColor barcolor(candleColor)if flip[1]==true and posLive==false    flip:=false    barsBetweenflips:=round(random(3,round(maxBars)))    posLive:=true    long:= flip[1]==true and coinLabel[1]>=5.0short:= flip[1]==true and coinLabel[1]<5.0    // Calculate Position Boxesif long==true and posType!=1     riskLDEC=1-(risk/100)     p1:= close[1]*(1+((risk/100)*ratio)) // TargetLine    p2:=close[1]    p3:= close[1]*riskLDEC // StopLine    plotBox:=true    posType:=1  if short==true and posType!=-1     riskSDEC=1-((risk*ratio)/100)    p1:= close[1]*riskSDEC   // TargetLine    p2:=close[1]    p3:= close[1]*(1+(risk/100)) // StopLine    plotBox:=true    posType:=-1        // Check Trade Status stoppedOut:= posType==1 and long==false and low<= p3? true: posType==-1 and short==false and high>=p3? true: false  takeProfit:= posType==1 and long == false and high>= p1? true: posType==-1 and short==false and low<=p1? true: false  if stoppedOut==true or takeProfit==true    posType:=0    plotBox:=false    posLive:=false// ====== Plots ========plot1=plot(plotBox and showBox? p1:na,style=plot.style_linebr,color=color.white, transp= 100)plot2=plot(plotBox and showBox? p2:na,style=plot.style_linebr,color=color.white, transp= 100)plot3=plot(plotBox and showBox? p3:na,style=plot.style_linebr,color=color.white, transp= 100)fill(plot1,plot2,color= color.green)fill(plot2,plot3,color= color.red)plotshape(flip==true and flip[1]==false and coinLabel>=5.0,style=shape.labelup,location=location.belowbar, color=color.green,size=size.tiny,title="short label",text="Heads",textcolor=color.white)plotshape(flip==true and flip[1]==false and coinLabel<5.0,style=shape.labeldown,location=location.abovebar, color=color.red,size=size.tiny,title="short label",text="Tails",textcolor=color.white)if stoppedOut==true    label.new(bar_index-1, p3, style=label.style_xcross, color=color.orange)if takeProfit==true    label.new(bar_index-1, p1, style=label.style_flag, color=color.blue)        if runTest==true and customTime==false or runTest==true and customTime==true and time >= start and time <= end     strategy.entry("Sell", strategy.short,when=short==true)    strategy.close("Sell", comment="Close Short", when=stoppedOut==true or takeProfit==true)    strategy.entry("Long", strategy.long,when=long==true)    strategy.close("Long",comment="Close Long", when= stoppedOut==true or takeProfit==true )