- Joined
- 20 October 2011
- Posts
- 10
- Reactions
- 0
Thank you for your input, Caveroute and Trash. Much appreciated and will go try it out.
How may I vary your code to only include stocks that closed at 52 week high on the most recent Friday?
I got Yahoo prices for RIO 12/05/2014 in Ami. so the download works. However as per usual the data is slightly different from Commsec. Low on Yahoo is 60.25 when it really was Low 60.94.
i assume you mean 60.24?
I guess you get what you pay for....my only solution it seems is to log on regularly and do the data upload from amibroker, they dont seem to make yesterdays data available so that leaves a gap as well.
no doubt there is a way to do this automatically so i dont even have to open lists etc...but one step at a time!
// Know Sure Thing (KST) - Developed by Martin Pring
RC1 = ROC(Avg, 10);
RC2 = ROC(Avg, 15);
RC3 = ROC(Avg, 20);
RC4 = ROC(Avg, 30);
RCMA1 = MA(RC1, 10); // 10-Period SMA of 10-Period Rate-of-Change
RCMA2 = MA(RC2, 10); //10-Period SMA of 15-Period Rate-of-Change
RCMA3 = MA(RC3, 10); // 10-Period SMA of 20-Period Rate-of-Change
RCMA4 = MA(RC4, 15); // 15-Period SMA of 30-Period Rate-of-Change
KST = (RCMA1 * 1) + (RCMA2 * 2) + (RCMA3 * 3) + (RCMA4 * 4);
SignalLine = MA(KST, 9); // 9-period SMA of KST
VerticalLineUp = Cross(KST, -100);
VerticalLineDown = Cross(100, KST);
Plot(KST, "Know Sure Thing", colorBlue, styleThick);
Plot(SignalLine, "KST Signal", colorBlack);
Plot(100, "", colorDarkRed, styleDashed);
Plot(-100, "", colorSeaGreen, styleDashed);
Plot(VerticalLineUp, "", colorYellow, 16384+32768+4096, 0, 1);
Plot(VerticalLineDown, "", colorDarkRed, 16384+32768+4096, 0, 1);
Plot(0, "", colorWhite);
Know Sure Thing is an indicator created apparently by Martin Pring. Dunno if it can be tweaked to closer represent price ranges. Just found it at http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:know_sure_thing_kst
Code:// Know Sure Thing (KST) - Developed by Martin Pring RC1 = ROC(Avg, 10); RC2 = ROC(Avg, 15); RC3 = ROC(Avg, 20); RC4 = ROC(Avg, 30); RCMA1 = MA(RC1, 10); // 10-Period SMA of 10-Period Rate-of-Change RCMA2 = MA(RC2, 10); //10-Period SMA of 15-Period Rate-of-Change RCMA3 = MA(RC3, 10); // 10-Period SMA of 20-Period Rate-of-Change RCMA4 = MA(RC4, 15); // 15-Period SMA of 30-Period Rate-of-Change KST = (RCMA1 * 1) + (RCMA2 * 2) + (RCMA3 * 3) + (RCMA4 * 4); SignalLine = MA(KST, 9); // 9-period SMA of KST VerticalLineUp = Cross(KST, -100); VerticalLineDown = Cross(100, KST); Plot(KST, "Know Sure Thing", colorBlue, styleThick); Plot(SignalLine, "KST Signal", colorBlack); Plot(100, "", colorDarkRed, styleDashed); Plot(-100, "", colorSeaGreen, styleDashed); Plot(VerticalLineUp, "", colorYellow, 16384+32768+4096, 0, 1); Plot(VerticalLineDown, "", colorDarkRed, 16384+32768+4096, 0, 1); Plot(0, "", colorWhite);
// Know Sure Thing (KST) - Developed by Martin Pring
// http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:know_sure_thing_kst
// modified by trash
for ( j = 10; j <= 30; j = j + 5 )
{
if( j <= 20 ) VarSet( "RCMA" + j, MA( ROC( Avg, j ), 10 ) );
else VarSet( "RCMA" + j, MA( ROC( Avg, j ), 15 ) );
}
KST = ( RCMA10 * 1 ) + ( RCMA15 * 2 ) + ( RCMA20 * 3 ) + ( RCMA30 * 4 );
SignalLine = MA( KST, 9 ); // 9-period SMA of KST
VerticalLineUp = Cross( KST, -100 );
VerticalLineDown = Cross( 100, KST );
Plot(KST, "Know Sure Thing", colorBlue, styleThick);
Plot(SignalLine, "KST Signal", colorBlack);
Plot(100, "", colorDarkRed, styleDashed);
Plot(-100, "", colorSeaGreen, styleDashed);
Plot(VerticalLineUp, "", colorYellow, 16384+32768+4096, 0, 1);
Plot(VerticalLineDown, "", colorDarkRed, 16384+32768+4096, 0, 1);
Plot(0, "", colorWhite);
// techtrader v2 amibroker version
// here we define buy conditions and name each one as a variable
PosQty = 10; // You can define here how many open positions you want
SetOption("MaxOpenPositions", PosQty );
PositionScore = Random();
SetOption ("UsePrevBarEquityForPosSizing", True);
SetTradeDelays(1,1,0,0);
// techtrader v2 amibroker version
// here we define buy conditions and name each one as a variable
PositionSize = -10; // always invest only 10% of the current Equity
cond1=Cross(H,Ref(HHV(H,10),-1)); // when todays high crosses last highest high over the last 10 periods
cond2=H > EMA(C,40); // todays high is greater than the 40 day Exp MA of closes
cond3=HHVBars(H,70) == 0; // todays high is the highest for 70 periods
cond4=EMA(V*C,21) > 500000; // ensure at least $500k of money flow
cond5=C < 10.00; // only trading in stocks less than $10
cond6=C > O; // todays close higher than open
// the following line is the trigger if all conditions satisfied
Buy=cond1 AND cond2 AND cond3 AND cond4 AND cond5 AND cond6;
Sell= Cross(Ref(EMA(L,180),-1),C); // close crosses below yesterdays average of the low
ApplyStop(stopTypeLoss, stopModePercent, 10);
Filter = Buy; // lists exploration results conforming to our buy criteria
AddColumn(Buy, "buy", 1.0); //
Filter = Sell; // lists exploration results conforming to our buy criteria
AddColumn(Sell, "sell", 1.0); //
Buy = ExRem(Buy,Sell) ;
Sell = ExRem(Sell, Buy);
In such case AmiBroker will use the absolute value of PositionScore variable to decide which trades are preferred.
SetForeign("$XI");
IndexFilter = EMA(C, 10) > EMA(C, 20);
RestorePriceArrays();
PositionScore = Correlation(IndexFilter, Ref(C, -5), 5);
// the following line is the trigger if all conditions satisfied
Buy=cond1 AND cond2 AND cond3 AND cond4 AND cond5 AND cond6 & IndexFilter;
SetOption("InitialEquity",100000);
SetOption("MaxOpenPositions",20);
SetPositionSize(5,spsPercentOfEquity);
Can I set a weekly periodicity through an AFL code. I know I can do this in the analysis window but would like to be able to embed it in my system code.
I have not been able to see how I would do so. At the moment I have the following options set:
Code:SetOption("InitialEquity",100000); SetOption("MaxOpenPositions",20); SetPositionSize(5,spsPercentOfEquity);
This is pretty good. Found it on the AB Yahoo site. Uses GFX to plot price. By James Hutchison.
}
_SECTION_BEGIN("#1AtPriceVolume");
/*There are four steps involved in the calculation.
This example is based on closing prices AND the
default parameter setting (12).
1. Find the High-Low range for closing prices for the entire period.
2. Divide this range by 12 to create 12 equal price zones.
3. Total the amount of Volume traded within each price zone.
4. Divide the Volume into up Volume AND down Volume (optional).
*/
SetChartOptions(0, chartHideQuoteMarker);
VAPLookback = Param("VAP Lookback", 100, 1, 500, 1);
HighValue = LastValue(HHV(C, VAPLookback));
LowValue = LastValue(LLV(C, VAPLookback));
HighLowRange = HighValue - LowValue;
HighLowEqualiser = HighLowRange / 10;
TotalVol = Cum(V);
PriceZero = LowValue;
PriceLine1 = PriceZero + HighLowEqualiser;
PriceVolZone1 = IIf(L > LowValue & H < PriceLine1, TotalVol, 0);
PriceLine2 = PriceLine1 + HighLowEqualiser;
PriceVolZone2 = IIf(L > PriceLine1 & H < PriceLine2, TotalVol, 0);
PriceLine3 = PriceLine2 + HighLowEqualiser;
PriceLine4 = PriceLine3 + HighLowEqualiser;
PriceLine5 = PriceLine4 + HighLowEqualiser;
PriceLine6 = PriceLine5 + HighLowEqualiser;
PriceLine7 = PriceLine6 + HighLowEqualiser;
PriceLine8 = PriceLine7 + HighLowEqualiser;
PriceLine9 = PriceLine8 + HighLowEqualiser;
PriceLine10 = PriceLine9 + HighLowEqualiser;
PlotLines = ParamToggle("Plot Lines", "Off|On", 1);
if(PlotLines)
{
Plot(PriceZero, "", colorOrange, ParamStyle("Zero",styleLine|styleThick|styleNoLabel),0,0,15);
Plot(PriceLine1, "", colorWhite, ParamStyle("Line1",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine2, "", colorWhite, ParamStyle("Line2",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine3, "", colorWhite, ParamStyle("Line3",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine4, "", colorWhite, ParamStyle("Line4",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine5, "", colorWhite, ParamStyle("Line5",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine6, "", colorWhite, ParamStyle("Line6",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine7, "", colorWhite, ParamStyle("Line7",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine8, "", colorWhite, ParamStyle("Line8",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine9, "", colorWhite, ParamStyle("Line9",styleDashed|styleNoLabel),0,0,15);
Plot(PriceLine10, "", colorWhite, ParamStyle("Line10",styleDashed|styleNoLabel),0,0,15);
}
_SECTION_END();
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.