Pine Script v5 · Strategy
PowerX by jwitt98
A Pine Script v5 strategy built on RSI (close, 7), SMA or Stoch (3) and MACD (close, 12). It has 10 order rules and no entry of its own. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 9 settings; defaults include Stop loss multiple 1.5, Profit target multiple 3.0 and Percent risk per trade 2.0.
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 PowerX by jwitt98 repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 26 of 26 trades.
- How did PowerX by jwitt98 do on BTCUSDT 1D with default settings?
- +107.85%
- From 26 Jan 2024 to 21 Oct 2026, over 78 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does PowerX by jwitt98 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: 78 before, 46 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 PowerX by jwitt98 use a stop loss?
- Yes
- strategy.exit sets a stop on line 93, 106.
- Does PowerX by jwitt98 run in Zeal Terminal?
- Yes
- It compiles in 42 ms and runs 1,000 bars in 67 ms, in the browser.
BTCUSDT · 1D · default settings
- Strategy equity
- Current risk
- Risk Factor
- RSI(7)
- Stoch %K
- MACD Hist
- Average daily range
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +107.85%
- $10,785.20
- Buy and hold
- +102.5%
- same period
- Closed trades
- 78
- 26 won · 52 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 1.08
- gross profit ÷ gross loss
- Max drawdown
- 107.84%
- −$32,798.10
One run with the author's default settings, $10,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
2 settings have no label
In the settings dialog startDate (line 13), endDate (line 14) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
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 |
|---|---|---|---|
| Start Date (no label in the script) | timestamp("1 Jan 2021 00:00 +0000") | time | isInTimeRange |
| End Date (no label in the script) | timestamp("1 Jan 2050 00:00 +0000") | time | isInTimeRange |
| Allow long positions | true | bool | exit Long limit/stop line 86 |
| Allow short positions | true | bool | exit Short limit/stop line 99 |
| Keep risk at or above the set point | false | bool | line 41 |
| Select the multipliers for the stop loss and profit targets | |||
| Stop loss multiple | 1.5 | float | longStopLoss shortStopLoss qtyToTrade |
| Profit target multiple | 3.0 | float | longProfitTarget shortProfitTarget |
| Money management | |||
| Use money management | false | bool | order Enter long order Enter long order Enter short order Enter short line 35 line 87 line 100 |
| Percent risk per trade | 2.0 | float | initial_riskPerTrade currentRisk |
What it calculates
- RSIclose, 7
rsiVal · line 53 - SMA / Stochta.sma(ta.stoch(close, high, low, 14),3), 3
stochKVal · line 55 - MACDclose, 12, 26, 9
macdLine · line 57 - MACDclose, 12, 26, 9
signalLine · line 57 - MACDclose, 12, 26, 9
histLine · line 57 - SMAhigh, 7
adr · line 59
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 |
|---|---|---|---|
| order Enter long long | (isUsingMoneyManagement) | On | 88 |
| order Enter long long | (isUsingMoneyManagement) | On | 91 |
| Exit Long limit/stop stop and limit | (greenBar and not greenBar[1] and isInTimeRange and isLongsAllowed) | On | 93 |
| cancel Enter long | (blackBar or redBar) | On | 96 |
| Close Enter long | (blackBar or redBar) | On | 97 |
| order Enter short short | (isUsingMoneyManagement) | On | 101 |
| order Enter short short | (isUsingMoneyManagement) | On | 104 |
| Exit Short limit/stop stop and limit | (redBar and not redBar[1] and isInTimeRange and isShortsAllowed) | On | 106 |
| cancel Enter short | (blackBar or greenBar) | On | 108 |
| Close Enter short | (blackBar or greenBar) | On | 109 |
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.
- 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 | +107.9% | +102.5% | 78 | 33% | 1.08 | 107.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −226.7% | +5.5% | 85 | 22% | 0.55 | 221.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +3.8% | +9.8% | 80 | 30% | 1.05 | 14.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −7.3% | +8.4% | 87 | 22% | 0.62 | 9.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +2.8% | +16.7% | 82 | 32% | 1.61 | 0.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.2% | +21.5% | 87 | 31% | 0.82 | 0.4% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +6.6% | +148.3% | 82 | 37% | 1.46 | 3.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −1.0% | +17.1% | 87 | 21% | 0.80 | 2.6% | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 30 | 33% | $1,372.65 |
| Sideways market | 31 | 45% | $27,860.70 |
| Falling market | 17 | 12% | −$18,448.10 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
98.2%
The 95th percentile of the worst drawdown when the same 78 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 90.6% to 98.2%; the tick is what actually happened, 92.1%. Order luck alone moves it this much.
All 78 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 29 Feb 2024 62,432.10 | 5 Mar 2024 60,057.30 | 5 | −$2,374.76 |
| short | 22 Mar 2024 65,501.30 | 8 Apr 2024 72,339.80 | 17 | −$6,838.55 |
| short | 15 Apr 2024 65,661.90 | 1 May 2024 56,685.70 | 16 | $8,976.11 |
| short | 27 Apr 2024 63,770.00 | 1 May 2024 56,685.70 | 4 | $7,084.26 |
| long | 7 May 2024 63,165.20 | 2 Jun 2024 67,766.80 | 26 | $4,601.66 |
| long | 10 May 2024 63,074.00 | 7 Jun 2024 68,979.50 | 28 | $5,905.53 |
| long | 14 May 2024 62,940.10 | 7 Jun 2024 68,979.50 | 24 | $6,039.44 |
| long | 16 May 2024 66,206.50 | 7 Jun 2024 68,979.50 | 22 | $2,773.02 |
| long | 6 Jun 2024 71,108.00 | 7 Jun 2024 68,979.50 | 1 | −$2,128.47 |
| short | 12 Jun 2024 67,314.20 | 12 Jun 2024 68,673.30 | 0 | −$1,359.09 |
| short | 3 Jul 2024 62,135.50 | 5 Jul 2024 56,768.60 | 2 | $5,366.87 |
| long | 16 Jul 2024 64,724.10 | 2 Aug 2024 65,354.00 | 17 | $629.96 |
| long | 20 Aug 2024 59,438.50 | 27 Aug 2024 58,177.90 | 7 | −$1,260.55 |
| long | 22 Aug 2024 61,156.00 | 27 Aug 2024 58,177.90 | 5 | −$2,978.08 |
| short | 31 Aug 2024 59,124.00 | 13 Sep 2024 58,132.30 | 13 | $991.68 |
| long | 18 Sep 2024 60,314.00 | 4 Oct 2024 60,752.70 | 16 | $438.73 |
| short | 8 Oct 2024 62,224.00 | 14 Oct 2024 65,179.10 | 6 | −$2,955.10 |
| long | 15 Oct 2024 66,084.00 | 4 Nov 2024 67,253.40 | 20 | $1,169.37 |
| long | 29 Oct 2024 69,962.20 | 4 Nov 2024 67,253.40 | 6 | −$2,708.84 |
| short | 5 Nov 2024 67,850.00 | 5 Nov 2024 70,414.40 | 0 | −$2,564.35 |
| long | 8 Nov 2024 75,857.90 | 11 Nov 2024 85,825.00 | 3 | $9,967.07 |
| long | 17 Dec 2024 106,059.00 | 18 Dec 2024 102,077.00 | 1 | −$3,981.73 |
| short | 22 Dec 2024 97,292.00 | 6 Jan 2025 98,363.60 | 15 | −$1,071.61 |
| short | 27 Dec 2024 95,791.60 | 6 Jan 2025 101,409.00 | 10 | −$5,617.54 |
| short | 11 Jan 2025 94,726.10 | 15 Jan 2025 97,885.20 | 4 | −$3,159.06 |
| long | 17 Jan 2025 99,987.30 | 1 Feb 2025 102,430.00 | 15 | $2,442.26 |
| short | 25 Feb 2025 91,552.90 | 26 Feb 2025 82,813.20 | 1 | $8,739.67 |
| short | 4 Mar 2025 86,221.20 | 24 Mar 2025 86,082.50 | 20 | $138.66 |
| short | 10 Mar 2025 80,734.50 | 9 Apr 2025 82,808.60 | 30 | −$2,074.12 |
| short | 7 Apr 2025 78,430.00 | 9 Apr 2025 82,808.60 | 2 | −$4,378.60 |
| short | 11 Apr 2025 79,607.30 | 14 Apr 2025 83,760.00 | 3 | −$4,152.70 |
| long | 19 May 2025 106,454.00 | 19 May 2025 102,521.00 | 0 | −$3,933.05 |
| long | 22 May 2025 109,644.00 | 29 May 2025 106,115.00 | 7 | −$3,529.40 |
| short | 1 Jun 2025 104,592.00 | 9 Jun 2025 106,981.00 | 8 | −$2,389.60 |
| long | 11 Jun 2025 110,274.00 | 13 Jun 2025 105,594.00 | 2 | −$4,680.68 |
| short | 20 Jun 2025 104,659.00 | 25 Jun 2025 107,962.00 | 5 | −$3,303.70 |
| long | 27 Jun 2025 106,947.00 | 10 Jul 2025 115,810.00 | 13 | $8,862.82 |
| long | 3 Jul 2025 108,850.00 | 10 Jul 2025 115,810.00 | 7 | $6,960.29 |
| long | 23 Jul 2025 119,954.00 | 25 Jul 2025 115,642.00 | 2 | −$4,312.39 |
| short | 1 Aug 2025 115,764.00 | 11 Aug 2025 119,345.00 | 10 | −$3,580.62 |
| long | 12 Aug 2025 118,686.00 | 12 Aug 2025 118,321.00 | 0 | −$364.93 |
| short | 19 Aug 2025 116,227.00 | 10 Sep 2025 111,546.00 | 22 | $4,680.67 |
| short | 24 Aug 2025 115,438.00 | 10 Sep 2025 113,419.00 | 17 | $2,018.90 |
| short | 5 Sep 2025 110,731.00 | 10 Sep 2025 113,419.00 | 5 | −$2,688.29 |
| short | 25 Sep 2025 113,307.00 | 29 Sep 2025 114,004.00 | 4 | −$697.08 |
| long | 2 Oct 2025 118,595.00 | 10 Oct 2025 114,351.00 | 8 | −$4,243.54 |
| short | 14 Oct 2025 115,166.00 | 27 Oct 2025 114,559.00 | 13 | $606.59 |
| short | 4 Nov 2025 106,583.00 | 18 Nov 2025 90,570.70 | 14 | $16,012.40 |
| short | 12 Nov 2025 103,059.00 | 18 Nov 2025 90,570.70 | 6 | $12,488.30 |
| long | 3 Dec 2025 91,277.90 | 15 Dec 2025 86,885.40 | 12 | −$4,392.50 |
| long | 9 Dec 2025 90,634.40 | 15 Dec 2025 86,885.40 | 6 | −$3,748.97 |
| short | 18 Dec 2025 86,243.20 | 22 Dec 2025 90,499.60 | 4 | −$4,256.36 |
| long | 31 Dec 2025 88,485.50 | 20 Jan 2026 87,904.80 | 20 | −$580.68 |
| long | 2 Jan 2026 88,839.10 | 20 Jan 2026 87,904.80 | 18 | −$934.23 |
| long | 12 Jan 2026 91,013.70 | 20 Jan 2026 87,904.80 | 8 | −$3,108.84 |
| short | 21 Jan 2026 88,427.70 | 31 Jan 2026 80,922.00 | 10 | $7,505.63 |
| long | 3 Mar 2026 68,830.10 | 23 Mar 2026 67,859.00 | 20 | −$971.06 |
| long | 13 Mar 2026 70,541.30 | 27 Mar 2026 68,820.30 | 14 | −$1,721.03 |
| long | 8 Apr 2026 71,924.20 | 4 May 2026 79,683.70 | 26 | $7,759.47 |
| long | 5 May 2026 79,861.00 | 16 May 2026 77,816.50 | 11 | −$2,044.47 |
| short | 17 May 2026 78,148.10 | 2 Jun 2026 70,632.70 | 16 | $7,515.34 |
| short | 28 Jun 2026 60,029.00 | 2 Jul 2026 61,862.90 | 4 | −$1,833.89 |
| short | 1 Jul 2026 58,624.70 | 2 Jul 2026 61,862.90 | 1 | −$3,238.19 |
| long | 6 Jul 2026 63,650.00 | 28 Jul 2026 63,139.90 | 22 | −$510.10 |
| long | 10 Jul 2026 63,230.00 | 28 Jul 2026 63,139.90 | 18 | −$90.10 |
| long | 15 Jul 2026 65,044.00 | 28 Jul 2026 63,139.90 | 13 | −$1,904.08 |
| long | 27 Jul 2026 65,400.00 | 28 Jul 2026 63,139.90 | 1 | −$2,260.09 |
| short | 29 Jul 2026 63,915.00 | 30 Jul 2026 64,963.20 | 1 | −$1,048.17 |
| short | 1 Aug 2026 62,887.90 | 5 Aug 2026 64,917.20 | 4 | −$2,029.29 |
| long | 8 Aug 2026 64,923.20 | 11 Aug 2026 63,661.90 | 3 | −$1,261.31 |
| short | 14 Aug 2026 63,490.90 | 17 Aug 2026 64,438.90 | 3 | −$948.00 |
| long | 20 Aug 2026 69,334.80 | 21 Aug 2026 75,123.90 | 1 | $5,789.13 |
| long | 4 Sep 2026 81,270.40 | 8 Sep 2026 78,130.60 | 4 | −$3,139.76 |
| short | 10 Sep 2026 78,306.40 | 18 Sep 2026 78,358.70 | 8 | −$52.29 |
| short | 16 Sep 2026 75,644.50 | 18 Sep 2026 78,358.70 | 2 | −$2,714.24 |
| long | 22 Sep 2026 86,620.00 | 24 Sep 2026 83,091.70 | 2 | −$3,528.29 |
| short | 10 Oct 2026 82,635.60 | 21 Oct 2026 84,760.90 | 11 | −$2,125.38 |
| short | 13 Oct 2026 81,850.00 | 21 Oct 2026 84,760.90 | 8 | −$2,910.93 |
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 |
|---|---|---|---|---|---|
| PowerX by jwitt98 this page | — | v5 strategy | +107.9% | 78 | 107.8% |
| Simple Buy-Sell Strategy by BlockchainSpecialists | sma macd rsi | v4 strategy | +43.7% | 6 | 15.5% |
| CCI Level Zone by Naruephat | sma rsi stoch | v5 strategy | No trades on this market | ||
| AVWAP Strategy by asfbhero | rsi stoch sma | v5 strategy | does not run in Zeal Terminal | ||
| SRJ RSI Outperformer Strategy by Sapt_Jash | rsi sma | v5 strategy | +0.6% | 8 | 2.4% |
| RSI SMA Crossover Strategy by reees | rsi sma | v5 strategy | +39.8% | 42 | 30.8% |
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.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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: 78 before, 46 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.
⋯//The PowerX strategy - based on the rules outlined in the book "The PowerX Strategy: How to Trade Stocks and Options in Only 15 Minutes a Day" by Markus Heitkoetter-//@version=5+//@version=6strategy("PowerX", overlay=true, initial_capital=10000)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 42 ms | Yes 1,000 bars in 67 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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/// © jwitt98//The PowerX strategy - based on the rules outlined in the book "The PowerX Strategy: How to Trade Stocks and Options in Only 15 Minutes a Day" by Markus Heitkoetter//@version=5strategy("PowerX", overlay=true, initial_capital=10000)longEntry = "Enter long"shortEntry = "Enter short"longExit = "Exit long"shortExit = "Exit short"//*********************************Begin inputs*********************************//get time range inputs and set time range booltimeRangeGroup = "Select the trading range"startDate = input.time(timestamp("1 Jan 2021 00:00 +0000"), "Start date", "Select the start date for the trading range", "", timeRangeGroup)endDate = input.time(timestamp("1 Jan 2050 00:00 +0000"), "End date", "Select the end date for the trading range", "", timeRangeGroup)isInTimeRange = time >= startDate and time <= endDate//get long/short inputspositionsAllowedGroup = "Select the direction(s) of trades to allow"isLongsAllowed = input.bool(true, "Allow long positions", "Check the box if you want to allow long positions", "", positionsAllowedGroup)isShortsAllowed = input.bool(true, "Allow short positions", "Check the box if you want to allow short positions", "", positionsAllowedGroup)//get the stop loss and profit target multiples. Per the PowerX rules the ratio shoud be 1:2. 1.5 and 3 are defaultsadrMultuplesGroup="Select the multipliers for the stop loss and profit targets"stopLossMultiple = input.float(1.5, "Stop loss multiple", 0.1, 10, 0.1, "The ADR is multiplied by the stop loss multiple to calculate the stop loss", group=adrMultuplesGroup)profitTargetMultiple=input.float(3.0, "Profit target multiple", 0.1, 10, 0.1, "The ADR is multiplied by the profit target multiple to calculate the profit target", group=adrMultuplesGroup)//get the option to use the money management stategy or not. This is a fixed ratio type management systemmoneyManagementGroup="Money management"isUsingMoneyManagement=input.bool(false, "Use money management", "Check the box if you want to use a fixed ratio type money management system, such as the type described in PowerX", group=moneyManagementGroup)initial_riskPercent=input.float(2.0, "Percent risk per trade", .1, 100, .1, "The percentage of capital you want to risk when starting out. This will increase or decrease base on the money management rules. Only applicable if money managent is used", group=moneyManagementGroup)/100isRiskDowsideLimited=input.bool(false, "Keep risk at or above the set point", "Check the box if you don't want the risk to fall below the set \"risk per trade\" percentage, for example, when your equity is underwater. Only applicable if money management is used", "", moneyManagementGroup)initial_riskPerTrade=initial_riskPercent * strategy.initial_capital riskFactor = 0.0currentProfit = 0.0currentRisk = 0.0//*********************************End inputs*********************************//*********************************Begin money management*********************************if(isUsingMoneyManagement) currentProfit := strategy.equity - strategy.initial_capital if(currentProfit < 0) currentProfit:=math.abs(currentProfit) riskFactor := 0.5*(math.pow(1+8*currentProfit/(2*initial_riskPerTrade), 0.5)+1) currentRisk := 1/riskFactor * initial_riskPercent * strategy.initial_capital if(isRiskDowsideLimited) currentRisk := initial_riskPerTrade else riskFactor := 0.5*(math.pow(1+8*currentProfit/(2*initial_riskPerTrade), 0.5)+1) currentRisk := riskFactor * initial_riskPercent * strategy.initial_capital plot(strategy.equity, "Strategy equity", display=display.data_window)plot(currentRisk, "Current risk", display=display.data_window)plot(riskFactor, "Risk Factor", display=display.data_window)//*********************************End money management*********************************//*********************************Begin indicators*********************************//4 indicators are used in this strategy, RSI(7), Stochastics(14, 3, 3), MACD(12, 26, 9), and ADR(7)rsiVal = ta.rsi(close, 7)//this checks outplot(rsiVal, "RSI(7)", color.lime, display=display.data_window)stochKVal = ta.sma(ta.sma(ta.stoch(close, high, low, 14),3),3)//this formula checks outplot(stochKVal, "Stoch %K", color.lime, display=display.data_window)[macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)plot(histLine, "MACD Hist", color.lime, display=display.data_window)adr = ta.sma(high, 7) - ta.sma(low, 7)plot(adr, "Average daily range", color.orange, display=display.data_window)//*********************************End indicators*********************************//*********************************Define the bar colors*********************************greenBar = rsiVal > 50 and stochKVal > 50 and histLine > 0redBar = rsiVal < 50 and stochKVal < 50 and histLine < 0blackBar = not greenBar and not redBarcolor currentBarColor = switch greenBar => color.green redBar => color.red blackBar => color.gray //because black is too hard to see in dark mmode => color.yellow barcolor(currentBarColor)//*********************************End defining the bar colors*********************************//*********************************Define the entry, stop loss and profit target*********************************longStopLimit = high + .01longProfitTarget = high + (profitTargetMultiple * adr)longStopLoss = high - (stopLossMultiple * adr)shortStopLimit = low - .01shortProfitTarget = low - (profitTargetMultiple * adr)shortStopLoss = low + (stopLossMultiple * adr)qtyToTrade= math.floor(currentRisk / (stopLossMultiple * adr))//only if using money managementif(qtyToTrade * high > strategy.equity) qtyToTrade := math.floor(strategy.equity / high)//*********************************End defining stop loss and profit targets*********************************//*********************************Execute trades, set rules, stop loss and profit targets*********************************if (greenBar and not greenBar[1] and isInTimeRange and isLongsAllowed) if(isUsingMoneyManagement) strategy.order(longEntry, strategy.long, qtyToTrade, limit=longStopLimit, stop=longStopLimit) //strategy.order(longEntry, strategy.long, qtyToTrade, stop=longStopLimit) else strategy.order(longEntry, strategy.long, limit=longStopLimit,stop=longStopLimit) //strategy.order(longEntry, strategy.long, stop=longStopLimit) strategy.exit("Long limit/stop", from_entry=longEntry, limit=longProfitTarget, stop=longStopLoss) if(blackBar or redBar) strategy.cancel(longEntry) strategy.close(longEntry, longExit) if (redBar and not redBar[1] and isInTimeRange and isShortsAllowed) if(isUsingMoneyManagement) strategy.order(shortEntry, strategy.short, qtyToTrade, limit=shortStopLimit, stop=shortStopLimit) //strategy.order(shortEntry, strategy.short, qtyToTrade, stop=shortStopLimit) else strategy.order(shortEntry, strategy.short, limit=shortStopLimit, stop=shortStopLimit) //strategy.order(shortEntry, strategy.short, stop=shortStopLimit) strategy.exit("Short limit/stop", from_entry=shortEntry, limit=shortProfitTarget, stop=shortStopLoss)if(blackBar or greenBar) strategy.cancel(shortEntry) strategy.close(shortEntry, shortExit) //*********************************End execute trades, set rules, stop loss and profit targets*********************************