//@version=5
strategy("Greedy Strategy", pyramiding = 100, calc_on_order_fills=false, overlay=true)
tp = input(10)
sl = input(10)
maxidf = input(title="Max Intraday Filled Orders", defval=5)
strategy.risk.max_intraday_filled_orders(maxidf)
upGap = open > high[1]
dnGap = open < low[1]
dn = strategy.position_size < 0 and open > close
up = strategy.position_size > 0 and open < close
strategy.entry("GapUp", strategy.long, stop = high[1], when = upGap)
strategy.entry("Dn", strategy.short, stop = close, when = dn)
strategy.entry("GapDn", strategy.short, stop = low[1], when = dnGap)
strategy.entry("Up", strategy.long, stop = close, when = up)
strategy.cancel("GapUp", not upGap)
strategy.cancel("GapDn", not dnGap)
strategy.cancel("Up", not up)
strategy.cancel("Dn", not dn)
XQty = strategy.position_size < 0 ? -strategy.position_size : strategy.position_size
dir = strategy.position_size < 0 ? -1 : 1
lmP = strategy.position_avg_price + dir*tp*syminfo.mintick
slP = strategy.position_avg_price - dir*sl*syminfo.mintick
float nav = na
revCond = strategy.position_size > 0 ? dnGap : (strategy.position_size < 0 ? upGap : false),
strategy.order("TP", strategy.position_size < 0 ? strategy.long : strategy.short, XQty, lmP, nav, "TPSL", strategy.oca.reduce, "TPSL", when= not revCond and XQty > 0)
strategy.order("SL", strategy.position_size < 0 ? strategy.long : strategy.short, XQty, nav, slP, "TPSL", strategy.oca.reduce, "TPSL", when= not revCond and XQty > 0)
strategy.cancel("TP", XQty == 0 or revCond)
strategy.cancel("SL", XQty == 0 or revCond)
//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)
Overview
Greedy Strategy places long entries when price gaps above the previous high and short entries on downward gaps below the previous low. Positions are managed with take-profit and stop-loss orders calculated in minimum tick increments from the average entry price. Key settings allow customization of take-profit distance, stop-loss distance, and maximum daily filled orders. It plots entries directly on the price chart.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
tp
int
10
tp
sl
int
10
sl
Max Intraday Filled Orders
int
5
maxidf
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.
This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr
Calculates standard Bollinger Bands and identifies band expansion breakouts where upper and lower bands move in opposite directions. It enters long positions when price breaks above the upper band with a high candle body percentage, and enters short positions
This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos
STRG-HOLP is a trading strategy that identifies High of Low Period (HOLP) and Low of High Period (LOHP) breakout setups. It tracks the lowest low or highest high over a user-defined lookback window. A long trade opens when the close breaks above the high of th
This strategy detects price breakouts above rolling highest highs or below lowest lows over a customizable lookback period. It includes optional volume spike and ATR volatility threshold filters, along with bar confirmation rules. Positions are taken upon conf
This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w