GetFitness args.History.FindAll("trendpilot", SymbolName)) returns always 0
GetFitness args.History.FindAll("trendpilot", SymbolName)) returns always 0
20 Nov 2019, 12:48
Why is this always results to zero?
protected override double GetFitness(GetFitnessArgs args)
{
return args.History.FindAll("trendpilot", SymbolName).Length;
}
however this
protected override double GetFitness(GetFitnessArgs args)
{
return args.History.count;
}
returns a value.
I want to sum total volume:
protected override double GetFitness(GetFitnessArgs args)
{
double total_volume = 0;
foreach (Position p in args.History.FindAll("trendpilot", SymbolName))
{
total_volume += p.VolumeInUnits;
}
return total_volume;
}
returns always 0.
Replies
sifneosfx
20 Nov 2019, 13:55
RE:
This doesn't work either:
public double total_volume;
protected override double GetFitness(GetFitnessArgs args)
{
return GetTotalVolume();
}
private double GetTotalVolume()
{
foreach (Position pos in History.FindAll("trendpilot"))
{
total_volume += pos.VolumeInUnits;
}
return total_volume;
}
@sifneosfx
PanagiotisCharalampous
20 Nov 2019, 14:11
Hi sifneosfx,
Maybe because History does not contain positions but HistoricalTrade items.
Best Regards,
Panagiotis
@PanagiotisCharalampous
sifneosfx
20 Nov 2019, 14:47
RE:
That did the magic, thanx!
Panagiotis Charalampous said:
Hi sifneosfx,
Maybe because History does not contain positions but HistoricalTrade items.
Best Regards,
Panagiotis
@sifneosfx

sifneosfx
20 Nov 2019, 13:10
RE:
Very strage, when removing from code the forech loop, I got results, with the loop (that does nothing) i get fitness 0.
public double total_volume; protected override double GetFitness(GetFitnessArgs args) { foreach (Position pos in args.History.FindAll("trendpilot")) { } return args.History.FindAll("trendpilot").Length; }@sifneosfx