P2-V2 - BTC Strategy

This is an early release as I have yet to go through the full automation aspect, however, I know some of you would like to see where it's at.
If you'd like to learn how to automate a full strategy using the Chrome Extension, go to the linked idea for a eurusd setup.
//version=2
study("P2-V2", shorttitle="Alerts", overlay=false)
//Heiken Ashi Candles
Factor = 3
Pd = 7
isHA = input(true, "HA Candles", bool)
data = isHA ? heikenashi(tickerid) : tickerid
o = security(data, period, open)
h = security(data, period, high)
l = security(data, period, low)
c = security(data, period, close)
//Triple EMA
temaLength = input(15, minval=1)
ema1 = ema(c, temaLength)
ema2 = ema(ema1, temaLength)
ema3 = ema(ema2, temaLength)
tema = 3 * (ema1 - ema2) + ema3
//Moving Average
smaLength = input(7, minval=1)
sma = sma(c, smaLength)
//RSI
src = c
rsiLength = input(4, minval=1, title="Length")
up = rma(max(change(src), 0), rsiLength)
down = rma(-min(change(src), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
rsin= input(9)
sn = 100 - rsin
ln = 0 + rsin
//Strategy
gc = c > o ? 1 : 0
rc = c < o ? 1 : 0
long = crossover(tema[2], sma[2]) and gc[1] == 1 and gc == 1 and rsi > sn
short = crossunder(tema[2], sma[2]) and rc[1] == 1 and rc == 1 and rsi < ln
plot(long, "long", color=green)
plot(short, "short", color=red)
//Strategy
gc = c > o ? 1 : 0
rc = c < o ? 1 : 0
long = crossover(tema[2], sma[2]) and gc[1] == 1 and gc == 1 and rsi > sn
short = crossunder(tema[2], sma[2]) and rc[1] == 1 and rc == 1 and rsi < ln
plot(long, "long", color=green)
plot(short, "short", color=red)
//Strategy
gc = c > o ? 1 : 0
rc = c < o ? 1 : 0
long = crossover(tema[2], sma[2]) and gc[1] == 1 and gc == 1 and rsi > sn
short = crossunder(tema[2], sma[2]) and rc[1] == 1 and rc == 1 and rsi < ln
plot(long, "long", color=green)
plot(short, "short", color=red)
Since: 08/12/2014 07:00:00
Net Profit = $644.58 in BTC value
Link for tracked statistics here:
bit.ly/1SMvGVu
On line 11 - 14 you'll see this...
o = security(data, period, open)
h = security(data, period, high)
l = security(data, period, low)
c = security(data, period, close)
we need to actually use the previous candle to avoid repainting, so just add a 1 candle look back.
square brackets 1 after the words "open, high, low, close"
TV does not let me paste the brackets, but you can see on line 12-16 of this strategy here what is needed.
![[AutoView] Automate it -Heiken Ashi, No pyramiding or repainting](https://s3.tradingview.com/w/wEZWjpGY_mid.png)
Hope this makes sense. Good luck.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.