// Trend Trading ///////////////////
#include <profile.c>
function run()
{
Verbose = 3;
set(LOGFILE); // log all trades
StartDate = 2013;
EndDate = 2023; // fixed simulation period
BarPeriod = 15;
if(is(INITRUN)) {
// Debug: Print original rollover values
printf("\n[INIT] Original RollShort: %f, RollLong: %f", RollShort, RollLong);
// Adjusting rollover values
RollShort = RollShort / 365.;
RollLong = RollLong / 365.;
// Debug: Print adjusted rollover values
printf("\n[INIT] Adjusted RollShort: %f, RollLong: %f", RollShort, RollLong);
}
vars Prices = series(price());
vars Trends = series(Laguerre(Prices,0.05));
Stop = 10*ATR(100);
MaxLong = MaxShort = -1;
if(valley(Trends))
enterLong();
else if(peak(Trends))
enterShort();
}