I do this for timed based bar
PrevTN = StaticVarGet("TimeNumber");
TN = LastValue(TimeNum());
NewBar = TN != PrevTN;
StaticVarSet("TimeNumber",TN);
This should work for any bar type
newday=day()!=ref(day(),-1);
PrevBN=StaticVarGet("BarofDay");
BN=lastvalue(barssince(newday,1));
newbar=BN!=PrevBN;
StaticVarSet("BarofDay",BN);
if (newbar)
{..... do trading code
}
To: [email protected]
From: [email protected]
Date: Mon, 17 Aug 2009 14:59:41 +0000
Subject: [amibroker] Re: Question regarding real-time trading
I might be missing something in your question but if you want to know if a new
bar has arrived, you could just check the value of barindex?
LastBar = LastValue(BarIndex());
prevLastBar = StaticVarGet("prevlastbar");
// Initialise
if (IsNull(prevLastBar)){
prevLastBar = LastBar;
StaticVarSet("prevlastbar", prevLastBar);
}
if (LastBar > prevLastBar){
_TRACE("New Bar");
StaticVarSet("prevlastbar", LastBar);
}
Regards,
Jules.
--- In [email protected], "scourt2000" <steveh...@...> wrote:
>
>
> Would it be of value to any other real-time traders here (besides me, of
> course) to have Amibroker automatically notify a script when the 1st tick of
> a new bar is coming into the script? This way, you don't have to know what
> kind of bar you're dealing with (minute-based, tick-based, volume-based) and
> try to do the calc yourself.
>
> I guess it would be something like a toggle trigger that you check in a
> simple IF condition and that toggle is only entered into on the 1st tick of
> each new bar.
>
> Just wanted to get an idea of the interest before going through the formal
> procedure of entering it into the Amibroker wish list area.
>
> Thanks.
>
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009