Newbie coding question. HELP Please!

Posted By: Neil_G

Newbie coding question. HELP Please! - 12/06/18 22:15

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
Posted By: jcl

Re: Newbie coding question. HELP Please! - 12/07/18 11:43

When you're using price series instead of prices, it's Price[0] or PriceLow[0]. And 50 pips are 50*PIP.
Posted By: Neil_G

Re: Newbie coding question. HELP Please! - 12/07/18 16:27

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.
Posted By: 3dgamelight

Re: Newbie coding question. HELP Please! - 12/09/18 15:28

This is not the wrong forum? This is non-interactive.
© 2024 lite-C Forums