Posted By: MatPed
Optimization - 12/12/16 14:40
Hi,
I was experimenting a script found in the manual
The only modification was few lines in order to optimize the main parameter: Threshold . Unfortunately it does not work.
What Am I missing?
Thank you in advance
I was experimenting a script found in the manual
Code:
// Currency Strength Strategy /////////////////////
// Exploits price shocks f.i. by CHF cap and Brexit
function run()
{
set(PARAMETERS); // Not as original
NumYears = 7; // Not as original
BarPeriod = 60;
Margin = 50; // Not as original
ccyReset(); // reset strengths at begin of any bar
string Name;
while(Name = (loop(Assets)))
{
if(assetType(Name) != FOREX)
continue; // Currency pairs only
asset(Name);
vars Prices = series(priceClose());
ccySet(ROC(Prices, 1)); // store price change as strength
}
// get currency pairs with highest and lowest strength difference
string Best = ccyMax(), Worst = ccyMin();
var Threshold = optimize(1.0, 1.0, 2.0, 0.1); // Not as original
static char OldBest[10], OldWorst[10]; // static for keeping contents between runs
if(*OldBest && !strstr(Best,OldBest)) { // new strongest asset?
asset(OldBest);
exitLong();
if(ccyStrength(Best) > Threshold) {
asset(Best);
enterLong();
}
}
if(*OldWorst && !strstr(Worst,OldWorst)) { // new weakest asset?
asset(OldWorst);
exitShort();
if(ccyStrength(Worst) < -Threshold) {
asset(Worst);
enterShort();
}
}
The only modification was few lines in order to optimize the main parameter: Threshold . Unfortunately it does not work.
What Am I missing?
Thank you in advance
