MIke - appreciate the help - that's some great sample code for me to work with. Thanks so much!
Damian --- In [email protected], "Mike" <[EMAIL PROTECTED]> 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 [email protected], "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! > > >
