Posted By: aventador
2 lines EL to check Trend Following Market - Convert to Lite-C - 01/05/23 05:59
Hi,
I'm not sure if the translation from EL to Lite-C below is correct or not but the result is different when i compare.
i made 2 programs and tried to get same result with EL but still not the same.
Tested on EUR/USD historical data provided by zorro.
Can shed some light what is the issue ?
Easylanguage
Buy next bar at highD(1) stop;
Sellshort next bar at LowD(1) stop;
lite-C
1st Code:
2nd Code:
I'm not sure if the translation from EL to Lite-C below is correct or not but the result is different when i compare.
i made 2 programs and tried to get same result with EL but still not the same.
Tested on EUR/USD historical data provided by zorro.
Can shed some light what is the issue ?
Easylanguage
Buy next bar at highD(1) stop;
Sellshort next bar at LowD(1) stop;
lite-C
1st Code:
Code
function run() { set(LOGFILE); BarPeriod = 1440; StartDate = 20130101; EndDate = 20181231; //asset("EUR/USD"); //... Hedge = 0; LookBack = 1; MaxLong = MaxShort = -1; var Highp = dayHigh(UTC,1); var Lowp = dayLow(UTC,1); /* Check if Trend following */ //static int i = 0; //printf("\n No %i, previous high = %.5f, previous low = %.5f", i, Highp,Lowp); if(NumOpenLong == 0 && NumOpenShort == 0) { enterLong(1, Highp); enterShort(1,Lowp); } if(NumOpenLong == 1 && NumOpenShort == 0) { if(price() <= Lowp) { exitLong(); } }else if (NumOpenShort == 1 && NumOpenLong == 0) { if(price() >= Highp) { exitShort(); } } }
2nd Code:
Code
function run() { set(LOGFILE); BarPeriod = 1440; StartDate = 20130101; EndDate = 20181231; //asset("EUR/USD"); //... Hedge = 0; LookBack = 1; MaxLong = MaxShort = -1; var Highp = dayHigh(UTC,1); var Lowp = dayLow(UTC,1); enterLong(1, Highp); enterShort(1,Lowp); }