This is the combined strategy code:
Code: Select all
{
Strategy Details:
Symbol: U1
Market 2: U2
Market 3: U3
Start Date: 20161002
Stop Date: 20170930
Out of Sample: 30 %
Fitness Function: PNL
Profit Target On: Yes
Profit Multiple: 2
Stop Loss On: Yes
Stop Loss Multiple: 2
Highest High On: No
Highest High Lookback: 0
Lowest Low On: No
Lowest Low Lookback: 0
Max Time: 1000000
Profitable Closes: 1000000
}
// ------------------------------------------
// declarations
//
variables: long_on(1), ATR(0), PT_ON(1), SL_ON(1), PT(0), SL(0), HH(0), LL(0);
variables: long_on(0), ATR(0), PT_ON(1), SL_ON(1), PT(0), SL(0), HH(0), LL(0);
variables: tt (0), max_time(1000000), profitable_closes(1000000), prof_x(0);
atr = avgTrueRange(8);
tt = totaltrades;
// -----------------------------------------
// entry
//
Condition1 = open[0] > average(close,8) and open[0] > average(close,200) and high[0] < average(close,3) and low[0] > average(close,200);
If condition1 and (Marketposition = 0 or (max_time - barssinceentry = 0) or (profitable_closes - prof_x = 1 and close >= close[1]) or (high >= PT and PT_ON = 1) or (high >= highest(h,0) and hh = 1) or (low <= SL and SL_on = 1) or (Low <= lowest(low,0) and LL = 1)) then begin
PT = close + atr * 2.00;
SL = close - atr * 2.00;
prof_x = 0;
end;
if condition1 = true and long_on = 1 then buy ("Entry") 100000 contracts this bar close;
Condition2 = open[0] > average(close,8) and open[0] > average(close,200) and low[0] > average(close,3) and low[0] < average(close,200);
If condition2 and (Marketposition = 0 or (max_time - barssinceentry = 0) or (profitable_closes - prof_x = 1 and close <= close[1]) or (low <= PT and PT_ON = 1) or (high >= highest(h,0) and hh = 1) or (high >= SL and SL_on = 1) or (Low <= lowest(low,0) and LL = 1)) then begin
PT = close - atr * 2.00;
SL = close + atr * 2.00;
prof_x = 0;
end;
if condition2 and long_on <> 1 then sellshort ("EntryS") 100000 contracts this bar close;
// ------------------------------------------
// exits
//
if barssinceentry > 0 and long_on = 1 and close >= entryprice then prof_x += 1;
if prof_x >= profitable_closes then sell ("ProfX") all contracts this bar close;
if barssinceentry > max_time-1 then sell ("TimeX") all contracts this bar close;
if HH = 1 and long_on = 1 then sell ("HHx") all contracts next bar at highest(h,0) limit;
if LL = 1 and long_on = 1 then sell ("LLx") all contracts next bar at lowest(l,0) stop;
if PT_ON = 1 and long_on = 1 then sell ("PTx") all contracts next bar at PT limit;
if SL_ON = 1 and long_on = 1 then sell ("SLx") all contracts next bar at SL stop;
// if marketposition = 1 and time >= 1555 then sell all contracts this bar close;
if barssinceentry > 0 and long_on <> 1 and close <= entryprice then prof_x += 1;
if prof_x >= profitable_closes then buyToCover("ProfXs") all contracts this bar close;
if barssinceentry > max_time-1 then buyToCover("TimeXs") all contracts this bar close;
if HH = 1 and long_on <> 1 then buyToCover ("HHxs") all contracts next bar at highest(h,0) stop;
if LL = 1 and long_on <> 1 then buyToCover ("LLxs") all contract next bar at lowest(l,0) limit;
if PT_ON = 1 and long_on <> 1 then buyToCover ("PTxs") all contracts next bar at PT limit;
if SL_ON = 1 and long_on <> 1 then buyToCover ("SLxs") all contracts next bar at SL stop;
// if marketposition = -1 and time >= 1555 then buytocover all contracts this bar close;
this word has already been defined
line 26, column 11
which is in reference to the bold type section of:
variables: long_on(1), ATR(0), PT_ON(1), SL_ON(1), PT(0), SL(0), HH(0), LL(0);
variables: long_on(0), ATR(0), PT_ON(1), SL_ON(1), PT(0), SL(0), HH(0), LL(0);
variables: tt (0), max_time(1000000), profitable_closes(1000000), prof_x(0);
If I remove the entire line of:
Code: Select all
variables: long_on(0), ATR(0), PT_ON(1), SL_ON(1), PT(0), SL(0), HH(0), LL(0);
Can anyone provide the correct wording/approach to fix the problem?
A solution to my issue would be warmly received. Thank you.