Hi there,
as i want to backtest my ideas later with every tick, i need to check if the current close is the close of a new bar or still the same bar. Now i coded a function, which should tell me exactly this (see below). In my opinion i did everything right, but if i attach the ea to a chart (in this case live chart), there is always that cross symbolizing that the ea isn't working. Furthermore i don't get the Alert messages. Could you go through it, it's just a few lines, but it would help ,me much, thank you!
-mike
as i want to backtest my ideas later with every tick, i need to check if the current close is the close of a new bar or still the same bar. Now i coded a function, which should tell me exactly this (see below). In my opinion i did everything right, but if i attach the ea to a chart (in this case live chart), there is always that cross symbolizing that the ea isn't working. Furthermore i don't get the Alert messages. Could you go through it, it's just a few lines, but it would help ,me much, thank you!
-mike
QuoteDisliked//+------------------------------------------------------------------+
//| Buy on UP-Trend-Day.mq4 |
//| miketoll |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Mike"
#property link "http://www.metaquotes.net"
//---- input parameters
extern int PercentOpen=25;
extern int PercentClose=25;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//Function, which checks if the current bar is new, or the same (bool --> true=1 / false=2)
bool newbar(int currentbars)
{
static int obars;
if(currentbars != obars)
{
obars = currentbars;
return(1);
}
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(newbar(Bars) == 1) //because if bool is true, then it is 1
{
Alert("Congratulation, a new bar\'s been created", "New bar?");
}
else
{
Alert("No new bar\'s been created, sorry!", "New bar?");
}
//----
return(0);
}
//+------------------------------------------------------------------+
I'm getting there ... slowly