Greedy Strategy

Definition

The Greedy Strategy opens an initial order if there is a gap between current open and the high or low of the previous bar. If open is greater than previous high, strategy goes long, if open is below the low of the previous bar, it opens a short position. After a position is opened, it will continue filling orders in the same direction as long as the color of the candle is consistent with the open position. If the current position is long, new long orders will be created for every consequent green candle and vice versa. This will proceed until the candle of a different color or until the limit of filled orders for a day is reached. 

The limit can be changed in the settings by editing the Max Intraday Filled Orders value. The Tp and Sl settings allow you to set the Stop Loss and Take Profit. The value represents the number of minticks above/below the position price where the TP and SL will be located.

Calculations

Pine Script
//@version=4
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, XQty, lmP, nav, "TPSL",  strategy.oca.reduce, "TPSL", when=  not revCond and XQty > 0)
strategy.order("SL", strategy.position_size < 0, 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)

Summary

The Greedy Strategy was created to take advantage of gaps in either direction. It then accelerates into those gaps by playing momentum to the upside or downside. The strategy opens an initial order if there is a gap between the current open and the high or low of the previous bar. If open is greater than previous high, strategy goes long and if open is below the low of the previous bar, it opens a short position. After a position is opened, it will continue filling orders in the same direction as long as the color of the candle is consistent with the open position.

홈으로 스탁 스크리너 포렉스 스크리너 크립토 스크리너 이코노믹 캘린더 사용안내 차트 특징 프라이싱 프렌드 리퍼하기 하우스룰(내부규정) 헬프 센터 웹사이트 & 브로커 솔루션 위젯 차팅 솔루션 라이트웨이트 차팅 라이브러리 블로그 & 뉴스 트위터
프로화일 프로화일설정 계정 및 빌링 리퍼드 프렌즈 코인 나의 서포트 티켓 헬프 센터 공개아이디어 팔로어 팔로잉 비밀메시지 채팅 로그아웃