• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:51pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 11:51pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

required to function call function 2 replies

Problem with close all function 4 replies

MT4 ArrayBsearch function problem 2 replies

stop loss function and edit time function for Breakout EA 1 reply

MT4 external exec call function ? 5 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Problem with Function + its call
Cancel

Problem with Function + its call

  • Post #1
  • Quote
  • First Post: Aug 8, 2007 9:18am Aug 8, 2007 9:18am
  •  miketoll
  • | Joined Jun 2006 | Status: Member | 115 Posts
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

Quote
Disliked
//+------------------------------------------------------------------+
//| 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
  • Post #2
  • Quote
  • Last Post: Aug 8, 2007 10:30am Aug 8, 2007 10:30am
  •  miketoll
  • | Joined Jun 2006 | Status: Member | 115 Posts
Another question:
How do i know, or how can i program, that an order which gets opened at a specific day gets closed on the same day?
The problem is, that you don't know when the day is over, or if the current tick already the last tick is.
Looking forward to your answer.
Greetings
-mike
I'm getting there ... slowly
 
 
  • Platform Tech
  • /
  • Problem with Function + its call
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023