CryptoRox

P2-V2 - BTC Strategy

2739 12 260
P2-V2 also known as Penner2.0 began with a TEMA and MA cross on Heiken Ashi, a strategy brought to us by a group of crypto traders. Since then we've added a few more indicators and played around with the rules.

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.
Comment: Alert Script:

//@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, sma) and gc == 1 and gc == 1 and rsi > sn
short = crossunder(tema, sma) and rc == 1 and rc == 1 and rsi < ln

plot(long, "long", color=green)
plot(short, "short", color=red)
Comment: The above alert script did not copy/paste properly and is getting an error, to avoid clutter, just replace the bottom section @ //Strategy

//Strategy
gc = c > o ? 1 : 0
rc = c < o ? 1 : 0
long = crossover(tema, sma) and gc == 1 and gc == 1 and rsi > sn
short = crossunder(tema, sma) and rc == 1 and rc == 1 and rsi < ln

plot(long, "long", color=green)
plot(short, "short", color=red)
Comment: Let's try this again...

//Strategy
gc = c > o ? 1 : 0
rc = c < o ? 1 : 0
long = crossover(tema, sma) and gc == 1 and gc == 1 and rsi > sn
short = crossunder(tema, sma) and rc == 1 and rc == 1 and rsi < ln

plot(long, "long", color=green)
plot(short, "short", color=red)
Comment: Apologies for all the updates, not sure why pasting that section in here becomes corrupt, so instead I simply published the alert script here:

P2-V2 - Alerts
Comment: All orders are now being tracked in a Google Sheet for public viewing.

Since: 08/12/2014 07:00:00
Net Profit = $644.58 in BTC value

Link for tracked statistics here:
http://bit.ly/1SMvGVu
Comment: To avoid repainting, this code needs to be adjusted. Results actually improve once the issue is corrected.
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


Hope this makes sense. Good luck.
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
strategy("P2-V2", shorttitle="StrategyP2-V2", overlay=false, pyramiding=10)

//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

//Plots
plot(tema, color=purple)
plot(sma, color=blue)

//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

strategy.entry("long", strategy.long, when=long)
strategy.entry("short", strategy.short, when=short)

price  = close[1]
noleverage = price / 100
leverage = noleverage * 4

TP = input(1000) * leverage
SL = input(35, maxval=200) * leverage
TS = input(0) * leverage
CQ = 100

TPP = (TP > 0) ? TP : na
SLP = (SL > 0) ? SL : na
TSP = (TS > 0) ? TS : na

strategy.exit("Close Long", "long", qty_percent=CQ, profit=TPP, loss=SLP, trail_points=TSP)
strategy.exit("Close Short", "short", qty_percent=CQ, profit=TPP, loss=SLP, trail_points=TSP)
Hi this is very nice!
do you can explain the exact rules how the strategy work?
I "study" the strategy but I don´t see the logic :D
thx and king regards
Reply
BTCUSD3M - OKcoin Futures
Heiken Ashi Candles

Triple EMA
Length 15

Moving Average
Length 7

Relative Strength Index
Length 4
OverSold 9 and OverBought 91

Long Rules
Triple EMA crosses up the MA. The next 2 candles need to be green, and the rsi should be overBought (when the second green candle closes).

Short Rules
Triple EMA crosses down the MA. The next 2 candles need to be red, and the rsi should be OverSold (when the second red candle closes).

In the script, take profit is set to market close at 1,000% and Stop Loss is set to market close at -35%. This is using x20 leverage.
It will automatically close when it's time to open a position in the opposite direction if neither TP or SL are hit.

Things like TP and SL change slightly if you're looking to automate this using Autoview.
+1 Reply
AcerGold CryptoRox
thx!
a question.
Is it possible to add a "start year" for backtesting? example: 2012/XY til today
king regards
Reply
You use strategy function (h = security(data, period, high), l = security(data, period, low), c = security(data, period, close)). It`s like you know the future. At current bar you don`t know the high/low/close. However, when you do a historical backtesting security function knows those values.
In live trading it will repaint, until signal bar closing.
+1 Reply
CryptoRox PRO al.tribun
Sadly, you are correct. I've recently had a few dreams crushed due to repainting :P
However it all works beautifully if you simply call the last candle ;)

//Easter Egg
o = security(data, period, open)
h = security(data, period, high)
l = security(data, period, low)
c = security(data, period, close)

Results on my P2-V2 chart.

Before
http://prntscr.com/9eras6

After
http://prntscr.com/9erahs
http://prntscr.com/9erahs
Reply
CryptoRox PRO CryptoRox
Of course I'd paste the unedited code...

//True Easter Egg
o = security(data, period, open)
h = security(data, period, high)
l = security(data, period, low)
c = security(data, period, close)
Reply
CryptoRox PRO CryptoRox
http://prntscr.com/9erbq9

TradingView is removing the edited section of the code for some reason. Apologies for the multiply reply/posts here.

o p e n
h i g h
l o w
c l o s e
Reply
Thank you for the script, looks tasty!!!
Can you pls post the script for the alerts.

Thank you very much!!!
Reply
Added it to the description above. Let me know if it works.
Reply
roosikas CryptoRox
alert script line 41 does not work
+1 Reply
United States
United Kingdom
India
Deutschland
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia
Malaysia
日本
한국
简体
繁體
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing Priority Support Ideas Published Followers Following Private Messages Chat Sign Out