Code: Select all
if (lasttrade >=0 and ema41 > ema8 and Price < lastpivolow and tr < trAvarage) then
begin
if (MarketPosition >= 0 or firsttime = True) then
begin
sellshort("bjoshort") TradeSize contracts next bar at open;
//buy("sellstopTradeSize contracts next bar at EntryPrice +tr Stop;
firsttime = false;
ownstoploss = entryprice(0)+(trmax);
print("short ","lastpiviotlow ",lastpivolow,"marketpos:",MarketPosition(0),firsttime,"currentbar ",currentbar,"tr avarage ",trAvarage:8:8,"tr ",tr:8:8,"trmax ",trmax:8:8, "entryprice",entryprice(0):8:8,"ownstoploss ",ownstoploss:8:8 );
lasttrade = -1;
end;
end;
if (lasttrade <=0 and ema41 < ema8 and Price >lastpivohigh and tr < trAvarage) then
begin
if (MarketPosition <=0 or firsttime = True) then
begin
buy("bjolong") TradeSize contracts next bar at open;
//sell("buystop")TradeSize contracts next bar at EntryPrice-tr Stop;
firsttime = false;
ownstoploss = entryprice(0)-(trmax) ;
print("long ","lastpiviothigh ",lastpivohigh,"marketpos:",MarketPosition(0),firsttime,"currentbar ",currentbar,"tr avarage ",trAvarage:8:8,"tr ",tr:8:8,"trmax ",trmax:8:8, "entryprice",entryprice(0):8:8,"ownstoploss ",ownstoploss:8:8 );
lasttrade = 1;
end;
end;
Code: Select all
long lastpiviothigh 1.09marketpos: 0.00FALSEcurrentbar 96.00tr avarage 0.00057487tr 0.00047143trmax 0.00144857entryprice0.00000000ownstoploss -0.00144857
short lastpiviotlow 1.12marketpos: 1.00FALSEcurrentbar 600.00tr avarage 0.00103027tr 0.00102357trmax 0.00296643entryprice1.08845000ownstoploss 1.09141643
long lastpiviothigh 1.11marketpos: 0.00FALSEcurrentbar 884.00tr avarage 0.00101160tr 0.00100786trmax 0.00296643entryprice0.00000000ownstoploss -0.00296643
short lastpiviotlow 1.13marketpos: 1.00FALSEcurrentbar 1191.00tr avarage 0.00101160tr 0.00066643trmax 0.00296643entryprice1.11942000ownstoploss 1.12238643
long lastpiviothigh 1.12marketpos: 0.00FALSEcurrentbar 1479.00tr avarage 0.00104940tr 0.00059786trmax 0.00310857entryprice0.00000000ownstoploss -0.00310857
short lastpiviotlow 1.14marketpos: 1.00FALSEcurrentbar 1942.00tr avarage 0.00104940tr 0.00103857trmax 0.00310857entryprice1.11732000ownstoploss 1.12042857
long lastpiviothigh 1.14marketpos: 0.00FALSEcurrentbar 1985.00tr avarage 0.00104940tr 0.00103857trmax 0.00310857entryprice0.00000000ownstoploss -0.00310857
short lastpiviotlow 1.13marketpos: 1.00FALSEcurrentbar 2127.00tr avarage 0.00104940tr 0.00104071trmax 0.00310857entryprice1.14391000ownstoploss 1.14701857
long lastpiviothigh 1.11marketpos: 0.00FALSEcurrentbar 2617.00tr avarage 0.00104940tr 0.00055643trmax 0.00310857entryprice0.00000000ownstoploss -0.00310857
short lastpiviotlow 1.10marketpos: 1.00FALSEcurrentbar 2723.00tr avarage 0.00104940tr 0.00049429trmax 0.00310857entryprice1.11417000ownstoploss 1.11727857
long lastpiviothigh 1.09marketpos: 0.00FALSEcurrentbar 3175.00tr avarage 0.00104085tr 0.00051500trmax 0.00310857entryprice0.00000000ownstoploss -0.00310857
short lastpiviotlow 1.10marketpos: 1.00FALSEcurrentbar 3462.00tr avarage 0.00104085tr 0.00058357trmax 0.00310857entryprice1.09080000ownstoploss 1.09390857
long lastpiviothigh 1.09marketpos: 0.00FALSEcurrentbar 3642.00tr avarage 0.00104085tr 0.00089786trmax 0.00310857entryprice0.00000000ownstoploss -0.00310857
short lastpiviotlow 1.12marketpos: 1.00FALSEcurrentbar 4022.00tr avarage 0.00110677tr 0.00053143trmax 0.00331786entryprice1.09413000ownstoploss 1.09744786
and the market position is also 0 on a Buy order
what am i doing wrong? this is backtesting only