Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Open Price Strategy

A Pine Script v4 strategy built on EMA (close, 15), Crossover (wait_ema, OpenPA) and Crossunder (wait_ema, OpenPA). It has 38 order rules, 32 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 10000 in cash and pays no commission. 40 settings; defaults include Time Frame For Enter ASAP 0930-0931, Time Frame For Wait To Enter 0930-1555 and Time Frame To Exit Trades 0930-1555.

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 Open Price Strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Open Price Strategy 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. It closed no trades on the other markets either. A backtest, not investment advice.
Can Open Price Strategy be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Open Price Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 244, 246.
Does Open Price Strategy run in Zeal Terminal?
Yes
It compiles in 75 ms and runs 1,000 bars in 168 ms, in the browser.

BTCUSDT · 1D · default settings

  • Open Price
  • 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 (40)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$10,000$20,253Equity from $10,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. 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, $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

    1 setting does nothing

    “Note For Your Reference Only” is declared but never read.

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

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 ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder, sum → math.sum.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 10: input(type = input.time) → input.time()
  • Line 11: input(type = input.time) → input.time()
  • Line 43: ema → ta.ema
  • Line 45: crossover → ta.crossover
  • Line 46: crossunder → ta.crossunder
13 more edits
  • Line 53: ema → ta.ema
  • Line 62: ema → ta.ema
  • Line 69: input(type = input.integer) → input.int()
  • Line 71: sum → math.sum
  • Line 71: sum → math.sum
  • Line 76: input(type = input.integer) → input.int()
  • Line 78: sum → math.sum
  • Line 78: sum → math.sum
  • Line 84: ema → ta.ema
  • Line 87: crossover → ta.crossover
  • Line 88: crossunder → ta.crossunder
  • Line 92: input(type = input.float) → input.float()
  • Line 93: input(type = input.float) → input.float()
⋯// © REV0LUTI0N-//@version=4+//@version=5//------------------------------------------------------------------------------  ⋯// Strategy Backtesting-startDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date', group="Backtesting")+startDate  = input.time(timestamp("2021-10-01T00:00:00"), title='Backtesting Start Date', group="Backtesting")-finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date', group="Backtesting")+finishDate = input.time(timestamp("9999-12-31T00:00:00"), title='Backtesting End Date', group="Backtesting")time_cond  = time >= startDate and time <= finishDate⋯wait_emasrc = input(close, title="EMA Source", group="Wait To Enter Settings")-wait_ema = ema(wait_emasrc, wait_ema_length)+wait_ema = ta.ema(wait_emasrc, wait_ema_length)plot(waittoenter ? wait_ema : na, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)-emacrossup = crossover(wait_ema, OpenPA)+emacrossup = ta.crossover(wait_ema, OpenPA)-emacrossdown = crossunder(wait_ema, OpenPA)+emacrossdown = ta.crossunder(wait_ema, OpenPA)//------------------------------------------------------------------------------  ⋯emasrc_asap = input(close, title="EMA Source", group="EMA Filter (Enter ASAP)")-ema_asap = ema(emasrc_asap, ema_length_asap)+ema_asap = ta.ema(emasrc_asap, ema_length_asap)//plot(ema_asap, "EMA (Enter ASAP)", style=plot.style_linebr, color=#cad850, linewidth=2)⋯emasrc = input(close, title="EMA Source", group="EMA Filter (Wait To Enter)")-ema = ema(emasrc, ema_length)+ema = ta.ema(emasrc, ema_length)//plot(ema, "EMA (Wait To Enter)", style=plot.style_linebr, color=#cad850, linewidth=2)⋯usecmffilter_asap = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")-mflength_asap = input(title="CMF length", group="CMF Filter (Enter ASAP)", type=input.integer, defval=20)+mflength_asap = input.int(title="CMF length", group="CMF Filter (Enter ASAP)", defval=20)ad_asap = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume-mf_asap = sum(ad_asap, mflength_asap) / sum(volume, mflength_asap)+mf_asap = math.sum(ad_asap, mflength_asap) / math.sum(volume, mflength_asap)//------------------------------------------------------------------------------  ⋯usecmffilter = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")-mflength = input(title="CMF length", group="CMF Filter (Wait To Enter)", type=input.integer, defval=20)+mflength = input.int(title="CMF length", group="CMF Filter (Wait To Enter)", defval=20)ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume-mf = sum(ad, mflength) / sum(volume, mflength)+mf = math.sum(ad, mflength) / math.sum(volume, mflength)//------------------------------------------------------------------------------  ⋯stop_emasrc = input(close, title="EMA Source", group="Open Line As Stop Loss")-stop_ema = ema(stop_emasrc, stop_ema_length)+stop_ema = ta.ema(stop_emasrc, stop_ema_length)//plot(stop_ema, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)plot(openlineclose ? stop_ema : na, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)-pricecrossup = crossover(stop_ema, OpenPA)+pricecrossup = ta.crossover(stop_ema, OpenPA)-pricecrossdown = crossunder(stop_ema, OpenPA)+pricecrossdown = ta.crossunder(stop_ema, OpenPA)//------------------------------------------------------------------------------  ⋯enablesltp = input(false, title='Enable Stop Loss & Take Profit', group="% Stop Loss & Take Profit")-stopTick = input(2.0, title='Stop Loss %', group="% Stop Loss & Take Profit", type=input.float, step=0.1) / 100+stopTick = input.float(2.0, title='Stop Loss %', group="% Stop Loss & Take Profit", step=0.1) / 100-takeTick = input(4.0, title='Take Profit %', group="% Stop Loss & Take Profit", type=input.float, step=0.1) / 100+takeTick = input.float(4.0, title='Take Profit %', group="% Stop Loss & Take Profit", step=0.1) / 100longStop = strategy.position_avg_price * (1 - stopTick)⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 7: input() → input.string()
  • Line 15: input() → input.string()
  • Line 16: input() → input.string()
  • Line 17: input() → input.string()
  • Line 18: input() → input.bool()
  • Line 24: input() → input.bool()
28 more edits
  • Line 25: input() → input.bool()
  • Line 28: input() → input.string()
  • Line 29: input() → input.source()
  • Line 30: input() → input.source()
  • Line 39: input() → input.bool()
  • Line 40: input() → input.bool()
  • Line 41: input() → input.int()
  • Line 42: input() → input.source()
  • Line 49: input() → input.bool()
  • Line 50: input() → input.bool()
  • Line 51: input() → input.int()
  • Line 52: input() → input.source()
  • Line 58: input() → input.bool()
  • Line 59: input() → input.bool()
  • Line 60: input() → input.int()
  • Line 61: input() → input.source()
  • Line 67: input() → input.bool()
  • Line 68: input() → input.bool()
  • Line 74: input() → input.bool()
  • Line 75: input() → input.bool()
  • Line 81: input() → input.bool()
  • Line 82: input() → input.int()
  • Line 83: input() → input.source()
  • Line 91: input() → input.bool()
  • Line 104: input() → input.string()
  • Line 105: input() → input.string()
  • Line 106: input() → input.string()
  • Line 107: input() → input.string()
⋯strategy("Open Price Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)-notes = input("", title="Note For Your Reference Only")+notes = input.string("", title="Note For Your Reference Only")//------------------------------------------------------------------------------  ⋯//Time Restriction Settings-firsttradetime = input("0930-0931", title='Time Frame For Enter ASAP', group="Time Restriction")+firsttradetime = input.string("0930-0931", title='Time Frame For Enter ASAP', group="Time Restriction")-startendtime = input("0930-1555", title='Time Frame For Wait To Enter', group="Time Restriction")+startendtime = input.string("0930-1555", title='Time Frame For Wait To Enter', group="Time Restriction")-endtime = input("0930-1555", title='Time Frame To Exit Trades', group="Time Restriction")+endtime = input.string("0930-1555", title='Time Frame To Exit Trades', group="Time Restriction")-enableclose = input(true, title='Enable Close Trade At End Of Exit Time Frame', group="Time Restriction")+enableclose = input.bool(true, title='Enable Close Trade At End Of Exit Time Frame', group="Time Restriction")firsttradetimetobuy = (time(timeframe.period, firsttradetime))⋯// Contrarian Settings-nocontrarian = input(true, title="Trade Regular Signals", inline="1", group="Contrarian Settings")+nocontrarian = input.bool(true, title="Trade Regular Signals", inline="1", group="Contrarian Settings")-usecontrarian = input(false, title="Trade Contrarian Signals", inline="1", group="Contrarian Settings")+usecontrarian = input.bool(false, title="Trade Contrarian Signals", inline="1", group="Contrarian Settings")//------------------------------------------------------------------------------  // Open Price Code-openpricetime = input('0930-0931', title="Time To Get Open Price", group="Strategy Settings")+openpricetime = input.string('0930-0931', title="Time To Get Open Price", group="Strategy Settings")-opencondition = input(open, title="Open Price Source", group="Strategy Settings")+opencondition = input.source(open, title="Open Price Source", group="Strategy Settings")-entrycondition = input(close, title="Entry Price Source", group="Strategy Settings")+entrycondition = input.source(close, title="Entry Price Source", group="Strategy Settings")OpenValueTime = time("1", openpricetime)⋯// EMA Open Line Cross Condition (Wait To Enter)-enterasap = input(true, title="Enter Trade ASAP", inline="1", group="Wait To Enter Settings")+enterasap = input.bool(true, title="Enter Trade ASAP", inline="1", group="Wait To Enter Settings")-waittoenter = input(false, title="Wait For EMA To Cross Open Line", inline="1", group="Wait To Enter Settings")+waittoenter = input.bool(false, title="Wait For EMA To Cross Open Line", inline="1", group="Wait To Enter Settings")-wait_ema_length = input(defval=15, minval=1, title="EMA Length", group="Wait To Enter Settings")+wait_ema_length = input.int(defval=15, minval=1, title="EMA Length", group="Wait To Enter Settings")-wait_emasrc = input(close, title="EMA Source", group="Wait To Enter Settings")+wait_emasrc = input.source(close, title="EMA Source", group="Wait To Enter Settings")wait_ema = ta.ema(wait_emasrc, wait_ema_length)⋯// EMA Filter (Enter ASAP)-noemafilter_asap = input(true, title="No EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")+noemafilter_asap = input.bool(true, title="No EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")-useemafilter_asap = input(false, title="Use EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")+useemafilter_asap = input.bool(false, title="Use EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")-ema_length_asap = input(defval=15, minval=1, title="EMA Length", group="EMA Filter (Enter ASAP)")+ema_length_asap = input.int(defval=15, minval=1, title="EMA Length", group="EMA Filter (Enter ASAP)")-emasrc_asap = input(close, title="EMA Source", group="EMA Filter (Enter ASAP)")+emasrc_asap = input.source(close, title="EMA Source", group="EMA Filter (Enter ASAP)")ema_asap = ta.ema(emasrc_asap, ema_length_asap)⋯// EMA Filter (Wait To Enter)-noemafilter = input(true, title="No EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")+noemafilter = input.bool(true, title="No EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")-useemafilter = input(false, title="Use EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")+useemafilter = input.bool(false, title="Use EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")-ema_length = input(defval=15, minval=1, title="EMA Length", group="EMA Filter (Wait To Enter)")+ema_length = input.int(defval=15, minval=1, title="EMA Length", group="EMA Filter (Wait To Enter)")-emasrc = input(close, title="EMA Source", group="EMA Filter (Wait To Enter)")+emasrc = input.source(close, title="EMA Source", group="EMA Filter (Wait To Enter)")ema = ta.ema(emasrc, ema_length)⋯// CMF Filter (Enter ASAP)-nocmffilter_asap = input(true, title="No CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")+nocmffilter_asap = input.bool(true, title="No CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")-usecmffilter_asap = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")+usecmffilter_asap = input.bool(false, title="Use CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")mflength_asap = input.int(title="CMF length", group="CMF Filter (Enter ASAP)", defval=20)⋯// CMF Filter (Wait To Enter)-nocmffilter = input(true, title="No CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")+nocmffilter = input.bool(true, title="No CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")-usecmffilter = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")+usecmffilter = input.bool(false, title="Use CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")mflength = input.int(title="CMF length", group="CMF Filter (Wait To Enter)", defval=20)⋯// EMA For Cross Over Open Line Stop Loss-openlineclose = input(false, title='Exit When Stop Loss EMA Crosses Open Line', group="Open Line As Stop Loss")+openlineclose = input.bool(false, title='Exit When Stop Loss EMA Crosses Open Line', group="Open Line As Stop Loss")-stop_ema_length = input(defval=15, minval=1, title="EMA Length", group="Open Line As Stop Loss")+stop_ema_length = input.int(defval=15, minval=1, title="EMA Length", group="Open Line As Stop Loss")-stop_emasrc = input(close, title="EMA Source", group="Open Line As Stop Loss")+stop_emasrc = input.source(close, title="EMA Source", group="Open Line As Stop Loss")stop_ema = ta.ema(stop_emasrc, stop_ema_length)⋯// Stop Loss & Take Profit % Based-enablesltp = input(false, title='Enable Stop Loss & Take Profit', group="% Stop Loss & Take Profit")+enablesltp = input.bool(false, title='Enable Stop Loss & Take Profit', group="% Stop Loss & Take Profit")stopTick = input.float(2.0, title='Stop Loss %', group="% Stop Loss & Take Profit", step=0.1) / 100⋯// Alert messages-message_enterlong  = input("", title="Long Entry message", group="Alert Messages")+message_enterlong  = input.string("", title="Long Entry message", group="Alert Messages")-message_entershort = input("", title="Short Entry message", group="Alert Messages")+message_entershort = input.string("", title="Short Entry message", group="Alert Messages")-message_closelong = input("", title="Close Long message", group="Alert Messages")+message_closelong = input.string("", title="Close Long message", group="Alert Messages")-message_closeshort = input("", title="Close Short message", group="Alert Messages")+message_closeshort = input.string("", title="Close Short message", group="Alert Messages")//------------------------------------------------------------------------------  ⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © REV0LUTI0N-//@version=5+//@version=6//------------------------------------------------------------------------------  ⋯

Settings

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

SettingDefaultType and rangeFeeds
Note For Your Reference Onlystringunused
Backtesting
Backtesting Start Datetimestamp("2021-10-01T00:00:00")timetime_cond
Backtesting End Datetimestamp("9999-12-31T00:00:00")timetime_cond
Time Restriction
Time Frame For Enter ASAP0930-0931stringfirsttradetimetobuy
Time Frame For Wait To Enter0930-1555stringtimetobuy
Time Frame To Exit Trades0930-1555stringtimetoclose
Enable Close Trade At End Of Exit Time Frametrueboolclose_all close_all line 230 line 232
Contrarian Settings
Trade Regular Signalstrueboolentry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short line 112 line 115 line 119 line 122 line 142 line 145 line 148 line 151 line 170 line 173 line 177 line 180 line 200 line 203 line 207 line 210
Trade Contrarian Signalsfalseboolentry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long entry Short entry Long line 127 line 130 line 134 line 137 line 156 line 159 line 162 line 165 line 185 line 188 line 192 line 195 line 215 line 218 line 222 line 225
Strategy Settings
Time To Get Open Price0930-0931stringOpenValueTime
Open Price SourceopensourceOpenPA
Entry Price Sourceclosesourceentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 112 line 115 line 127 line 130 line 142 line 145 line 156 line 159 line 170 line 173 line 185 line 188 line 200 line 203 line 215 line 218
Wait To Enter Settings
Enter Trade ASAPtrueboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 112 line 115 line 127 line 130 line 142 line 145 line 156 line 159 line 170 line 173 line 185 line 188 line 200 line 203 line 215 line 218
Wait For EMA To Cross Open Linefalseboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long EMA - Wait To Enter line 119 line 122 line 134 line 137 line 148 line 151 line 162 line 165 line 177 line 180 line 192 line 195 line 207 line 210 line 222 line 225
EMA Length15int · min 1wait_ema
EMA Sourceclosesourcewait_ema
EMA Filter (Enter ASAP)
No EMA Filtertrueboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 112 line 115 line 127 line 130 line 170 line 173 line 185 line 188
Use EMA Filterfalseboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long EMA (Enter ASAP) line 142 line 145 line 156 line 159 line 200 line 203 line 215 line 218
EMA Length15int · min 1ema_asap
EMA Sourceclosesourceema_asap
EMA Filter (Wait To Enter)
No EMA Filtertrueboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 119 line 122 line 134 line 137 line 177 line 180 line 192 line 195
Use EMA Filterfalseboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long EMA (Wait To Enter) line 148 line 151 line 162 line 165 line 207 line 210 line 222 line 225
EMA Length15int · min 1ema
EMA Sourceclosesourceema
CMF Filter (Enter ASAP)
No CMF Filtertrueboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 112 line 115 line 127 line 130 line 142 line 145 line 156 line 159
Use CMF Filterfalseboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 170 line 173 line 185 line 188 line 200 line 203 line 215 line 218
CMF length20int (written input.integer)mf_asap
CMF Filter (Wait To Enter)
No CMF Filtertrueboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 119 line 122 line 134 line 137 line 148 line 151 line 162 line 165
Use CMF Filterfalseboolentry Long entry Short entry Short entry Long entry Long entry Short entry Short entry Long line 177 line 180 line 192 line 195 line 207 line 210 line 222 line 225
CMF length20int (written input.integer)mf
Open Line As Stop Loss
Exit When Stop Loss EMA Crosses Open Linefalseboolclose_all close_all EMA - Wait To Enter line 237 line 239
EMA Length15int · min 1stop_ema
EMA Sourceclosesourcestop_ema
% Stop Loss & Take Profit
Enable Stop Loss & Take Profitfalseboolexit Close Long exit Close Short Long Stop Loss Short Stop Loss Long Take Profit Short Take Profit line 243 line 245
Stop Loss %2.0float · step 0.1longStop shortStop
Take Profit %4.0float · step 0.1shortTake longTake
Alert Messages
Long Entry messagestringentry Long
Short Entry messagestringentry Short
Close Long messagestringclose_all exit Close Long
Close Short messagestringclose_all exit Close Short

What it calculates

  • EMA (ema, ta.ema in v5)EMA Source (close), EMA Length (15)wait_ema · line 43
  • Crossover (crossover, ta.crossover in v5)wait_ema, OpenPAemacrossup · line 45
  • Crossunder (crossunder, ta.crossunder in v5)wait_ema, OpenPAemacrossdown · line 46
  • EMA (ema, ta.ema in v5)EMA Source (close), EMA Length (15)ema_asap · line 53
  • EMA (ema, ta.ema in v5)EMA Source (close), EMA Length (15)ema · line 62
  • EMA (ema, ta.ema in v5)EMA Source (close), EMA Length (15)stop_ema · line 84
  • Crossover (crossover, ta.crossover in v5)stop_ema, OpenPApricecrossup · line 87
  • Crossunder (crossunder, ta.crossunder in v5)stop_ema, OpenPApricecrossdown · line 88

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.

closecloseprice datawait_ema_lengthEMA Lengthsetting · 15ema_length_asapEMA Lengthsetting · 15ema_lengthEMA Lengthsetting · 15stop_ema_lengthEMA Lengthsetting · 15firsttradetimeTime Frame For Enter AS…setting · 0930-0931startendtimeTime Frame For Wait To …setting · 0930-1555endtimeTime Frame To Exit Trad…setting · 0930-1555openpricetimeTime To Get Open Pricesetting · 0930-0931openopenprice datavolumevolumeprice datalowlowprice datahighhighprice datamflength_asapCMF lengthsetting · 20mflengthCMF lengthsetting · 20stopTickStop Loss %setting · 2.0takeTickTake Profit %setting · 4.0timetimeprice datastartDateBacktesting Start Datesetting · timestamp("2021-10-…finishDateBacktesting End Datesetting · timestamp("9999-12-…wait_emaEMA→ wait_emaemacrossupCrossover→ emacrossupemacrossdownCrossunder→ emacrossdownema_asapEMA→ ema_asapemaEMA→ emastop_emaEMA→ stop_emapricecrossupCrossover→ pricecrossuppricecrossdownCrossunder→ pricecrossdownfirsttradetimetobuyfirsttradetimetobuyvaluetimetobuytimetobuyvaluetimetoclosetimetoclosevalueOpenValueTimeOpenValueTimevalueOpenPAOpenPAvaluead_asap, adad_asap · ad2 valuesmf_asapmf_asapvaluemfmfvaluelongStop, shortStoplongStop · shortStop2 valuesshortTake, longTakeshortTake · longTake2 valuestime_condtime_condconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose_all:close_all strategy.close_allexit:Close Longexit Close Longstrategy.exitexit:Close Shortexit Close Shortstrategy.exitplot:36Open Priceplotplot:44EMA - Wait To Enterplotplot:55EMA (Enter ASAP)plotplot:64EMA (Wait To Enter)plotplot:86EMA - Wait To Enterplotplot:98Long Stop Lossplotplot:99Short Stop Lossplotplot:100Long Take Profitplotplot:101Short Take Profitplot

Order rules

OrderFires whenBy defaultLine
Open Long longentrycondition > OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and nocontrarianOn113
Open Short shortentrycondition < OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and nocontrarianOn116
Open Long longemacrossup and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and nocontrarianOn120
Open Short shortemacrossdown and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and nocontrarianOn123
Open Short shortentrycondition > OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and usecontrarianOn128
Open Long longentrycondition < OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and usecontrarianOn131
Open Short shortemacrossup and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and usecontrarianOn135
Open Long longemacrossdown and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and usecontrarianOn138
Open Long longentrycondition > OpenPA and close > ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and nocontrarianOn143
Open Short shortentrycondition < OpenPA and close < ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and nocontrarianOn146
Open Long longemacrossup and close > ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and nocontrarianOn149
Open Short shortemacrossdown and close < ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and nocontrarianOn152
Open Short shortentrycondition > OpenPA and close > ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and usecontrarianOn157
Open Long longentrycondition < OpenPA and close < ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and usecontrarianOn160
Open Short shortemacrossup and close > ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and usecontrarianOn163
Open Long longemacrossdown and close < ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and usecontrarianOn166
Open Long longentrycondition > OpenPA and mf_asap > 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and nocontrarianOn171
Open Short shortentrycondition < OpenPA and mf_asap < 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and nocontrarianOn174
Open Long longemacrossup and mf > 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and nocontrarianOn178
Open Short shortemacrossdown and mf < 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and nocontrarianOn181
Open Short shortentrycondition > OpenPA and mf_asap > 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and usecontrarianOn186
Open Long longentrycondition < OpenPA and mf_asap < 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and usecontrarianOn189
Open Short shortemacrossup and mf > 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and usecontrarianOn193
Open Long longemacrossdown and mf < 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and usecontrarianOn196
Open Long longentrycondition > OpenPA and close > ema_asap and mf_asap > 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and nocontrarianOn201
Open Short shortentrycondition < OpenPA and close < ema_asap and mf_asap < 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and nocontrarianOn204
Open Long longemacrossup and close > ema and mf > 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and nocontrarianOn208
Open Short shortemacrossdown and close < ema and mf < 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and nocontrarianOn211
Open Short shortentrycondition > OpenPA and close > ema_asap and mf_asap > 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and usecontrarianOn216
Open Long longentrycondition < OpenPA and close < ema_asap and mf_asap < 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and usecontrarianOn219
Open Short shortemacrossup and close > ema and mf > 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and usecontrarianOn223
Open Long longemacrossdown and close < ema and mf < 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and usecontrarianOn226
Close strategy.position_size > 0 and timetoclose and enablecloseOn231
Close strategy.position_size < 0 and timetoclose and enablecloseOn233
Close strategy.position_size > 0 and pricecrossdown and openlinecloseOn238
Close strategy.position_size < 0 and pricecrossup and openlinecloseOn240
Exit Close Long stop and limitstrategy.position_size > 0 and enablesltp and time_condOn244
Exit Close Short stop and limitstrategy.position_size < 0 and enablesltp and time_condOn246

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 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

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
Open Price Strategy this page—v4 strategy0.0%00.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%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 75 msWith a workaround 1,000 bars in 168 msNot measured
PineTSNo v5 and v6 only—Not measured

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/// © REV0LUTI0N//@version=4//------------------------------------------------------------------------------  // Strategystrategy("Open Price Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)notes = input("", title="Note For Your Reference Only")//------------------------------------------------------------------------------  // Strategy BacktestingstartDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date', group="Backtesting")finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date', group="Backtesting")time_cond  = time >= startDate and time <= finishDate//------------------------------------------------------------------------------  //Time Restriction Settingsfirsttradetime = input("0930-0931", title='Time Frame For Enter ASAP', group="Time Restriction")startendtime = input("0930-1555", title='Time Frame For Wait To Enter', group="Time Restriction")endtime = input("0930-1555", title='Time Frame To Exit Trades', group="Time Restriction")enableclose = input(true, title='Enable Close Trade At End Of Exit Time Frame', group="Time Restriction")firsttradetimetobuy = (time(timeframe.period, firsttradetime))timetobuy = (time(timeframe.period, startendtime))timetoclose = na(time(timeframe.period, endtime))//------------------------------------------------------------------------------  // Contrarian Settingsnocontrarian = input(true, title="Trade Regular Signals", inline="1", group="Contrarian Settings")usecontrarian = input(false, title="Trade Contrarian Signals", inline="1", group="Contrarian Settings")//------------------------------------------------------------------------------  // Open Price Codeopenpricetime = input('0930-0931', title="Time To Get Open Price", group="Strategy Settings")opencondition = input(open, title="Open Price Source", group="Strategy Settings")entrycondition = input(close, title="Entry Price Source", group="Strategy Settings")OpenValueTime = time("1", openpricetime)var OpenPA = 0.0if OpenValueTime    if not OpenValueTime[1]        OpenPA := openconditionplot(not OpenValueTime ? OpenPA : na, title="Open Price", color=color.red, linewidth=2, style=plot.style_linebr)//------------------------------------------------------------------------------  // EMA Open Line Cross Condition (Wait To Enter)enterasap = input(true, title="Enter Trade ASAP", inline="1", group="Wait To Enter Settings")waittoenter = input(false, title="Wait For EMA To Cross Open Line", inline="1", group="Wait To Enter Settings")wait_ema_length = input(defval=15, minval=1, title="EMA Length", group="Wait To Enter Settings")wait_emasrc = input(close, title="EMA Source", group="Wait To Enter Settings")wait_ema = ema(wait_emasrc, wait_ema_length)plot(waittoenter ? wait_ema : na, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)emacrossup = crossover(wait_ema, OpenPA)emacrossdown = crossunder(wait_ema, OpenPA)//------------------------------------------------------------------------------  // EMA Filter (Enter ASAP)noemafilter_asap = input(true, title="No EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")useemafilter_asap = input(false, title="Use EMA Filter", inline="1", group="EMA Filter (Enter ASAP)")ema_length_asap = input(defval=15, minval=1, title="EMA Length", group="EMA Filter (Enter ASAP)")emasrc_asap = input(close, title="EMA Source", group="EMA Filter (Enter ASAP)")ema_asap = ema(emasrc_asap, ema_length_asap)//plot(ema_asap, "EMA (Enter ASAP)", style=plot.style_linebr, color=#cad850, linewidth=2)plot(useemafilter_asap ? ema_asap : na, "EMA (Enter ASAP)", style=plot.style_linebr, color=#cad850, linewidth=2)//------------------------------------------------------------------------------  // EMA Filter (Wait To Enter)noemafilter = input(true, title="No EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")useemafilter = input(false, title="Use EMA Filter", inline="1", group="EMA Filter (Wait To Enter)")ema_length = input(defval=15, minval=1, title="EMA Length", group="EMA Filter (Wait To Enter)")emasrc = input(close, title="EMA Source", group="EMA Filter (Wait To Enter)")ema = ema(emasrc, ema_length)//plot(ema, "EMA (Wait To Enter)", style=plot.style_linebr, color=#cad850, linewidth=2)plot(useemafilter ? ema : na, "EMA (Wait To Enter)", style=plot.style_linebr, color=#cad850, linewidth=2)//------------------------------------------------------------------------------  // CMF Filter (Enter ASAP)nocmffilter_asap = input(true, title="No CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")usecmffilter_asap = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Enter ASAP)")mflength_asap = input(title="CMF length", group="CMF Filter (Enter ASAP)", type=input.integer, defval=20)ad_asap = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volumemf_asap = sum(ad_asap, mflength_asap) / sum(volume, mflength_asap)//------------------------------------------------------------------------------  // CMF Filter (Wait To Enter)nocmffilter = input(true, title="No CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")usecmffilter = input(false, title="Use CMF Filter", inline="1", group="CMF Filter (Wait To Enter)")mflength = input(title="CMF length", group="CMF Filter (Wait To Enter)", type=input.integer, defval=20)ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volumemf = sum(ad, mflength) / sum(volume, mflength)//------------------------------------------------------------------------------  // EMA For Cross Over Open Line Stop Lossopenlineclose = input(false, title='Exit When Stop Loss EMA Crosses Open Line', group="Open Line As Stop Loss")stop_ema_length = input(defval=15, minval=1, title="EMA Length", group="Open Line As Stop Loss")stop_emasrc = input(close, title="EMA Source", group="Open Line As Stop Loss")stop_ema = ema(stop_emasrc, stop_ema_length)//plot(stop_ema, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)plot(openlineclose ? stop_ema : na, "EMA - Wait To Enter", style=plot.style_linebr, color=#2962ff, linewidth=1)pricecrossup = crossover(stop_ema, OpenPA)pricecrossdown = crossunder(stop_ema, OpenPA)//------------------------------------------------------------------------------  // Stop Loss & Take Profit % Basedenablesltp = input(false, title='Enable Stop Loss & Take Profit', group="% Stop Loss & Take Profit")stopTick = input(2.0, title='Stop Loss %', group="% Stop Loss & Take Profit", type=input.float, step=0.1) / 100takeTick = input(4.0, title='Take Profit %', group="% Stop Loss & Take Profit", type=input.float, step=0.1) / 100longStop = strategy.position_avg_price * (1 - stopTick)shortStop = strategy.position_avg_price * (1 + stopTick)shortTake = strategy.position_avg_price * (1 - takeTick)longTake = strategy.position_avg_price * (1 + takeTick)plot(strategy.position_size > 0 and enablesltp ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Stop Loss")plot(strategy.position_size < 0 and enablesltp ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Stop Loss")plot(strategy.position_size > 0 and enablesltp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")plot(strategy.position_size < 0 and enablesltp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")//------------------------------------------------------------------------------  // Alert messagesmessage_enterlong  = input("", title="Long Entry message", group="Alert Messages")message_entershort = input("", title="Short Entry message", group="Alert Messages")message_closelong = input("", title="Close Long message", group="Alert Messages")message_closeshort = input("", title="Close Short message", group="Alert Messages")//------------------------------------------------------------------------------  // Strategy Execution//------------------------------------------------------------------------------  // Entry Alerts - No EMA or CMFif entrycondition > OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if entrycondition < OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    // Entry Alerts (Wait To Enter) - No EMA or CMFif emacrossup and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if emacrossdown and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    //------------------------------------------------------------------------------  // Contrarian - Entry Alerts - No EMA or CMFif entrycondition > OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if entrycondition < OpenPA and time_cond and firsttradetimetobuy and noemafilter_asap and nocmffilter_asap and enterasap and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    // Contrarian - Entry Alerts (Wait To Enter) - No EMA or CMFif emacrossup and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if emacrossdown and time_cond and timetobuy and noemafilter and nocmffilter and waittoenter and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    //------------------------------------------------------------------------------  // Entry Alerts - Use EMA but No CMFif entrycondition > OpenPA and close > ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if entrycondition < OpenPA and close < ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)// Entry Alerts (Wait To Enter)  - Use EMA but No CMFif emacrossup and close > ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if emacrossdown and close < ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    //------------------------------------------------------------------------------  // Contrarian - Entry Alerts - Use EMA but No CMFif entrycondition > OpenPA and close > ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if entrycondition < OpenPA and close < ema_asap and time_cond and firsttradetimetobuy and useemafilter_asap and nocmffilter_asap and enterasap and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)// Contrarian - Entry Alerts (Wait To Enter)  - Use EMA but No CMFif emacrossup and close > ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if emacrossdown and close < ema and time_cond and timetobuy and useemafilter and nocmffilter and waittoenter and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    //------------------------------------------------------------------------------  // Entry Alerts - Use CMF but No EMAif entrycondition > OpenPA and mf_asap > 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if entrycondition < OpenPA and mf_asap < 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    // Entry Alerts (Wait To Enter) - Use CMF but No EMAif emacrossup and mf > 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if emacrossdown and mf < 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    //------------------------------------------------------------------------------  // Contrarian - Entry Alerts - Use CMF but No EMAif entrycondition > OpenPA and mf_asap > 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if entrycondition < OpenPA and mf_asap < 0 and time_cond and firsttradetimetobuy and noemafilter_asap and usecmffilter_asap and enterasap and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    // Contrarian - Entry Alerts (Wait To Enter) - Use CMF but No EMAif emacrossup and mf > 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if emacrossdown and mf < 0 and time_cond and timetobuy and noemafilter and usecmffilter and waittoenter and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    //------------------------------------------------------------------------------  // Entry Alerts - Use EMA and CMFif entrycondition > OpenPA and close > ema_asap and mf_asap > 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if entrycondition < OpenPA and close < ema_asap and mf_asap < 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    // Entry Alerts (Wait To Enter) - Use EMA and CMFif emacrossup and close > ema and mf > 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and nocontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    if emacrossdown and close < ema and mf < 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and nocontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    //------------------------------------------------------------------------------  // Contrarian - Entry Alerts - Use EMA and CMFif entrycondition > OpenPA and close > ema_asap and mf_asap > 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if entrycondition < OpenPA and close < ema_asap and mf_asap < 0 and time_cond and firsttradetimetobuy and useemafilter_asap and usecmffilter_asap and enterasap and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    // Contrarian - Entry Alerts (Wait To Enter) - Use EMA and CMFif emacrossup and close > ema and mf > 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and usecontrarian    strategy.entry("Short", strategy.short, alert_message = message_entershort)    if emacrossdown and close < ema and mf < 0 and time_cond and timetobuy and useemafilter and usecmffilter and waittoenter and usecontrarian    strategy.entry("Long", strategy.long, alert_message = message_enterlong)    //------------------------------------------------------------------------------  // Hours exitsif strategy.position_size > 0 and timetoclose and enableclose     strategy.close_all(alert_message = message_closelong)if strategy.position_size < 0 and timetoclose and enableclose    strategy.close_all(alert_message = message_closeshort)    //------------------------------------------------------------------------------  // Open Line exitsif strategy.position_size > 0 and pricecrossdown and openlineclose    strategy.close_all(alert_message = message_closelong)if strategy.position_size < 0 and pricecrossup and openlineclose    strategy.close_all(alert_message = message_closeshort)//------------------------------------------------------------------------------      // % TP and SL exits    if strategy.position_size > 0 and enablesltp and time_cond    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)if strategy.position_size < 0 and enablesltp and time_cond    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)