PureBytes Links
Trading Reference Links
|
Hi,
Nothing guarantines that your AFL is executed exactly at 60.00secs interval.
If sometimes it executes at 60.5 sec, your code will skip some minutes
(tNow2 = t2 - floor(t2/100)*100; will not give 0).
Try something like this:
RequestTimedRefresh( 5 );
....
ExecTimer = Int(Now(4) / 100); //Hours and minutes
if (StaticVarGet("ExecTimer") != ExecTimer)
{
StaticVarSet("ExecTimer", ExecTimer);
//do what you need to do here
}
Regards,
Y
--------------------------------------------------
From: "adexie" <adexie@xxxxxxxxx>
Sent: Wednesday, March 11, 2009 2:55 AM
To: <amibroker@xxxxxxxxxxxxxxx>
Subject: [amibroker] irregular behavior of my code trying to fire every
minute
> Dear all,
>
> I started learning amibroker afl a couple of months ago. Wrote my first
> trading program, which only turned out working occasionally. Can you guys
> take a look and help me out? Thanks so much in advance.
>
> This is exactly the first half of my "Indicator trader". It is placed in
> the chart panel as an indicator and supposedly it should fire and scan all
> the tickers for signal every minute. But sometimes, it doesn't fire for a
> long time. The code and the log are attached below:
>
> -----------Code-------------------------
> _SECTION_BEGIN("Autotrading_Indicator");
> MarketHours = TimeNum()>=093500 AND TimeNum()<=155400;
> MarketClose= TimeNum()>155430 AND TimeNum()<=240000;
>
> AutoTradingOn = ParamToggle("Autotrading On Off", "OFF|ON", 0);
>
> SetChartOptions( 2, chartWrapTitle );
> RequestTimedRefresh( 60 );
>
> t2 = Now(4);
> tNow = t2-floor(t2/10000)*10000;
>
> tNow2 = t2 - floor(t2/100)*100;
>
> if(tNow2 == 0)
> {
> _TRACE("Current time " + Now() + ", tNow: " + tNow + " t1 " + t1 + " t2 "
> + t2 + ", AutoTradingOn: " + AutoTradingOn);
> }
> ----------------------------------------------------------
>
> Log: (notice in the first a few minute it's fine, but after
> 7:05, it wasn't fired until 7:37.
>
> [4016] Current time 3/10/2009 7:00:00 PM, tNow: 0 t1 185901 t2 190000,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:01:00 PM, tNow: 100 t1 185901 t2 190100,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:02:00 PM, tNow: 200 t1 185901 t2 190200,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:03:00 PM, tNow: 300 t1 185901 t2 190300,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:04:00 PM, tNow: 400 t1 185901 t2 190400,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:05:00 PM, tNow: 500 t1 185901 t2 190500,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:37:00 PM, tNow: 3700 t1 185901 t2 193700,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:42:00 PM, tNow: 4200 t1 185901 t2 194200,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:49:00 PM, tNow: 4900 t1 185901 t2 194900,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 7:54:00 PM, tNow: 5400 t1 185901 t2 195400,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 8:11:00 PM, tNow: 1100 t1 185901 t2 201100,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 8:27:00 PM, tNow: 2700 t1 185901 t2 202700,
> AutoTradingOn: 1
> [4016] Current time 3/10/2009 9:07:00 PM, tNow: 700 t1 185901 t2 210700,
> AutoTradingOn: 1
>
>
>
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|