Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, 7th_zorro), 893 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 7 1 2 3 4 5 6 7
Pre-Market Volatility #426885
07/31/13 10:45
07/31/13 10:45
Joined: Jul 2013
Posts: 75
R
royal Offline OP
Junior Member
royal  Offline OP
Junior Member
R

Joined: Jul 2013
Posts: 75
Hi all!
I am trying to implement this strategy for the FDax with Zorro
FDax Pre-Market System

(I'm afraid it is only in german :()

Here's my script so far:

Code:
function run()
{
	BarPeriod = 60;
	set(TICKS|LOGFILE);		

	int TakeProfit1 = 15;
	int TakeProfit2 = 20;
	int TakeProfit3 = 25;
	int StopLoss1 = 35;
	int StopLoss2 = 30;
	int StopLoss3 = 25;
			
		if (hour() >= 8 && hour() < 9){

			if (price() >= (priceOpen() + 15)){
				
				TakeProfit = TakeProfit1;
				Stop = StopLoss1;				
				enterShort();
			}

			if (price() <= (priceOpen() - 15)){
			
				TakeProfit = TakeProfit1;
				Stop = StopLoss1;
				enterLong();			

			if (price() >= (priceOpen() + 20)){
			
				TakeProfit = TakeProfit2;
				Stop = StopLoss2;				
				enterShort();
			}

			if (price() <= (priceOpen() - 20)){
			
				TakeProfit = TakeProfit2;
				Stop = StopLoss2;
				enterLong();
			}

			if (price() >= (priceOpen() + 25)){
			
				TakeProfit = TakeProfit3;
				Stop = StopLoss3;				
				enterShort();
			}

			if (price() <= (priceOpen() - 25)){
			
				TakeProfit = TakeProfit3;
				Stop = StopLoss3;
				enterLong();
			}
		}
	} 
}



When I look in the Logfile I see that all trades are entered a the same Price, so something must be wrong with my "if (price() >= (priceOpen() + x))" conditions :\
I think it's just a small error, but nevertheless I can't find it.
Hopefully someone can help me and thanks in advance for any advice laugh

Re: Pre-Market Volatility [Re: royal] #426888
07/31/13 10:56
07/31/13 10:56
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
I think you need to add * PIP .

if (price() >= (priceOpen() + 15 * PIP))

Re: Pre-Market Volatility [Re: Sundance] #426890
07/31/13 10:58
07/31/13 10:58
Joined: Jul 2013
Posts: 75
R
royal Offline OP
Junior Member
royal  Offline OP
Junior Member
R

Joined: Jul 2013
Posts: 75
I have tried this already, with the same results frown

Re: Pre-Market Volatility [Re: royal] #426892
07/31/13 11:04
07/31/13 11:04

A
acidburn
Unregistered
acidburn
Unregistered
A



Sundance is right!

Also... are you sure that you want to compare the mean price of the bar (price()) and the open price? What happens if you use priceClose() instead of price()?

Re: Pre-Market Volatility [Re: royal] #426893
07/31/13 11:04
07/31/13 11:04
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
Than add some brackets?

if (price() >= (priceOpen() + (15 * PIP) ))

Re: Pre-Market Volatility [Re: Sundance] #426895
07/31/13 11:13
07/31/13 11:13
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
Oh. Also your stops and take profits need the * PIP .

Re: Pre-Market Volatility [Re: Sundance] #426896
07/31/13 11:17
07/31/13 11:17
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
When i remember right. When you set BarPeriod to 60. Zorro will only run your script every 60 minutes. Within those 60 minutes price can move large distances. So that it is no problem to move far away from your 25 pips. So when Zorro checks 60 minutes later there can be three if clauses fullfilled...

@acid: can you confirm this?

Last edited by Sundance; 07/31/13 11:18.
Re: Pre-Market Volatility [Re: Sundance] #426897
07/31/13 11:18
07/31/13 11:18
Joined: Jul 2013
Posts: 75
R
royal Offline OP
Junior Member
royal  Offline OP
Junior Member
R

Joined: Jul 2013
Posts: 75
The Logfile shows Trades like this:
[GER30::L3400] Long 1@4440 Risk 37 at 08:00
[GER30::L3400] Stop 1@4405: -36.83 at 08:24
[GER30::L3400] Long 1@4440 Risk 32 at 08:00
[GER30::L3400] Stop 1@4410: -31.83 at 08:24
[GER30::L3400] Long 1@4440 Risk 27 at 08:00
[GER30::L3400] Stop 1@4415: -26.83 at 08:23

so the Stoploss works correctly, but all 3 trades are entered at 4440. They should be entered in 5 pips steps. So if open price at 8 o'clock is 4000 the first short should be entered at 4015, the second at 4020 and the third at 4025.
I hope this makes the entry a bit clearer.


Quote:
When i remember right. When you set BarPeriod to 60. Zorro will only run your script every 60 minutes.


I thougt with set(TICKS) this is not the behavior?

Last edited by royal; 07/31/13 11:20.
Re: Pre-Market Volatility [Re: Sundance] #426898
07/31/13 11:22
07/31/13 11:22
Joined: May 2013
Posts: 627
Bonn
Sundance Offline
User
Sundance  Offline
User

Joined: May 2013
Posts: 627
Bonn
Okay found it:

The run function is called once per bar, and trade exit conditions are tested (at least) once per bar regardless of the TimeFrame setting. For this reason, using a different TimeFrame is not fully equivalent to setting Barperiod to the same time frame. Trading algorithms will behave slightly different, even when the resulting time frame (BarPeriod * TimeFrame) is the same.

PS: Haven't seen your SET(TICKS)

Last edited by Sundance; 07/31/13 11:23.
Re: Pre-Market Volatility [Re: Sundance] #426899
07/31/13 11:28
07/31/13 11:28

A
acidburn
Unregistered
acidburn
Unregistered
A



Originally Posted By: Sundance
When i remember right. When you set BarPeriod to 60. Zorro will only run your script every 60 minutes. Within those 60 minutes price can move large distances. So that it is no problem to move far away from your 25 pips. So when Zorro checks 60 minutes later there can be three if clauses fullfilled...

@acid: can you confirm this?


In general, yes. But, I haven't checked the strategy, maybe that is desirable? If not, then replacing multiple if's with one if with multiple "else if" clauses would fix it.

Page 1 of 7 1 2 3 4 5 6 7

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