You are missing a clause in your translation for the Trade Station part: AND 
buystop < buystop [ 1day day ago]

Also, rather than recalculating the offset array each time, it is better to 
store the value in an intermediate variable and only do the calculation once.

e.g.

avgPrice1DayAgo = Ref(averagePrice, -1);
notWideningBuyStop = IIf(averagePrice >= avgPrice1DayAgo && ...)

For plotting, you can use a number of pre-defined shapes in conjunction with 
the PlotShapes function. There are a number of posts in the User's Knowledge 
Base on this:

http://www.amibroker.org/userkb/?s=plotshapes

Mike

--- In [email protected], "loewenste...@..." <zl...@...> wrote:
>
> mac_bosh: Thank you very much, that did the trick for getting the correct 
> values.
> 
> I am now battling with preventing the stop widening - in TradeStation 2000i 
> it is coded as:
> 
> IF (averagePrice >= averagePrice[1 day ago] AND 
>     averagePrice[1 day ago] >= averagePrice[2 days ago] AND
>     buystop < buystop [ 1day day ago]
> THEN
>     buystop = buystop[1 day ago];
> 
> I translated it as:
> 
> notWideningBuyStop = IIf(averagePrice >= Ref(averagePrice, -1) && 
> Ref(averagePrice,-1) >= Ref(averagePrice,-2), Ref(Buystop,-1), Buystop);
> 
> However I am still seeing the stop widening and wonder what I am doing wrong.
> 
> Further in TradeStation the sell and buy stops are plotted as seperate stops 
> (large dots) but I can only display small dots on a line. Is it perhaps best 
> to plot this as a staircase? (another part that I need to attack).
> 
> Many tahnks in advance, Marinus
> 
> --- In [email protected], "mac_bosh" <mac@> wrote:
> >
> > Hi,
> > 
> > Something like this ...
> > 
> > initialBuyStop =
> >  iif(averagePrice > Ref(averagePrice, -1)
> >  && Ref(averagePrice,-1) < Ref(averagePrice,-2), LOW - fixValue, 
> > initialBuyStop);
> > 
> > 
> > finalBuyStop = iif(fixValue < LOW - initialBuyStop, LOW - fixValue, 
> > initialBuyStop);
> > 
> > Cheers
> > 
> > --- In [email protected], "loewensteijn@" <zl2ml@> wrote:
> > >
> > > Hello, I am relative new to Amibroker and am trying to migrate some stuff 
> > > from TradeStation to AB.
> > > 
> > > The IIF statement has me in tangles and I would appreciate if someone can 
> > > help me translate the following two statements:
> > > 
> > > TradeStation code:
> > > first one:
> > > 
> > > IF ( averagePrice > averagePrice[1 day ago] AND 
> > >    averagePrice[1 day ago] < averagePrice[2 days ago] )
> > > THEN
> > >    initialBuyStop = LOW - fixValue;
> > > 
> > > and the second one:
> > > 
> > > IF fixValue < ( LOW - initialBuyStop ) 
> > > THEN
> > >    finalBuyStop = ( LOW - fixValue ) 
> > > ELSE
> > >    finalBuyStop = initialBuyStop;
> > > 
> > > 
> > > Many thanks in advance,
> > > Marinus
> > >
> >
>


Reply via email to