Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=2
- strategy("Binary Option EMA/Stoch Strat - Drew", overlay=true)
- //stoch
- length1 = input(14, minval=1), smoothK = input(1, minval=1), smoothD = input(3, minval=1)
- k = sma(stoch(close, high, low, length1), smoothK)
- d = sma(k, smoothD)
- len = input(4, minval=1, title="Length")
- src = input(high, title="Source")
- out = ema(src, len)
- HIGH = out
- len1 = input(4, minval=1, title="Length")
- src1 = input(low, title="Source")
- out1 = ema(src1, len1)
- LOW = out1
- HL2 = (HIGH+LOW)/2
- len2 = input(21, minval=1, title="Length")
- src2 = input(close, title="Source")
- out2 = ema(src2, len2)
- EMA = out2
- timeframe = input(title="Timeframe", type=integer, minval=1, defval=3)
- x = close < LOW and open < HL2 and close < EMA and d < 50 and k < 50
- y = close > HIGH and open > HL2 and close > EMA and d > 50 and k > 50
- if (x)
- strategy.entry("UP", strategy.long)
- if (y)
- strategy.entry("DOWN", strategy.short)
- // original expiry tie code (doesn't work properly)
- //bars = barssince(strategy.opentrades == 0)
- //strategy.close_all(when=(bars>=timeframe))
- // new expiry time code (still not working)
- opened_order = strategy.position_size[0] != strategy.position_size[1] and strategy.position_size[0] != 0
- bars = barssince(opened_order) + 1
- strategy.close_all(when=(bars>=timeframe))
Advertisement
Add Comment
Please, Sign In to add comment