PureBytes Links
Trading Reference Links
|
Hello Chaitanya,
Though, I do not have AmiBroker before me right now, however the following touch up to Pankaj's code should do what you are lookig for :
intrade = 0;
for(i=1; i<BarCount; i++)
{
if(i>1)intrade[i] = intrade[i-1];
if( C[i] < MA200[i] )
{
intrade[i] = 1;
}
else
{
intrade[i] = 0;
}
}
Plot(Close, "Price", colorBlack, styleCandle);
Plot(MA(C,200), " MA(200): " , colorBlue);
Plot(intrade, "intrade: " , styleleftaxisscale);
GraphXSpace = 5;
With Regards
Sanjiv Bansal
--- In amibroker@xxxxxxxxxxxxxxx, "Chaitanya" <kcityg@xxx> wrote:
>
> No; i do not want to use InTrade as an array; if i use it as an array i need to not only set intrade[i] to 1 but every other intrade array value until i get my exit signal; and that after checking if the previous intrade bar is 1; very messy.
>
> I just want to use a boolean variable and keep checking it at certain bars if it is true or false.
>
> So, in the code below, i want intrade[i] to be set to 1 and stay at 1 until i get my exit signal.
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Pankaj Sharma" <psharma@> wrote:
> >
> > Try the following. It will let you access intrade for each bar of your
> > chart. Please disregard my earlier comment to your query; it is more
> > applicable for a RT environment.
> >
> >
> >
> > for(i=1; i<BarCount; i++)
> > {
> > if( C[i] < MA200[i] )
> > {
> > intrade[i] = 1;
> > }
> > else
> > {
> > intrade[i] = 0;
> > }
> > }
> >
> > Plot(Close, "Price", colorBlack, styleCandle);
> > Plot(MA(C,200), " MA(200): " , colorBlue);
> >
> > Plot(intrade, "intrade: " , styleleftaxisscale);
> >
> >
> > GraphXSpace = 5;
> >
> >
> >
> > _____
> >
> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> > Of Chaitanya
> > Sent: 27 October 2009 21:25
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: cant get to set a simple boolean variable..
> >
> >
> >
> >
> >
> > Thanks Pankaj.
> >
> > I did suspect that it was using it as an array; so what do i have to do to
> > declare intrade as a boolean variable (a flag kind of a variable) and not as
> > an array? I couldnt find it in the help but i could have easily overlooked.
> >
> > MA200 = MA(C, 200);
> > intrade = 0;
> >
> > for(i=1; i<BarCount; i++)
> > {
> > if( C[i] < MA200[i] )
> > {
> > intrade = 1;
> > }
> > else
> > {
> > intrade = 0;
> > }
> > }
> >
> > Plot(Close, "Price", colorBlack, styleCandle);
> > Plot(MA(C,200), " intrade: " + intrade + " MA(200): " , colorBlue);
> > GraphXSpace = 5;
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Pankaj Sharma" <psharma@> wrote:
> > >
> > > Chaitanya,
> > >
> > >
> > >
> > > This is because AFL processes inTrade as an array. Within the loop, for
> > each
> > > bar, inTrade is set to true or false.
> > >
> > >
> > >
> > > When you access inTrade by itself outside the loop, you access the value
> > of
> > > inTrade for the bar that AFL is processing. Which will be zero (as set on
> > > the first line) unless your code has changed it during loop processing,
> > for
> > > the current bar.
> > >
> > >
> > >
> > > Best,
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > _____
> > >
> > > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On
> > Behalf
> > > Of Chaitanya
> > > Sent: 27 October 2009 09:09
> > > To: amibroker@xxxxxxxxxxxxxxx
> > > Subject: [amibroker] cant get to set a simple boolean variable..
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > New problem:
> > >
> > > I cant seem to get a simple boolean variable working; here is sniplet of
> > > code..
> > >
> > > intrade = 0; //intrade = false;
> > > for(i=1; i < barcount; i++)
> > > {
> > > if(my condition)
> > > {
> > > intrade = 1;
> > > }
> > > etc etc..
> > >
> > > }
> > >
> > > The intrade = 1 in the above program seems to be never executing even
> > though
> > > the program is traversing into the loop; and the bool always stays false
> > > (0); what am i doing wrong?
> > >
> > > --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com,
> > > "Chaitanya" kcityg@ wrote:
> > > >
> > > > never mind; got it using appending strings to any existing study on the
> > > chart. like..
> > > >
> > > > Plot( MA(200), "RSI value " + r + "myBool Value " + boolVar1, colorblue
> > );
> > > >
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com,
> > > "Chaitanya" <kcityg@> wrote:
> > > > >
> > > > > i have found it useful to write any indicator values or variable
> > values
> > > directly on amibroker UI rather than using a separate debug window (for
> > one
> > > it makes tracking bar per bar easier) but i forgot how i did that in the
> > > past.
> > > > >
> > > > > Can someone point me to an example..
> > > > >
> > > > > Example: I have a boolean (true/false) variable and an array variable
> > > say BuySignal array. i want to print the values of these two variables as
> > i
> > > progress from bar to bar on the chart pane itself.
> > > > >
> > > > >
> > > > > thanks!
> > > > > -gariki
> > > > >
> > > >
> > >
> >
>
------------------------------------
**** 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/
|