1 registered members (AndrewAMD),
1,248
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Posted BabyPips Strategy
[Re: TankWolf]
#426286
07/19/13 10:51
07/19/13 10:51
|
Joined: Jul 2013
Posts: 522
dusktrader
User
|
User
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:
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: jcl]
#426298
07/19/13 14:40
07/19/13 14:40
|
Joined: Jul 2013
Posts: 522
dusktrader
User
|
User
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]
#426304
07/19/13 17:06
07/19/13 17:06
|
Joined: May 2013
Posts: 245
swingtraderkk
Member
|
Member
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.
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.
|
|
|
|