Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by jcl. 07/22/26 06:42
ZorroGPT
by TipmyPip. 07/21/26 17:54
New Zorro version 3.11
by jcl. 07/21/26 13:42
Lapsa's very own thread
by Lapsa. 07/18/26 13:40
Purchase A8 full licence version
by ukgamer. 07/17/26 05:52
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (TipmyPip, madpower2000), 1,532 guests, and 18 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Ephraim, Student_64151
19223 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help entering trades #441320
05/19/14 08:32
05/19/14 08:32
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Hi all,

I am new to programming and am hoping for some advice. Currently, I am just getting to know Zorro and lite-C and tried to run the following simple script based on Bill Williams' fractal indicator (it is supposed to open a long(short) trade when price breaks the high(low) fractal:

function run()
{

var FH = FractalHigh(series(price()),5);
var FL = FractalLow(series(price()), 5);

if (crossOver(series(price()), FH))
enterLong();
else if (crossUnder(series(price()), FL))
enterShort();

}

When I test this, no trades are opened. Can anyone explain why? Is it because I am trying to open a trade when a series crosses a certain price (the current fractal) rather than another series?

Any help greatly appreciated.

Re: Help entering trades [Re: boatman] #441325
05/19/14 11:31
05/19/14 11:31
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
A price can not cross over its fractal.

The Fractal indicator is either zero when the period has no peak, or it is the peak value. Because the price can not be higher than its own peak in the last 5 bars, it will never cross the fractal. The indicator is not suited for crossing anyway because it's no line, but just points.

Re: Help entering trades [Re: jcl] #441351
05/20/14 03:24
05/20/14 03:24
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thanks for clarifying, JCL. I don't think I totally understand though. Williams' fractal indicator isn't necessarily the most recent peak, it is the most recent high with at least two lower candles both before and after. In some cases, this will correspond to the most recent peak, but not all.

Suppose I wanted to buy when price moved through the most recent fractal (as opposed to the most recent peak). Could I do this by passing the value of the most recent fractal to a pending buy order?

Re: Help entering trades [Re: boatman] #441352
05/20/14 03:55
05/20/14 03:55
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I came up with this script to enter pending orders at the most recent high and low fractals, and to only have one open trade at any one time. Is this script correct? Thanks for your patience, I am very new to coding.

function run()
{

var FH = FractalHigh(series(price()),5);
var FL = FractalLow(series(price()), 5);

Stop = 2*ATR(60);
TakeProfit = 2*ATR(60);

if (NumOpenLong < 1) enterLong(0,FH);
else if (NumOpenShort < 1) enterShort(0,FL);

}

Re: Help entering trades [Re: boatman] #441360
05/20/14 07:30
05/20/14 07:30
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
No, I think this script is also not correct. Keep in mind that "Fractal" is 0 when there is no peak in the middle. Otherwise it's in fact the most recent peak. With no peak you're entering at 0, which means you enter at market.

I am not sure what you want to do and for what you're using the "Fractal" indicator. If you want to enter a trade at a peak level, use the LL and HH indicators instead. If you're using Fractal for a peak, you must check if it's zero and not enter a trade in that case.

The best way to see how your script trades is just plotting the used indicators in a window and check how they affect the trades.

Re: Help entering trades [Re: jcl] #441375
05/20/14 12:58
05/20/14 12:58
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thanks for your response. I'm not really trying to do anything special with the Fractal indicator, just using it to familiarise myself with Zorro and programming in general. I have used Bill Williams' stuff in the past, so thought it made sense to start with something I know.

Attached is a plot as you suggested, zoomed in so that you can see a couple of days in detail. It plots just the upper fractal. It looks to me like the value of the fractal alternates between zero and approximately 1.767. Why would it keep going back to that value, rather than updating as a new upper fractal is formed?

Attached Files
Upper Fractal.png (13 downloads)
Re: Help entering trades [Re: boatman] #441380
05/20/14 15:46
05/20/14 15:46
Joined: Jul 2000
Posts: 28,126
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,126
Frankfurt
The answer to "why" is always "because it's made this way". I have not invented that indicator, so I guess you must ask Bill Williams.

If you want a line connecting the fractal peaks, you can for instance use a static variable and set it only when Fractal returns nonzero. But for just testing crossover or similar signals, other indicators that really return a line are probably better suited.

Re: Help entering trades [Re: jcl] #441387
05/21/14 02:55
05/21/14 02:55
Joined: Sep 2013
Posts: 504
California
G
GPEngine Offline
User
GPEngine  Offline
User
G

Joined: Sep 2013
Posts: 504
California
boatman, the underlying series price() varies in the range 1.763 to 1.773.
In the chart below that, where you plot your indicator, the y-axis has range 0 to 2.0. There is no way your eye can detect that variation. I bet the peak heights are actually different.

Hint: Try printing the values.
printf("\nFH=%f", FH);

Re: Help entering trades [Re: GPEngine] #441406
05/21/14 13:11
05/21/14 13:11
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline OP
Senior Member
boatman  Offline OP
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
Thanks guys, really appreciate the responses. GPEngine - you were absolutely correct, the peaks were different.


Moderated by  Petra 

Gamestudio download | 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