YouTube Video about this script and setup: http://bit.ly/1S48a7z
This script contains 2 things people have been asking for, multiple time frames and of course, a trailing stop that can be both back tested and setup for alerts.
This strategy itself seems to perform better without the use of the Trailing Stop, so play around and monitor it before actually trying to trade it live.
View all the trades being tracked in a Google Sheets here: http://bit.ly/1nI65Bj
To learn more about back testing strategies, automation and AutoView join our free slack group via http://slack.crypto.pink/
This requires 4 alerts, so you are going to have to upgrade to PRO. It'd be greatly appreciated if you signed up using our referral link.
//@version=2 strategy("Public TS - FX", shorttitle="Strategy", overlay=false, default_qty_value=100) ts = input(5, "Trailing Stop") / 10000 //Heiken Ashi Candles Factor = 3 Pd = 7 isHA = input(true, "HA Candles", bool) data = isHA ? heikenashi(tickerid) : tickerid r1 = input("3", "Resolution", resolution) r2 = input("5", "Resolution", resolution) r3 = input("15", "Resolution", resolution) r4 = input("30", "Resolution", resolution) o1 = security(data, r1, open) c1= security(data, r1, close) o2 = security(data, r2, open) c2 = security(data, r2, close) o3 = security(data, r3, open) c3 = security(data, r3, close) o4 = security(data, r4, open) c4 = security(data, r4, close) long = o4 < c4 and o3 < c3 and o2 < c2 and o1 < c1 short = o4 > c4 and o3 > c3 and o2 > c2 and o1 > c1 last_long = long ? time : nz(last_long) last_short = short ? time : nz(last_short) in_long = last_long > last_short in_short = last_short > last_long long_signal = crossover(last_long, last_short) short_signal = crossover(last_short, last_long) last_open_long = long ? open : nz(last_open_long) last_open_short = short ? open : nz(last_open_short) last_high = not in_long ? na : in_long and (na(last_high) or high > nz(last_high)) ? high : nz(last_high) last_low = not in_short ? na : in_short and (na(last_low) or low < nz(last_low)) ? low : nz(last_low) long_ts = not na(last_high) and close <= (last_high - ts) short_ts = not na(last_low) and close >= (last_low + ts) strategy.entry("Long", strategy.long, when=long_signal) strategy.entry("Short", strategy.short, when=short_signal) strategy.close("Long", when=long_ts) strategy.close("Short", when=short_ts) price = close noleverage = price / 100 leverage = 10 // noleverage * 4 TP = input(0) * leverage SL = input(42, 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)
Here is the description: «yes its Heikin Ashi Close price which is calculatet by OHLC/4 of current bar. TradingView recalculate this price at close of the 180mn Heikin Ashi bar. Thats why its repainting».
Please pinpoint what language and thing should I learn more.
In line 18 - 25, when I call the Heiken Ashi candle, I call the previous candle that has already completed.
I am going to load this chart and run it while I'm at work, as it's been awhile since I've written anything with HA. But I'm pretty sure that this uses the previous HA candle avoiding all repainting.