Thanks for the sniplet Ed. After adding just one closing brace to the
first four lines its working for me.. but have a couple of questions and
some validations just so i understand how its working.


    * Chart redraws every so many seconds (10secs default) and evaluates
all the rules in the afl. Or does it happen more often; because i see my
incoming ticks changing the bars more often? so evertime a new tick come
in is the chart and indicators redrawn?
I am still testing but i have added the following lines at the end of
your code to cover for situations where a signal intermittently comes
and goes away within a 5min bar; to get the recurrent says i am
resetting it every chart refresh..

else if( (!LastValue(Buy) AND !LastValue(Cover) AND !LastValue(Short)
AND !LastValue(Sell)))
{
  StaticVarSet( "buyVar",0);
  StaticVarSet( "sellVar",0);
  StaticVarSet( "shortVar",0);
  StaticVarSet( "coverVar",0);
//Say("reset done");
}

How it is working?

    * First time around none of the myBuyVar, mySellVar etc are
initialized; so StaticVarGet returns zero. And say for the first time my
buy rules are triggered, it goes into the if statement block and sets
buyVar to 1 and essentially resets all others to zero (useful from the
second execution onwards).

    * Now that buyVar is set to 1, next chart refresh gives myBuyVar a
value of 1 and this prevents from Say( "Buy" ) executing again and
again; until it is reset by some other if statement block.

    * If my system covers and goes long at the same time, then i better
get both signals and i should remove the three extra ANDs in this
statement..
(LastValue(Buy) AND !LastValue(Cover) AND !LastValue(Short) AND
!LastValue(Sell))


PS: AB support actually suggested using LastValue(Buy) within AlertIf
statement just directly; i would think if the chart refreshes every
10secs or so and i use LastValue(buy) within the alertif statement it
should work if it is reading the signal from the last bar but somehow it
is not; do you think you know why that one doesnt work?


thanks a bunch again!
-gariki


--- In [email protected], "Edward Pottasch" <empotta...@...>
wrote:
>
> found a mistake already. This shoudl work I think.
>
> Ed
>
> myBuyVar = Nz(StaticVarGet("buyVar");
> mySellVar = Nz(StaticVarGet("sellVar");
> myShortVar = Nz(StaticVarGet("shortVar");
> myCoverVar = Nz(StaticVarGet("coverVar");
>
> if (myBuyVar == 0 AND (LastValue(Buy) AND !LastValue(Cover) AND
!LastValue(Short) AND !LastValue(Sell)) )
> {
>  StaticVarSet( "buyVar",1);
>  StaticVarSet( "sellVar",0);
>  StaticVarSet( "shortVar",0);
>  StaticVarSet( "coverVar",0);
>  Say( "Buy" );
> }
> else if (mySellVar == 0 AND (!LastValue(Buy) AND !LastValue(Cover) AND
!LastValue(Short) AND LastValue(Sell)) )
> {
>  StaticVarSet( "buyVar",0);
>  StaticVarSet( "sellVar",1);
>  StaticVarSet( "shortVar",0);
>  StaticVarSet( "coverVar",0);
>  Say( "Sell" );
> }
> else if (myShortVar == 0 AND (!LastValue(Buy) AND !LastValue(Cover)
AND LastValue(Short) AND !LastValue(Sell)) )
> {
>  StaticVarSet( "buyVar",0);
>  StaticVarSet( "sellVar",0);
>  StaticVarSet( "shortVar",1);
>  StaticVarSet( "coverVar",0);
>  Say( "Short" );
> }
> else if (myCoverVar == 0 AND (!LastValue(Buy) AND LastValue(Cover) AND
!LastValue(Short) AND !LastValue(Sell)) )
> {
>  StaticVarSet( "buyVar",0);
>  StaticVarSet( "sellVar",0);
>  StaticVarSet( "shortVar",0);
>  StaticVarSet( "coverVar",1);
>  Say( "Cover" );
> }
>
>
>
>
> From: gariki
> Sent: Wednesday, July 21, 2010 2:27 AM
> To: [email protected]
> Subject: [amibroker] Re: sick of watching the screen..
>
>
>
>
> Thanks all for the replies.. it would save me a lot of time if i can
figure this out..
>
>
> TJ: i will defnitely send a mail to support; i have actually sent it
once (Ticket number: 72641) and from the response i got i thought that
the way i am using it i cannot do any better.
> "Actually - AlertIf is mostly planned for use in the AUTOMATIC
ANALYSIS window - you can run SCAN with "run every" feature enabled.
That way will make it independent from chart focus, scrolling etc."
>
>
> Herman: i am surprised that you think this is not an issue because i
thought when you posted this thread, you are running into exactly the
same problem as i have; maybe not.. hmm..
> http://finance.groups.yahoo.com/group/amibroker/message/148221
>
>
>
>
> Anyways; here is almost exactly what i have for most of my systems
(ofcourse rules are simplified); and the way i am using them now is i
plot the graphs and that shows the buy/sell arrows; all i wish is when
it is creating these arrows, it also shouts out loud so that i dont have
to sit at the screen but do something more useful like.. reading a book
or yoga :) and dont care until i hear out a loud sound about my entry..
the problem i run into is it only works intermittently (when the cursor
is on the bar before which the signal is coming); somtimes the alerts
sound; sometimes they dont..
>
>
>
>
>   //Testing alerts
>
>
>   BuySignal = Cross(EMA(C,10),EMA(C,20));
>   SellSignal = BarsSince(BuySignal) == 10;
>   ShortSignal = Cross(EMA(C,20),EMA(C,10));
>   CoverSignal = BarsSince(ShortSignal) == 10;
>
>
>   Buy = ExRem(BuySignal,SellSignal);
>   Sell = ExRem(SellSignal, BuySignal);
>   Short = ExRem(ShortSignal, CoverSignal);
>   Cover = ExRem(CoverSignal, ShortSignal);
>
>
>   shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
>   Plot(Close, "Price", colorBlack, styleCandle);
>   PlotShapes( shape, IIf( Buy, colorGreen, colorRed), 0, IIf(Buy, Low,
High) );
>   PlotShapes( Short*shapeHollowDownArrow + Cover*shapeHollowUpArrow,
IIf(Short, colorRed, colorGreen));
>   GraphXSpace = 5;
>
>
>
>
>   AlertIf( Buy, "SOUND C:\\Program Files\\Amibroker\\BuyBuyBuy.wav",
"Audio alert ");
>   AlertIf( Sell, "SOUND C:\\Program
Files\\Amibroker\\SellSellSell.wav", "Audio alert");
>   AlertIf( Short, "SOUND C:\\Program
Files\\Amibroker\\SellSellSell.wav", "Audio alert");
>   AlertIf( Cover, "SOUND C:\\Program Files\\Amibroker\\BuyBuyBuy.wav",
"Audio alert ");
>
>
>   RoundLotSize = 1;
>   PositionSize = MarginDeposit = 1;
>
>
>
>
>
>
> Any help is appreciated; currently if i place this above code onto a
graph pane and set the time frame to 1min; i can easily get signals and
i have verified that the alerts are not going ON when the signal is
generated.
>
>
>
>
> thanks!
> -gariki
>
>
>
>
> --- In [email protected], "Bruce" brucer@ wrote:
> >
> > FWIW, I ran into some issues with AlertIf long ago and just coded
around them. My primary use was in Explorations, so I just coded my own
lookback since the build-in lookback parameter seemed problematic in my
testing. I encourage you to pursue sending the info to support, because
I think that there may be some idiosyncrasies of AlertIf that have not
been fully explained.
> >
> > --- In [email protected], Tomasz Janeczko groups@ wrote:
> > >
> > > Hello,
> > >
> > > AlertIf does NOT require clicking to activate. You have got
something wrong with your formula.
> > > Send the formula to support if you need help.
> > >
> > > Best regards,
> > > Tomasz Janeczko
> > > amibroker.com
> > >
> > > On 2010-07-20 16:26, gariki wrote:
> > > > Hello All,
> > > >
> > > > i am currently trading 4 systems on 5min time period and am just
getting sick/tired of watching the screen for signals. I have alertif's
coded into the systems but because of the problems with that function
(it wont activate unless the last bar is clicked etc) it doesnt work.
> > > >
> > > > Ideally i would go auto-trade but i do not want to automate the
part of putting trades on. I just want a good reliable mechanism to play
sound alerts when i get signals.. is there any other alternative?
> > > >
> > > > TJ, plese consider fixing alertif functionality for this use
case; for users that dont want to automate quite this is the next best
thing and will be very handy (or maybe there is an alternative; that
would solve my problem; would love to hear that..)
> > > >
> > > >
> > > > 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
> > > >
> > > >
> > > >
> > > >
> > >
> >
>

Reply via email to