Strategy · Pine Script v5 · On the chart

Candlestick Pattern Strategy 1

by geraked

Candlestick Pattern Strategy 1 is a scalping strategy designed for short-term timeframes.

View on GitHub

GitHub stars104on the repository
Pine versionv5runs as is
Lines of code47
Settings1inputs
LicenceMIT
Last update3 years ago29 Oct 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

47 lines of Pine Script v5 from strategies/CP1.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

CP1.pine
// This is a simple strategy based on a candlestick pattern for scalping.
// © 2023 Geraked, Rabist
// Licensed under MIT

// Backtesting result:
//      Symbol:             EURJPY
//      Timeframe:          1 MIN
//      Range:              2023-07-02 — 2023-07-12
//      Percent Profitable: 78.2%
//      Total Trades:       344
//      Profit Factor:      1.482


//@version=5
strategy("Candlestick Pattern Strategy 1", "CP1", overlay=true)

reverse = input.bool(true, "Reverse Signal")

longSignal = close > open and close[1] > open[1] and open[1] < open and close > close[1] and low < low[1] and low < open[1]
longStop = low

shortSignal = close < open and close[1] < open[1] and open[1] > open and close < close[1] and high > high[1] and high > open[1]
shortStop = high

if (longSignal)
    if (not reverse)
        strategy.entry("long", strategy.long)
        inn = strategy.opentrades.entry_price(strategy.opentrades - 1)
        longTp = inn + (inn - longStop)
        strategy.exit("exit", "long", stop=longStop, limit=longTp, comment_loss="Stop long", comment_profit="TP long")
    else
        strategy.entry("short", strategy.short)
        inn = strategy.opentrades.entry_price(strategy.opentrades - 1)
        longTp = inn + (inn - longStop)
        strategy.exit("exit", "short", stop=longTp, limit=longStop, comment_loss="Stop short", comment_profit="TP short")   

if (shortSignal)
    if (not reverse)
        strategy.entry("short", strategy.short)
        inn = strategy.opentrades.entry_price(strategy.opentrades - 1)
        shortTp = inn - (shortStop - inn)
        strategy.exit("exit", "short", stop=shortStop, limit=shortTp, comment_loss="Stop short", comment_profit="TP short")
    else
        strategy.entry("long", strategy.long)
        inn = strategy.opentrades.entry_price(strategy.opentrades - 1)
        shortTp = inn - (shortStop - inn)
        strategy.exit("exit", "long", stop=shortTp, limit=shortStop, comment_loss="Stop long", comment_profit="TP long")

Overview

Candlestick Pattern Strategy 1 evaluates two-bar candlestick price action patterns to generate entry signals directly on the price chart. When a bullish or bearish setup is detected, the strategy executes a position and places automated stop-loss and take-profit exit orders. The stop loss is positioned at the pattern extreme low or high, while the take profit target is calculated to match the risk distance. A simple configuration setting allows traders to reverse entry direction signals for testing counter-trend execution.

Details

Published by

geraked on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Scalping

Markets

Forex

Timeframes

M1-M5

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

backtesting-trading-strategiesexpert-advisorexpert-advisorsforex-botgerakedmetatraderpinescriptrabiststock-markettrading-algorithms

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Reverse Signalbooltruereverse
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

257 stars

This overlay strategy marks short-term turning points on the price chart and enters SPY option-style trades from them. It plots simple moving averages of highs and lows, draws up and down reversal arrows, and colors bars when a short-term extreme coincides wit

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of SPY Options Trading - Alert

DI Engulfing C003

by ruckard
13 stars

This strategy trades bullish and bearish body engulfing patterns on the price chart. It allows longs only when price is above the 200-period exponential moving average and shorts only when price is below it. A long needs three consecutive red candles followed

Strategy v5 Candlestick patternsTrend
Updated 1 year ago · None stated GitHub repository of DI Engulfing C003

Quick Flip Scalper

by TradersPost
218 stars

This strategy executes an opening-range liquidity fade based on the first candle of a session. It qualifies the opening range against the daily ATR to confirm manipulation or liquidity spikes. If qualified, it searches for reversal candlestick patterns, such a

Strategy v6 Sessions & timeCandlestick patterns
Updated 3 months ago · None stated GitHub repository of Quick Flip Scalper
330 stars

Exceeded Candle [Alorse] is a mean-reversion strategy that identifies candlestick engulfing patterns combined with Bollinger Bands filters. It enters a long position when a green candle surpasses the body of the previous red candle while price is below the mid

Strategy v4 Mean reversionCandlestick patterns
Updated 2 months ago · None stated GitHub repository of Exceeded candle [Alorse]
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers