|
adviseLong/Short
#410605
11/06/12 08:03
11/06/12 08:03
|
Joined: Sep 2012
Posts: 74 Niedersachsen, Germany
PriNova
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2012
Posts: 74
Niedersachsen, Germany
|
Hi zorro's i read the manual about the adviseLong/-short command, but there are no examples in it? are their any here? this is my code i used how i understand this command:
function run()
{
set(TICKS|RULES);
StartDate = 20100101;
var lv = 20;
var hv = 80;
int tradeL, tradeS;
var *stochs = series(Stoch(5,3,MAType_SMA,5,MAType_SMA),20);
tradeL = adviseLong(DTREE, 0, lv,hv, stochs[0],stochs[1]);
tradeS = adviseShort(DTREE, 0, lv,hv, stochs[0],stochs[1]);
Stop = 2*ATR(100);
if( tradeL > 0)
{
exitShort();
if(numLong() ==0) enterLong();
}
if( tradeS > 0)
{
exitLong();
if(numShort() ==0) enterShort();
}
}
and the prediction after training ist 0% the .rul file looks like:
// Prediction rules generated by Zorro
int EURUSD_L(float* sig)
{ return -100; }
int EURUSD_S(float* sig)
{ return -100; }
// Prediction accuracy: 0%
did i something wrong here?
|
|
|
Re: adviseLong/Short
[Re: PriNova]
#410621
11/06/12 12:36
11/06/12 12:36
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
Chief Engineer
|
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
Yes, you must set HEDGING here in Train mode. Otherwise your second trade immediately closes the first and the advise function can not get any useful result. The prediction accuracy can also be 0 when the parameters are totally uncorrelated to the trade result. This is a test script:
var signal(var val1,var val2)
{
return (val2-val1)/PIP;
}
void run()
{
BarPeriod = 1440;
set(RULES|HEDGING);
asset("SPX500");
var *Close = series(priceClose()),
*High = series(priceHigh()),
*Low = series(priceLow());
var LPH = LowPass(High,100),
LPL = LowPass(Low,100);
Stop = 50*PIP;
TakeProfit = 50*PIP;
var S1 = signal(*Close,LPH),
S2 = signal(*Close,LPL),
S3 = signal(*Close,*High),
S4 = signal(*Close,*Low),
S5 = signal(LPH,LPL);
if(adviseLong(DTREE,0,S1,S2,S3,S4,S5) > 0)
enterLong();
if(adviseShort(DTREE,0,S1,S2,S3,S4,S5) > 0)
enterShort();
}
|
|
|
|