I am trying to do some simple backtest code using the E-Mini. What I want to do is something like this:
if (bar(-3)=downbar & bar(-2)=upbar & bar(-1)=upbar and bar(-1).high>bar(-2).high) then go long on current bar with a stoplimit of bar(-2).high
if ordernot filled on current bar, cancel.
then, if order filled. Set exit limit @ enter price + 1.00 and set stop-limit at enter - 2.5..
This is what I have done so far, but it does not record any trades in the strategy analyzer...
if(close(-4)>close(-3) && (close(-3)<close(-2)) && close(-2)<close(-3) && Strategy.isInTrade()==false && close(-1)<close(-2)
&& high(-2)<high(-1))
{
var longenter = high(-1);
Strategy.doLong("Forward Momentum",Strategy.LIMIT, Strategy.THISBAR, null, longenter);
}
if(Strategy.isInTrade()==true && Strategy.isLong() == true)
{
Strategy.setStop(longenter-2.5);
Strategy.doSell("Getting out at profit", Strategy.LIMIT,Strategy.THISBAR, null, (longenter+1.00));
}
Any help would be great...
if (bar(-3)=downbar & bar(-2)=upbar & bar(-1)=upbar and bar(-1).high>bar(-2).high) then go long on current bar with a stoplimit of bar(-2).high
if ordernot filled on current bar, cancel.
then, if order filled. Set exit limit @ enter price + 1.00 and set stop-limit at enter - 2.5..
This is what I have done so far, but it does not record any trades in the strategy analyzer...
if(close(-4)>close(-3) && (close(-3)<close(-2)) && close(-2)<close(-3) && Strategy.isInTrade()==false && close(-1)<close(-2)
&& high(-2)<high(-1))
{
var longenter = high(-1);
Strategy.doLong("Forward Momentum",Strategy.LIMIT, Strategy.THISBAR, null, longenter);
}
if(Strategy.isInTrade()==true && Strategy.isLong() == true)
{
Strategy.setStop(longenter-2.5);
Strategy.doSell("Getting out at profit", Strategy.LIMIT,Strategy.THISBAR, null, (longenter+1.00));
}
Any help would be great...
Comment