PureBytes Links
Trading Reference Links
|
I think I can use this:
_SECTION_BEGIN("2_SAR_of_RSI");
Title = "SAR Of RSI";
Filter = 1;
Plot( RSI(14), "RSI", colorBlue );
RSIValue = RSI(14);
P = ParamField("Price field",-1);
oldo = O; oldh = H; oldl = L; oldc = C; oldv = V;
O = H = L = C = p;
sar_flexible = SAR();
O = oldo; H = oldh; L = oldl; C = oldc; V = oldv;
Plot( sar_flexible, "SAR_F", IIf(sar_flexible > RSIValue, colorRed , colorGreen) ,styleDots | styleNoLine );
pds=9;
pds=Optimize("pds",9,3,15,3);
MACD_Buy = MACD() > EMA(MACD(),pds);
MACD_Sell = MACD() < EMA(MACD(),pds);
Buy = sar_flexible < RSIValue AND MACD_Buy;
Sell = sar_flexible > RSIValue AND MACD_Sell;
Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);
AddColumn(RSIValue,"RSIValue",1.2, colorDefault,colorDefault);
AddColumn(sar_flexible,"sar_flexible",1.2, colorDefault,colorDefault);
AddColumn(Buy,"Buy",1.2, colorDefault,colorDefault);
AddColumn(Sell,"Sell",1.2, colorDefault,colorDefault);
AddColumn(MACD_Buy,"MACD_Buy",1.2, colorDefault,colorDefault);
AddColumn(MACD_Sell,"MACD_Sell",1.2, colorDefault,colorDefault);
GraphXSpace = 5;
_SECTION_END();
--- In amibroker@xxxxxxxxxxxxxxx, "gmorlosky" <gmorlosky@xxx> wrote:
>
> Thnaks but I'm really looking for the SAR of the indicator as part of my system. I'll re-post a clearer message.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Grover Yowell" <gyowell1@> wrote:
> >
> > Hi,
> >
> >
> >
> > Here is a copy of a message from Howard Bandy of Quantitative Trading
> > Systems in which he provides the SAR (long only) . It will follow the Buy
> > signal of your indicator and generate the parabolic SAR.
> >
> >
> >
> > Grover
> >
> > Howard's message begins here.
> >
> > Greetings all --
> >
> > Here is an AFL code that will implement the parabolic trailing stop for a
> > long position. Set the Buy independently. Set the initial level of the
> > trailing stop as you wish. The code takes care of raising the stop level as
> > the price rises.
> >
> > ////////////////////////////////////////////
> >
> > // ParabolicStop.afl
> > //
> > // This implementation is for a long position.
> > //
> > // The parabolic trailing stop is set below the
> > // entry point on the first day of long position,
> > // and rises according to a formula as the price rises.
> > // Unlike the traditional trailing stop, the
> > // parabolic stop continues to rise even as the
> > // price holds steady or drops. Eventually, the
> > // price and the parabolic stop meet, which triggers
> > // an exit.
> > //
> > SetTradeDelays(0,0,0,0);
> >
> > // Trading system entry logic goes here.
> > // Exit will be made by the parabolic stop.
> >
> > // For example, use moving average crossover entry.
> > MALen1 = Optimize("MALen1",30,1,31,1);
> > MAvg = AMA(C,2/(MALen1+1));
> >
> > MALen2 = Optimize("MALen2",15,1,31,2);
> > Pass = C>=MA(C,MALen2);
> >
> > Buy = pass AND Cross(C,MAvg);
> >
> > // The code for the Parabolic Trailing Stop begins here.
> > //
> > // Assume that entry will be made at the close of the day the
> > // buy signal is generated.
> > //
> > // Setting TradeAtStop to 1 assumes that there is a stop
> > // in place and the trade exits intraday at the stop price.
> > // Setting TradeAtStop to 0 assumes that intraday exit
> > // cannot take place (as in mutual fund end-of-day
> > // trading) and the trade takes place at the close
> > // of the signal day.
> >
> > TradeAtStop = Param("TradeAtStop",0,0,1,1);
> >
> > // Set the initial stop level.
> > // For this example, it is set at the Lowest Low
> > // for some number of days.
> >
> > LBDays = Optimize("LBDays",1,0,10,1);
> >
> > // Set the Acceleration factor and Maximum Acceleration.
> >
> > IAF = Param("IAF",0.02,0.001,0.1,0.001); // acceleration factor
> > MaxAF = Param("MaxAF",0.2,0.001,1.0,0.001); // max acceleration
> >
> > Psar = Close; // initialize
> > mp = 0; // flat initial conditions
> > Sell = 0; // clear sell signals
> > af = IAF; // initial acceleration factor
> > hp = High [ 0 ];
> > lp = Low [ 0 ];
> > Lp = LLV(Low,LBDays);
> >
> > // Loop through all the bars.
> >
> > for( i = 2; i < BarCount; i++ )
> > {
> > // Check for exit from long position
> >
> > if ( (mp == 1) AND (Low[i] < Psar[i-1]) )
> > {
> > Sell[i] = 1;
> > if (TradeAtStop)
> > {
> > SellPrice[i] = Psar[i-1];
> > }
> > else
> > {
> > SellPrice[i] = Close[i];
> > }
> > mp = 0;
> > }
> >
> > // Continuation of long position -- adjust stop
> >
> > if ( mp == 1 )
> > {
> > if (High[i] > Hp)
> > {
> > Hp = High[i];
> > af = af + IAF;
> > if (af > MaxAF) af = MaxAF;
> > }
> > psar [ i ] = psar [ i-1 ] + af * ( hp - psar [ i-1 ] );
> > }
> > else
> > {
> > // not in a long position.
> > // value of psar is not important.
> > // set the psar level so it will plot
> > // on the price graph.
> >
> > psar[i] = Close[BarCount-1];
> > }
> >
> > // Check for new long position
> >
> > if ( (mp == 0) AND (Buy[i]) )
> > {
> > BuyPrice[i] = Close[i];
> > Psar[i] = Lp[i];
> > Hp = High[i];
> > af = IAF;
> > mp = 1;
> > }
> > }
> >
> > // The code for the Parabolic Trailing Stop ends here.
> >
> >
> > Plot( Close, "Price", colorBlack, styleCandle );
> > Plot( MAvg, "MAvg", colorBlue,styleLine);
> > Plot( psar, "SAR", colorRed,
> > styleDots | styleNoLine | styleThick );
> >
> > Buy = ExRem(Buy,Sell);
> > Sell = ExRem(Sell,Buy);
> > //Figure 7.11 Parabolic Stop - Looping Code
> >
> > ////////////////////////////////////////////
> >
> > Thanks,
> > Howard
> > www.quantitativetradingsystems.com
> >
> >
> >
> >
> >
> > From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
> > Of gmorlosky
> > Sent: Saturday, April 25, 2009 4:27 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Need SAR in raw code form ?
> >
> >
> >
> >
> >
> >
> >
> >
> > Does anyone have the SAR formula in it's raw Amibroker code. I want to use
> > my indicator in place of the high and low value.
> > Thanks
> >
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
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/
|