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.
AutoView, a Chrome Extension that allows for trade automation using TradingView alerts.
1Broker, used to automate your trades on , stocks, forex, indices and more...
Since: 04/01/2016 05:01:00
Net Profit = 170 pips
Link for tracked statistics here:
//@version=2 strategy("HeikenAshi", 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) c = security(data, res, close) h = security(data, res, low) l = security(data, res, high) long = c > o short = c < o last_long = long ? time : nz(last_long) last_short = short ? time : nz(last_short) 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 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 :)
Hope that helps and makes sense, apologies for the delayed response.
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!
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.