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

[amibroker] Re: 'Simple!' dynamic applystop help please



PureBytes Links

Trading Reference Links

Hello,

Thank you for pointing out the flaw. I changed the code from day() to
datenum() which gives a unique day for the trade.


StopLvl = 0.0030;
 
Buydate = ValueWhen(Buy,Datenum()); // Determine buy date
 
StopLvlWid = 0.0010;
 
StopLvl = IIf( Datenum()!=Buydate, StopLvl+StopLvlWid, StopLvl);
 
ApplyStop(stopTypeLoss, stopModePoint, StopLvl, True, True);


With an addcolumn, I can see StopLvl changes from 0.0030 to 0.0040
when the date changes but the trade is still stopped out at 0.0030 on
the following day.

Still puzzled.

Regards
Alan


--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
wrote:
> Hello,
> 
> Your formula logic is flawed.
> 
> Day() represents DAY NUMBER (1-31) not date,
> so
> ValueWhen(Buy,Day())
> will be true EVERY MONTH when day is the same as day of the entry
> (previous month(s))
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "firehorse888uk" <firehorse888uk@xxxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Friday, May 27, 2005 7:50 PM
> Subject: [amibroker] 'Simple!' dynamic applystop help please
> 
> 
> > Hi,
> > 
> > I'm backtesting forex.
> > 
> > On the day of the trade, I want the stop loss to be 30pts.
> > On subsequent days, I want the stop loss to be 40pts.
> > Edited relevant section of code follows:
> > 
> > StopLvl = 0.0030;
> > 
> > Buydate = ValueWhen(Buy,Day()); // Determine buy day
> > 
> > StopLvlWid = 0.0010;
> > 
> > StopLvl = IIf( Day()!=Buydate, StopLvl+StopLvlWid, StopLvl);
> > 
> > ApplyStop(stopTypeLoss, stopModePoint, StopLvl, True, True);
> > 
> > 
> > Can anyone see why the above code doesn't work.
> > I've tracked StopLvl and it changes correctly for the following
day.
> > I've set dynamic level to true so I don't understand why the trade
> > stops out at 30pts rather than 40pts on subsequent days.
> > 
> > Thanks
> > Alan




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/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/