hour

Indicators coded by community members
Message
Author
allan21
Posts: 5
Joined: Mon Oct 08, 2007 4:53 am

hour

#1 Postby allan21 » Fri Dec 28, 2007 5:25 am

Hi,

I am trying to use the following condition:

if Hour (Time(0)) <> 20 then

but when I compile the code I get the following error:
Undeclared Identifier Hour.

How can I resolve this issue?

Thanks

allan21
Posts: 5
Joined: Mon Oct 08, 2007 4:53 am

hour

#2 Postby allan21 » Fri Dec 28, 2007 7:38 am

Hi,

there's another issue that I'd like to address, every time I process single tick procedure, all the paramters used in this procedure are reset to zero.
What I'd like to have is be able to remember the time of the previous tick and if the coming tick is within the same hour, I don't want to process it.
I can't do that cause if I use for example time1 := iTime('EURUSD', PERIOD_H1, 0), everytime I run singletick, time1 is reset to zero.

In brief, I need to tun single tick once for one hour candle only, not once for every tick.

How can I do that?

Thank you

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

Re: hour

#3 Postby Tantalus » Fri Dec 28, 2007 10:52 am

allan21 wrote:Hi,

I am trying to use the following condition:

if Hour (Time(0)) <> 20 then

but when I compile the code I get the following error:
Undeclared Identifier Hour.

How can I resolve this issue?

Thanks


Assuming you're working in Delphi:

The function you are looking for is HourOf(), and it's located in the DateUtils library. Declare it where you declare the other API libraries:

uses
SysUtils, DateUtils, StrategyInterfaceUnit; {you may have different files listed}

Look in the Delphi help file under "HourOf" or "DateUtils"

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Re: hour

#4 Postby Terranin » Fri Dec 28, 2007 2:42 pm

allan21 wrote:Hi,

there's another issue that I'd like to address, every time I process single tick procedure, all the paramters used in this procedure are reset to zero.
What I'd like to have is be able to remember the time of the previous tick and if the coming tick is within the same hour, I don't want to process it.
I can't do that cause if I use for example time1 := iTime('EURUSD', PERIOD_H1, 0), everytime I run singletick, time1 is reset to zero.

In brief, I need to tun single tick once for one hour candle only, not once for every tick.

How can I do that?

Thank you


In this case you should move this variable out of procedure:

Code: Select all

var
  LastTime: TDateTime;

procedure GetSingleTick; stdcall;
begin
  SetCurrencyAndTimeFrame(Currency, PERIOD_M...);
  if Time(0) = LastTime then
    exit;

  LastTime := Time(0);

  ...
end;
Hasta la vista
Mike


Return to “Indicators”

Who is online

Users browsing this forum: No registered users and 18 guests