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

[amibroker] Re: Remembering a recent stock event using AFL



PureBytes Links

Trading Reference Links

MIke - appreciate the help - that's some great sample code for me to
work with.  Thanks so much!

Damian

--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Hi,
> 
> You can try something along the lines of capturing the event in an 
> array. Capturing the price that was in effect at the time of the 
> event. Buy when Low is less or equal to 95% of the price at the time 
> of the event.
> 
> You could optionally restrict your entry to only those occurences 
> where the expected pullback happens within a predetermined time.
> 
> The code below assumes that you would be setting a limit order for 
> the entry, and thus can take the trade at the crossover price on the 
> bar that the crossover occured. Swap the Buy statements to see how it 
> behaves when pullback restricted to 10 bar lag.
> 
> Set the MA1 param value to 20 in your chart to match the code.
> 
> Mike
> 
> 
> SetTradeDelays(0, 0, 0, 0);
> 
> Breakout = Cross(Close, MA(Close, 20));
> Closing = ValueWhen(Breakout, Close);
> Lag = BarsSince(Breakout);
> 
> Buy = Lag >= 1 AND Cross(0.95 * Closing, Low);
> // Buy = Lag >= 1 AND Lag <= 10 AND Cross(0.95 * Closing, Low);
> 
> PlotShapes(IIF(Breakout, shapeSmallUpTriangle, null), colorYellow, 0, 
> Low, -20);
> PlotShapes(IIF(Buy, shapeUpArrow, null), colorDarkGreen, 0, Low, -20);
> 
> for (bar = 0; bar < BarCount; bar++) {
> 	if (Buy[bar]) {
> 		PlotText("Lag: " + Lag[bar], bar, Low[bar], 
> colorDarkGreen);
> 	}
> }
> 
> _SECTION_BEGIN("Price");
> SetChartOptions(0,chartShowArrows|chartShowDates);
> _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %
> g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( 
> ROC( C, 1 ) ) ));
> Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | 
> ParamStyle("Style") | GetPriceStyle() ); 
> _SECTION_END();
> 
> _SECTION_BEGIN("MA1");
> P = ParamField("Price field",-1);
> Periods = Param("Periods", 15, 2, 200, 1, 10 );
> Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", 
> colorCycle ), ParamStyle("Style") ); 
> _SECTION_END();
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "droskill" <droskill@> wrote:
> >
> > Let's say I'm trading a breakout - but I don't want to take the
> > breakout immediate but wait for a pullback to enter - how would I
> > "store" that such an event has happened.  So, say I have a stock 
> cross
> > over the 20d MA - I don't want to enter now - I want to enter when
> > their is a 5% pullback.  Can anybody give me some guidance as to how
> > to code something like this up?
> > 
> > Thanks!
> >
>



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

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/