Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 712 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
andrew oliveira - supertrend #456421
11/22/15 11:41
11/22/15 11:41
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline OP
Senior Member
nanotir  Offline OP
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
Hi

I dont know if some of you is familiar with that indicador.
Does it work for you?
Can you post the script here?

I dont want to spend time coding it or playing with it if someone already tried to and it is workless.

Re: andrew oliveira - supertrend [Re: nanotir] #456956
12/17/15 03:10
12/17/15 03:10
Joined: Mar 2015
Posts: 336
Rogaland
N
nanotir Offline OP
Senior Member
nanotir  Offline OP
Senior Member
N

Joined: Mar 2015
Posts: 336
Rogaland
well... here is the code for it

Quote:
function run()
{
set(PLOTNOW);

StartDate = 20150101;
LookBack = 500;
BarPeriod = 30;
NumYears = 1;


PlotBars = 1000;

vars Price= series(price());

int factor =3;
int Period = 10;

TimeFrame = 1;

vars UpBand = series();
vars DnBand = series();
UpBand[0] = (priceHigh()+priceLow())/2 + factor*ATR(Period);
DnBand[0] = (priceHigh()+priceLow())/2 - factor*ATR(Period);

vars ST = series();
ST[0] = 0;

vars Direction = series();
Direction[0] = 1;//just to initialize

vars PriceC = series(priceClose());

// Begin Direction calculation
if ( PriceC[0] > UpBand[1] )
Direction[0] = 1;
else
if ( PriceC[0] < DnBand[1] )
Direction[0] = -1;
else
Direction[0] = Direction[1];
// End Direction calculation

// Begin SuperTrend calculation
if ( Direction[0] == 1 )
{
if ( DnBand[1] > DnBand[0] )
DnBand[0] = DnBand[1];

ST[0] = DnBand[0];
plot("ST",ST[0],0,GREEN);

}
else
if ( Direction[0] == -1 )
{
if ( UpBand[1] < UpBand[0] )
UpBand[0] = UpBand[1];

ST[0] = UpBand[0];
plot("ST2",ST[0],0,RED);
}
// End SuperTrend calculation


plot("ST3",ST[0],0,DARKGREEN);


}

Re: andrew oliveira - supertrend [Re: nanotir] #463625
12/18/16 01:10
12/18/16 01:10
Joined: Nov 2016
Posts: 5
M
mey Offline
Newbie
mey  Offline
Newbie
M

Joined: Nov 2016
Posts: 5
Hi Nanitek,

thanks a lot for sharing this code.
I would like to use it in function run() by call-by reference function call and also plot it from here.
But I fail miserably to declare the function.
The handing-over parameters from new function “Supertrend” should be “ST and color flag”.
In function run() I only receive the data by the call and I don’t know how the statement should like like, I always receive pointer errors.

function definition:
var Supertrend (vars ST, vars color)

call function in function run():
vars Super = series();
vars ST = series();
vars Color = series();
ST = series(Supertrend(Super[0]),Color());


Trading conditions (simplified):
if (priceClose() > ST)
enterLong();
else
enterShort();

Can you or somebody else help me as lite-C beginner?

Thanks again in advance.


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