Hi there,
today i created my first EA. I just wanted to do a backtest for statistics.
My entry condition was:
1. Go long after a two-day higher close + exit on the next opening
2. Go short after a two-day higher close + exit on the next opening
Therefore i had only ONE code with the ONLY the Parameter OP_BUY to OP_SELL changed. As i have the same exit points, shouldn't i then have two contrary outcomes like, -2000$ for long and +2000$ for short?
Here's the code wich is in my start function:
int start()
{
//----
//variables
double open;
static int ticket, err;
OrderClose(ticket,0.1,Ask,3,Red);
if(Close[1]>Close[2]&& Close[2] > Close[3])
{
ticket=OrderSend(Symbol(),OP_SELL,0.1,Open[0]+2*Point,3,0,0,"buy on a 2day higher close",1,0,Green);
err=GetLastError();
if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET);
MessageBox("Order opened at " + OrderOpenPrice(),"Order opened");
}
else
{
MessageBox("Error" + err, "ERROR!");
return(0);
}
}
Only the bold parameter was changed from short to long. So if i have a certain profit on the one backtest, shouldn't i have the same loss on the other backtest?
I hope you got my problem. Maybe i'm just confused, or i'm just overlooking something. Please clear things up, i'm struggling.
Greetings
-mike
BTW: How do i manage that i exit my position on the close of the same day. I mean in the example above i opend my position on the open of the day, but how do i exit on the same day (on the day's close)??
Hope you can help my in my two questions.
Cheers
today i created my first EA. I just wanted to do a backtest for statistics.
My entry condition was:
1. Go long after a two-day higher close + exit on the next opening
2. Go short after a two-day higher close + exit on the next opening
Therefore i had only ONE code with the ONLY the Parameter OP_BUY to OP_SELL changed. As i have the same exit points, shouldn't i then have two contrary outcomes like, -2000$ for long and +2000$ for short?
Here's the code wich is in my start function:
int start()
{
//----
//variables
double open;
static int ticket, err;
OrderClose(ticket,0.1,Ask,3,Red);
if(Close[1]>Close[2]&& Close[2] > Close[3])
{
ticket=OrderSend(Symbol(),OP_SELL,0.1,Open[0]+2*Point,3,0,0,"buy on a 2day higher close",1,0,Green);
err=GetLastError();
if(ticket>0)
{
OrderSelect(ticket,SELECT_BY_TICKET);
MessageBox("Order opened at " + OrderOpenPrice(),"Order opened");
}
else
{
MessageBox("Error" + err, "ERROR!");
return(0);
}
}
Only the bold parameter was changed from short to long. So if i have a certain profit on the one backtest, shouldn't i have the same loss on the other backtest?
I hope you got my problem. Maybe i'm just confused, or i'm just overlooking something. Please clear things up, i'm struggling.
Greetings
-mike
BTW: How do i manage that i exit my position on the close of the same day. I mean in the example above i opend my position on the open of the day, but how do i exit on the same day (on the day's close)??
Hope you can help my in my two questions.
Cheers
I'm getting there ... slowly