Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (TedMar, AndrewAMD, dr_panther, 1 invisible), 1,186 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Posted BabyPips Strategy [Re: Squalou] #410341
11/01/12 12:00
11/01/12 12:00
Joined: Oct 2012
Posts: 75
H
hughbriss Offline
Junior Member
hughbriss  Offline
Junior Member
H

Joined: Oct 2012
Posts: 75
I always use numLong(0) and numShort(0) to count the number of open trades if this helps?

Re: Posted BabyPips Strategy [Re: hughbriss] #410342
11/01/12 12:08
11/01/12 12:08
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
Im using the beta 1.02 version which now uses those variables. Hughs code should also work.

Re: Posted BabyPips Strategy [Re: TankWolf] #426286
07/19/13 10:51
07/19/13 10:51
Joined: Jul 2013
Posts: 522
D
dusktrader Offline
User
dusktrader  Offline
User
D

Joined: Jul 2013
Posts: 522
Hello, I'm working my way through all these examples, try to learn how to program with Zorro. On this script, I keep running into an error (with Zorro 1.12.1) that I'm stuck on.

The error is:
(EURUSD::S) Error 010: Invalid stop limit 1.2823
(EURUSD::L) Error 010: Invalid stop limit 1.3034
(EURUSD::S) Error 010: Invalid stop limit 1.3059
(...etc)

What would cause a stop to be invalid? I thought maybe it was too tight in the spread, but that doesn't seem to fix the issue.

Here is the code I am working with so far:
Code:
function run()
{
	set(PARAMETERS+FACTORS+TESTNOW+NFA);
	BarPeriod = 5;
	StartDate = 2006;
	NumYears = 7;
	NumWFOCycles = 6;
	LookBack = 100;

	var* Close = series(priceClose());
	var* High = series(priceHigh());
	var* Low = series(priceLow());
	var* PLUSDI14 = series(PlusDI(14));
	var* MINUSDI14 = series(MinusDI(14));
	var* ADX14 = series(ADX(14));
	var* ATR11 = series(ATR(11));
	var* SMAATR11 = series(SMA(ATR11,21));
	plot("ADX14",ADX14[0],NEW,0x0000CC);
	plot("ATR11",ATR11[0],NEW,BLUE);
	plot("SMAATR11",SMAATR11[0],NEW,BLUE);

	if(lhour(UTC) >= 7 and lhour(UTC) <= 21)

	if(ADX14[0] > 25 && ATR11[0] > SMAATR11[0] && crossOver(PLUSDI14,MINUSDI14) && NumOpenLong == 0)
	{
		if(Low[1] + (2*PIP) < (10*PIP))
			Stop = 15*PIP;
		else
			Stop = Low[1] + (2*PIP);

		enterLong();
	}
	else if(ADX14[0] > 25 && ATR11[0] < SMAATR11[0] && crossOver(MINUSDI14,PLUSDI14) && NumOpenShort == 0)
	{
		if(High[1] - (2*PIP) < (10*PIP))
			Stop = 15*PIP;
		else
			Stop = Low[1] - (2*PIP);

		enterShort();
	}
}


Thanks if you can offer any tips on this error I'm getting.

Re: Posted BabyPips Strategy [Re: dusktrader] #426287
07/19/13 10:59
07/19/13 10:59
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
A stop is invalid when it's at the wrong side of the price. I think this can happen in your script due to the "Stop = Low[1] - (2*PIP)".

Re: Posted BabyPips Strategy [Re: jcl] #426298
07/19/13 14:40
07/19/13 14:40
Joined: Jul 2013
Posts: 522
D
dusktrader Offline
User
dusktrader  Offline
User
D

Joined: Jul 2013
Posts: 522
I have a stupid question here (sorry, I'm a n00b programmer)... in this script, what is the purpose of:

var* High = series(priceHigh());
var* Low = series(priceLow());

Are not priceHigh() and priceLow() already built-in series that I can pull from? For example, why not just use priceClose() and priceHigh(2) for the current and last bar?

Thanks

Last edited by dusktrader; 07/19/13 14:43.
Re: Posted BabyPips Strategy [Re: dusktrader] #426299
07/19/13 14:49
07/19/13 14:49
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
priceHigh()/Low() are functions, not series, but there is indeed no reason in the script for the High and Low series. I guess the author just liked series, or he experimented with other indicators where he needed the series.

The script has other bugs, for instance some of the comparisons can never return true. For learning scripting, better start with your own script from scratch.

Re: Posted BabyPips Strategy [Re: jcl] #426300
07/19/13 15:04
07/19/13 15:04
Joined: Jul 2013
Posts: 522
D
dusktrader Offline
User
dusktrader  Offline
User
D

Joined: Jul 2013
Posts: 522
Thanks. At the moment I'm studying these other scripts, which I don't yet fully understand, and gathering tidbits from them. This is how I usually learn...

Yes I will write my own scripts soon, but I learn a lot from studying other ones that are already working.

Re: Posted BabyPips Strategy [Re: dusktrader] #426304
07/19/13 17:06
07/19/13 17:06
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
Hi all,

Had a go at fixing this according to the rules published.

Not profitable as far as I can see since fixed, was more profitable in its broken state?????

BTW I can see no logic for the ATR rule, except perhaps an indication of momentum in favour of the trade, but if so why does the rule state that the atr should be under its 21d ma for shorts? surely it should be > 21d ma of atr for shorts also?

Haven't time to back test variants, but would appreciate if anyone can spot my errors as I'm a noob too.

Code:
function run()
{
set(PARAMETERS+FACTORS+TESTNOW);
BarPeriod = 5;
StartDate = 2002;
//NumYears = 7;
//NumWFOCycles = 10;
LookBack = 100;

vars Close = series(priceClose());
vars High = series(priceHigh());
vars Low = series(priceLow());
vars PLUSDI14 = series(PlusDI(14));
vars MINUSDI14 = series(MinusDI(14));
vars ADX14 = series(ADX(14));
vars ATR11 = series(ATR(11));
vars SMAATR11 = series(SMA(ATR11,21));

int profit = optimize(20,5,200,5);

if(lhour(UTC) >= 7 and lhour(UTC) <= 21)
	{
	if((ADX14[0] > 25) and (ATR11[0] > SMAATR11[0]) and crossOver(PLUSDI14,MINUSDI14))
		{
			Stop = (max(2+((Close[0]-Low[0])/PIP),15))*PIP;
			TakeProfit = profit*PIP;
			enterLong();			
		}
	else
		{
			if((ADX14[0] > 25) and (ATR11[0] > SMAATR11[0]) and (crossOver(MINUSDI14,PLUSDI14)))
			{
			Stop = (max(2+((High[0]-Close[0])/PIP),15))*PIP;
			TakeProfit = profit*PIP;
			enterShort();
			}
		}
	}
plot("ADX14",ADX14[0],NEW,0x0000CC);
plot("ADX25",25,0,SILVER);
plot("ATR11",ATR11[0],NEW,BLUE);
plot("SMAATR11",SMAATR11[0],0,SILVER);

}


Last edited by swingtraderkk; 07/19/13 17:10.
Page 2 of 2 1 2

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