Gamestudio Links
Zorro Links
Newest Posts
New Zorro v1.99.2
by jcl
46 minutes 0 seconds ago
Strategy Development
by AndrewAMD
59 minutes 37 seconds ago
closing profitable trades (stop)
by MINER
Today at 12:47
Next contest?
by jcl
Yesterday at 15:44
advance decline (ADO) code examples?
by 3dgamelight
12/09/18 19:52
Newbie coding question. HELP Please!
by 3dgamelight
12/09/18 16:28
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14
12/08/18 19:10
AUM Magazine
Latest Screens
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Who's Online
19 registered (alibaba, ags, Artvin, AndrewAMD, chsmac85, 20BN, CocaCola, Ayumi, 5 invisible), 477 Guests and 12 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
mahomed, bondz, Neil_G, bobby4h, MutilatedDuck
18117 Registered Users
Topic Options
Rate This Topic
#475410 - 12/06/18 23:15 Newbie coding question. HELP Please!
Neil_G Offline
Guest

Registered: 12/06/18
Posts: 2
Loc: ON
Hi,

Newbie here.

As an exercise in learning Zorro, I'm trying to code a youtube strategy (yes, I know it won't make me any money :-) ).

The strategy:

  • entry after first hour of forex session (EUR session starts at 0800h UTC)
  • if 2nd hour of session goes above high of first hour, enter long
  • if 2nd hour of session goes below low of first hour, enter short
  • exit after 4 hours
  • TP=50 PIPs


Here is my code:

Code:
function run()
{
	BarPeriod = 60;
	LifeTime = 4;
	
	int LondonOpen = timeOffset(UTC,0,9,0); 
	vars PriceHigh = series(priceHigh(1));
	vars PriceLow = series(priceLow(1));
	vars Price = series(price());

	TakeProfit = 50;
	
	if((LondonOpen==0) && (Asset="GBP/USD"))
	{
		if(Price<PriceLow)
			enterShort(); 
		else if(Price>PriceHigh)
			enterLong();
	}
}



Am I even close?

Problems (that I've noticed so far):
  • trades don't enter at high or low of bar
  • trades don't go in proper direction


Any help/suggestions would be appreciated.

Thanks,

Neil

Top
#475418 - 12/07/18 12:43 Re: Newbie coding question. HELP Please! [Re: Neil_G]
jcl Online

Chief Engineer

Registered: 07/22/00
Posts: 26655
Loc: Frankfurt
When you're using price series instead of prices, it's Price[0] or PriceLow[0]. And 50 pips are 50*PIP.

Top
#475432 - 12/07/18 17:27 Re: Newbie coding question. HELP Please! [Re: jcl]
Neil_G Offline
Guest

Registered: 12/06/18
Posts: 2
Loc: ON
I had the 50*PIP in my code (accidentally deleted it from post when I removed some comments).

I had it in my head that Zorro worked on sets (which, given that I got results, I guess it sort of does). I changed the code to reflect your comment (and changed the BarPeriod = 1 and LifeTime) and it appears I'm getting what I want.

Thanks jcl.

Top
#475439 - 12/09/18 16:28 Re: Newbie coding question. HELP Please! [Re: Neil_G]
3dgamelight Online
Junior Member

Registered: 04/24/17
Posts: 83
This is not the wrong forum? This is non-interactive.

Top


Moderator:  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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

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