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

[amibroker] Re: Set buyprice and sell price



PureBytes Links

Trading Reference Links

Graham is correct. You have to use a chart of the shortest timeframe. 
If you want to show 5 and 15 minute data you will have to plot it on 
a 5 minute chart. You cannot plot 5 minute bars on a 15 minute chart.

I use something like this so I can switch between charts without 
having to change the code. The example assumes the longer period is 
three times the chart interval. It calculates a MACD and Stoch in a 
timeframe 3 times the current chart interval. 

// Timeframe calculations
tf	= Interval() / 60; // interval is in seconds
tfp	= tf * 180; // chart interval * 3 * 60seconds

TimeFrameSet(tfp);
MacdTf = MACD(r1, r2);
tfStoch	= StochK( StoPer, Kper);
TimeFrameRestore();

MacdTfe	= TimeFrameExpand(MacdTf, tfp);
tfeStoch = TimeFrameExpand(tfStoch, tfp);

plot it as usual but expect to see the 15 minute plot to be flat for 
three 5 min bars. The current bar can change but the previous lines 
will be flat for three bars for each 15 minute period.

This part of you code doesn't make sense:

> C5=Ref (C,1); this is looking ahead 1 bar. Is that what you want to 
do? You can do that but not from the current bar. And your other 
calculation is not looking from a previous period. That will give 
unexpected results.

> BuyPrice = TimeFrameExpand (C5,in5Minute);
> Buy = C>1.45;
> Sell=C>50;
You got the 15 min BuyPrice but don't use it in the next 2 lines. Do 
you want the 5 minute C to be > BuyPrice + 1.45? 

A buy of C>1.45 does not make sense compared to a sell of C>50. You 
will have a buy on all bars C>1.45 and then a sell on all bars with 
C>50. A cross function makes more sense but since I can't see the 
rest of your code all this may be fine.

Barry

--- In amibroker@xxxxxxxxxxxxxxx, "Louis Préfontaine" 
<rockprog80@xxx> wrote:
>
> Hi,
> 
> I tried this as a test but it doesn't work well:
> 
> //SetTradeDelays( 1, 1, 1, 1 );
> 
> TimeFrameSet (in5Minute);
> 
> C5=Ref (C,1);
> 
> TimeFrameRestore();
> 
> BuyPrice = TimeFrameExpand (C5,in5Minute);
> Buy = C>1.45;
> Sell=C>50;
> 
> All my signals are based on 15-minute bars but I do have 5-minute 
bars in
> the database.  What I am trying to do is simply set the buyprice 
not as the
> close of the 15-minute bar, but as the close of the next 5-minute 
bar...
> 
> Louis
> 
> 
> 
> 2008/6/20 Louis Préfontaine <rockprog80@xxx>:
> 
> > Hi,
> >
> > I mean, if I work with 15-minute bars, wouldn't it be simply more
> > complicated to use 5-minute bars and then timeframeexpand every 
single rule
> > but this particular buyprice?
> >
> > Thanks,
> >
> > Louis
> >
> > 2008/6/20 Louis Préfontaine <rockprog80@xxx>:
> >
> >> Hi,
> >>
> >> Is it possible to do the opposite?  Or, if I use 15-minute bars 
(but my
> >> database is in 5-minute bars) to set the buyprice at the Close 
of the first
> >> of the three 5-minute bars?
> >>
> >> Thanks,
> >>
> >> Louis
> >>
> >> 2008/6/20 Graham <kavemanperth@xxx>:
> >>
> >>   You have to set your base time period to 15 minute and use 1 
hour
> >>> timeframe over it
> >>>
> >>> --
> >>> Cheers
> >>> Graham Kav
> >>> AFL Writing Service
> >>> http://www.aflwriting.com
> >>>
> >>> 2008/6/20 Louis Préfontaine <rockprog80@xxx<rockprog80%
40gmail.com>
> >>> >:
> >>>
> >>> > Hi,
> >>> >
> >>> > If this is not possible, I'd like to be able to set a % 
adjustment that
> >>> > depend on the price and liquidity of the stock. I used to set 
a 1%
> >>> > adjustment, but 1% of 50$ is 0.5, and no way there would be 
0.5
> >>> difference
> >>> > between signal and when I buy. On the other side, 1% of 1$ is 
0.1, so
> >>> it
> >>> > may not be enough... Anybody thought about this?
> >>> >
> >>> > Louis
> >>> >
> >>> > 2008/6/19 Louis Préfontaine <rockprog80@xxx<rockprog80%
40gmail.com>
> >>> >:
> >>> >>
> >>> >> Hi,
> >>> >>
> >>> >> I am using 1-hour bars and wouldn't like to set my buyprice 
or
> >>> sellprice
> >>> >> at the Close of the first 15-minute bars after the signal. I 
toyed
> >>> with
> >>> >> timeframe but still not sure how to do this.
> >>> >>
> >>> >> If anyone know how to do this; this shouldn't be complicated.
> >>> >>
> >>> >> Thanks again!
> >>> >>
> >>> >> Louis
> >>>  
> >>>
> >>
> >>
> >
>



------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

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