Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Quad), 454 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
volatility-based trailing stop #445713
09/21/14 13:29
09/21/14 13:29
Joined: Apr 2014
Posts: 45
Germany
webradio Offline OP
Newbie
webradio  Offline OP
Newbie

Joined: Apr 2014
Posts: 45
Germany
I am about to port my ATR-based trailing stop from MT4 to Zorro. I do enjoy programming, but I wonder if a similar source code already exists. At least, I coundn't find it on ta-lib.org and tadoc.org, nor in indicators.c. Sometimes this indicator is called Supertrend. It looks familiar to you, for sure:

Re: volatility-based trailing stop [Re: webradio] #445813
09/25/14 21:36
09/25/14 21:36
Joined: Apr 2014
Posts: 45
Germany
webradio Offline OP
Newbie
webradio  Offline OP
Newbie

Joined: Apr 2014
Posts: 45
Germany
I gave it a try
Code:
function run()
{
	set(PLOTNOW);
	PlotDate = 20140810;
	PlotHeight1 = 900;
	
	vars Top = series(2.0*priceHigh()-priceLow());
	vars Btm = series(2.0*priceLow()-priceHigh());
	var width = 3.0*EMA(series(ATR(2)), 10);
	var center = (priceHigh()+priceLow()+priceClose())/3.0;
	if (priceHigh()>Top[1]) {
		Top[0] = center+width;
	} else {
		Top[0] = min(Top[1], center+width);
	}
	if (priceLow()<Btm[1]) {
		Btm[0] = center-width;
	} else {
		Btm[0] = max(Btm[1], center-width);
	}
	
	plot("Top", Top[0],DOT,GREEN);
	plot("Btm", Btm[0],DOT,RED);
}

example from NinjaTrader
this script
this script, diffeent parameters


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1