Strategy example

Breakout Strategy v1

Readonly source from tests/EasyLanguage/dorian-draper-learning, generated Pine Script v6, and an expiry-free example EX5.

Original EasyLanguage

  1. {-------------------------------------------------------------------
  2. Breakout v1
  3. Description:
  4. - Breakout strategy based on the highest high and lowest low of the last 8 bars
  5. - Uses stop orders to enter the market on breakouts
  6. -------------------------------------------------------------------}
  7. Input:
  8. TrlgBars(8);
  9. Vars:
  10. BuyPx(0),
  11. SellPx(0);
  12. BuyPx = Highest(High, TrlgBars) + .02;
  13. SellPx = Lowest(Low, TrlgBars) - .02;
  14. {Setup entrada}
  15. Buy ("BrkLE") Next Bar at BuyPx Stop;
  16. SellShort ("BrkSE") Next Bar at SellPx Stop;

Generated Pine Script v6

  1. //@version=6
  2. strategy("Breakout_v1", overlay=true)
  3. trlgbars = input.float(8.0, "trlgbars")
  4. var float buypx = 0
  5. var float sellpx = 0
  6. __el_call1 = ta.highest(high, int(trlgbars))
  7. __el_call2 = ta.lowest(low, int(trlgbars))
  8. if bar_index >= 7
  9. buypx := __el_call1 + .02
  10. sellpx := __el_call2 - .02
  11. strategy.entry("BrkLE", strategy.long, stop=buypx)
  12. strategy.entry("BrkSE", strategy.short, stop=sellpx)

Compiled MetaTrader 5 example

The EX5 uses the original script filename stem and has no PineAnywhere expiration guard.

Download Breakout_v1.ex5
An unexpected error occurred. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.