CryptoRox

[AutoView] Automate it -Heiken Ashi, No pyramiding or repainting

Alerts on Heiken Ashi candles using a resolution and no repainting. This script was initially just a test script that lead to solving a few issues around repainting, and pyramiding.

Building scripts for automation has been tricky due to us being forced to use pyramiding and of course, finding all the things that caused charts to repaint when live trading vs back testing. Over the course of all these builds, we've successfully found ways around all the issues. So here they are, with an explanation.

Heiken Ashi candles, they used to cause repainting depending on how they were used, and of course, the alerts were not consistent and/or firing when they should've. To solve this, we added a resolution, and only use the previous HA candle in our strategy. This eliminates all repainting as the candle is complete and we're not trying to predict the future. This simultaneously eliminated all alert issues as long as you use "crossing down on condition".

No pyramiding, this is something that is built right into strategies and back testing. However, getting a study to do it for alerts and automation via AutoView was tricky. The solution: we get the time of the last long and the last short, down to the second. If the last long was more recent then the last short, then we will not open another long. It's actually a simple, almost face palm solution that should not have likely taken this long to figure out.

In playing around with both of these new solutions, I found that by simply acting on the previous 3 hour Heiken Ashi close, this strategy performs well across multiple markets. The only thing that you really need to play with is, where you'll take profit and cut your losses.

In this strategy you'll see that each order can potentially margin call on x200, or double according to my take profit and stop loss. It lacks some consistency and the drawdown is pretty heavy. Change the TP to 40 and SL to 20, suddenly you see a more consistent and steady incline. Take a 20 pip loss or a 40 pip win is much nicer in my books compared to tp 60 and sl 60.

Anyways, I hope these new solutions help the community in both making some extra cash and improving your own personal strategies.

As per the usual, feel free to contact me on here, or request an invite to our free private slack group by sending me your email.

Referral Tax:
AutoView, a Chrome Extension that allows for trade automation using TradingView alerts.
http://bit.ly/1OjeQr7

1Broker, used to automate your trades on commodities , stocks, forex, indices and more...
https://1broker.com/m/r.php?i=3228
Comment: Here is the alert script
HeikenAshi[1]
Comment: All orders are now being tracked in a Google Sheet for public viewing.

Since: 04/01/2016 05:01:00
Net Profit = 170 pips

Link for tracked statistics here:
http://bit.ly/1W48xxM
Remove from Favorite Scripts Add to Favorite Scripts
//@version=2
strategy("HeikenAshi[1]", title="Strategy", overlay=false, default_qty_value=100)

//Heiken Ashi Candles
Factor = 3
Pd = 7
isHA = input(true, "HA Candles", bool)

data = isHA ? heikenashi(tickerid) : tickerid
res = input("180", "Resolution", resolution)

o = security(data, res, open[1])
c = security(data, res, close[1])
h = security(data, res, low[1])
l = security(data, res, high[1])

long = c > o
short = c < o

last_long = long ? time : nz(last_long[1])
last_short = short ? time : nz(last_short[1])

long_signal = crossover(last_long, last_short)
short_signal = crossover(last_short, last_long)

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

TP = input(60) * 10 //+ 2
SL = input(60) * 10 //- 2
TS = input(0) * 10
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)
I want to create a strategy where If heikin ashi candle closes say above supertrend, BUY at the market immediately ( not on next heikin ashi open) and close all shorts. Can anyone help me with the code? I have one written but it doesnt quite execute at the instant when heikin ashi closes at a certain level. If i backtest it, it shows trade orders which change values and its hard to replicate that in real trading.
Reply
How about h and l?
Reply
Thank you so much for this beautiful information.

Sincerely,

Kevin Manrrique
Reply
Is there any automating trading for MT4 and also I came across this page because I trying top fix a repainting issue on a strategy. Is there any way I can stop this repeating? Anyone Please! I'm trying to fix this strategy all I need to do now is fix the repainting issue and then I can share it to everyone!
Reply
CryptoRox PRO TradeWithConfidence
Unfortunately the only current integration is OKcoin and 1broker. We have looked into MT4, and though we hope to 1 day, it's a long way off.

Depending on the reason for your strategy repainting, the fix is easy. You can send me a pm and I can walk you through it.
Reply
Hello and thanks for your dedication!
I am having an issue with setting up my alerts to use with autoview, I understood I have to create an alert as clicking on the "clock" on the right side of the chart and hitting the plus sign, right? Mine tells me I can't create an alert for this type of chart, mine is setup as Heikin Ashi, 15 min .... Any help would be appreciated :)
Reply
Krsnadeva Krsnadeva
I was able to create the alert changing to regular candels, now .... is there a way to triger an alert on strategy.exit? since mine uses a TS of 5 pips and 1broker dont have TS.

tks again
Reply
CryptoRox PRO Krsnadeva
Sadly 1 broker does not have TS compatibility. There is going to be an AutoView update that'll allow it soon, but there's still an issue with TS on TradingView. Trailing Stops require tick by tick data, so using them in a back test will give inaccurate results. To use a Trailing Stop, you need to leave your chart open, and forward test (let it run) to see where a TS would actually trigger.
Hope that helps and makes sense, apologies for the delayed response.
Reply
Krsnadeva CryptoRox
Thank you! Yeah it makes sense ... So I am reworking it without the TS.

I already got the alerts to trigger the positions on 1broker, but it seem to give me a fixed TP/SL of 30 pips, actually 3, (USDJPY), I tried setting to sl=20 and sl=200, still same, Eventually I'll figure it out :)

And thanks again for sharing your expertise with us mere mortals!
Reply
CryptoRox PRO Krsnadeva
Thanks for the generous comments.
On USDJPY the SL might need you to keep adding some 0's to it as the price is so much different from the usual forex markets, or atleast that's my assumption lol. Just play around on a low leverage setup so you don't throw money away during your testing/setup phase.
Keep me posted on this.
Reply
United States
United Kingdom
India
Deutschland
France
España
Italia
Polska
Türkiye
Россия
Brasil
Indonesia
Malaysia
Việt Nam
日本
한국
简体
繁體
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 Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Priority Support Contact Support Ideas Published Followers Following Private Messages Chat Sign Out