[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Newbie question



PureBytes Links

Trading Reference Links

I'll try static variables and valuewhen(). Thanks for the pointer.

Is it correct to assume that I can reassign static variables at will?

--- In amibroker@xxxxxxxxxxxxxxx, "Charles Stangor" 
<cstangor232@xxxx> wrote:
> OK.  I think you might need the valuewhen() function or a static 
variable 
> for that.
> 
> ----- Original Message ----- 
> From: "sibir61" <sibir61@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Tuesday, September 27, 2005 10:06 AM
> Subject: [amibroker] Re: Newbie question
> 
> 
> > Correct, it remains the same because you reassign it on every bar.
> > But you if you have test = 999 + bar.minute() - look what that 
does.
> > Now assume that my buy stop can only be calculated once and never
> > again - change bar.minute() to function that generates one value 
at
> > 10AM and is never called again - now test variable would be in
> > trouble.
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Charles Stangor"
> > <cstangor232@xxxx> wrote:
> >> Not so.  Try this simple code:
> >> test = 999; printf (WriteVal(test));
> >>
> >> Test remains at 999 forever unless you change it.
> >>
> >>
> >>
> >> ----- Original Message ----- 
> >> From: "sibir61" <sibir61@xxxx>
> >> To: <amibroker@xxxxxxxxxxxxxxx>
> >> Sent: Tuesday, September 27, 2005 9:40 AM
> >> Subject: [amibroker] Re: Newbie question
> >>
> >>
> >> > Hi Graham,
> >> >
> >> > I will try to rephrase/simplify my question. Say you have 
event A
> >> > taking place at random time T1 and event B taking place at 
random
> >> > time T2. There is no technical indicator to connect the two -
> > both
> >> > are just formations (could happen at any time). I place a fixed
> > buy
> >> > stop once A AND B = TRUE for the rest of the day. That buy stop
> > does
> >> > not get activated till sometime later in the day if ever, again
> >> > formations. AFL evaluates code you write every time for each 
new
> > bar,
> >> > which means that there is no way of passing fixed info from one
> > bar
> >> > to another, because on every bar every member of the array has 
to
> > be
> >> > reassigned again - x=ref(x,-1) does not work because compiler
> >> > complains about x not being initialized (correct).
> >> >
> >> > To summarize my question: if i evaluate stocks on a 1 min bar 
how
> > do
> >> > I store a value I calculate at 10AM on a 1 min bar to keep that
> > value
> >> > persistent for the rest of the trading day. AFL resets all
> > variables
> >> > on each bar, which prevents me from storing any values.
> >> >
> >> > int x = 0;
> >> > foreach(Bar bar in minuteBars){
> >> >   if(bar.Time()=="10AM")
> >> >      x = bar.High()+magicNumber;
> >> >   if(bar.High()>x && x!=0)
> >> >     Buy = 1;
> >> > }
> >> > AFL from my understanding has a limited number of nested 
scopes.
> >> > It seems that in AFL there is no way to define x the way it is
> > done
> >> > in here because AFL assumes that you can only write code within
> > that
> >> > foreach loop - AFL evaluater acts as a loop, which if true is
> > really
> >> > really bad.
> >> >
> >> > Are there any workarounds?
> >> >
> >> > Thanks.
> >> >
> >> >
> >> > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx>
> > wrote:
> >> >> Steve
> >> >> For a starter at AFL seems like you want to jump in te deep 
end.
> > I
> >> >> would suggest you start with one item at a time rather than 
try
> > to
> >> >> code everything at first attempt
> >> >>
> >> >> to define the value of a variable just use
> >> >> VariableName = 10;
> >> >> The value will not change throughout the entire AFL, unless 
you
> > give
> >> >> it a different value later on within the AFL
> >> >> You may only need to use the function function if you really
> > need to
> >> >> define a new custom function for multiple uses with different
> > inputs
> >> >>
> >> >> To use an array value at a certain time (or when any other
> > specific
> >> >> occurence is true) use the function Valuewhen
> >> >>
> >> >> Other than that am confused on what your problems are.
> >> >>
> >> >> --
> >> >> Cheers
> >> >> Graham
> >> >> AB-Write >< Professional AFL Writing Service
> >> >> Yes, I write AFL code to your requirements
> >> >> http://e-wire.net.au/~eb_kavan/ab_write.htm
> >> >>
> >> >>
> >> >> On 9/24/05, sibir61 <sibir61@xxxx> wrote:
> >> >> > Hi there,
> >> >> >
> >> >> > I am a newbie with a system, so I have a couple of questions
> > about
> >> >> > coding up price formation based trading system. I need to 
set
> > up
> >> > global
> >> >> > variables that are global not for a current bar, but for a
> > whole
> >> > system
> >> >> > and/or for a certain time period: I would like to calculate
> > buy
> >> > stop
> >> >> > price at 10AM everyday once and use that number for the rest
> > of
> >> > the
> >> >> > day. I was not able to find any meaningful way to do so - 
the
> >> > UserGuide
> >> >> > refers to global variables vs local variables within
> > functions -
> >> > still
> >> >> > for 1 bar, regardless of the timeframe. I, however, need 
global
> >> >> > variables defined within the entire execution cycle. How do 
I
> > do
> >> > that?
> >> >> >
> >> >> > More detailed example: I prefilter stocks based on previous
> > day's
> >> > ATR
> >> >> > action. If it satisfies my condition then I sit tight the 
next
> >> > day till
> >> >> > 10AM when I determine today's price target based on H/L
> > values.
> >> > Then I
> >> >> > combine the two conditions/prices to determine the entry buy
> >> > stop. This
> >> >> > is done just once for a day - not on every bar. Profit 
target
> > is
> >> > also
> >> >> > just an entry price + certain range = fixed target during 
the
> >> > day. I am
> >> >> > having difficulty convincing Amibroker to store those values
> > and
> >> > not
> >> >> > recalculate them on every bar. I trade on a 1 min bar time
> > range.
> >> >> >
> >> >> > Steve
> >> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > Please note that this group is for discussion between users 
only.
> >> >
> >> > To get support from AmiBroker please send an e-mail directly to
> >> > SUPPORT {at} amibroker.com
> >> >
> >> > For other support material please check also:
> >> > http://www.amibroker.com/support.html
> >> >
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >
> >
> >
> >
> >
> >
> > Please note that this group is for discussion between users only.
> >
> > To get support from AmiBroker please send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> 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/