Code:
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() );
// 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; // 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;
// here we define variables used once in the trade
ApplyStop( stopTypeLoss, stopModePercent, amount=10 );
Sell= Cross(Ref(EMA(L,180),-1),C); // close crosses below yesterdays average of the low
// here we define what gets displayed on the chart
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);
Filter = cond1 AND cond2 AND cond3 AND cond4 AND cond5 AND cond6;
// 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); //
// This section creates the data that you can plot to see how often TT2 trades
// NOTE:- Using VOLUME array so get correct number when switching to WEEKLY or MONTHLY display
AddToComposite(Buy,"~TTBuys","V");
AddToComposite(Sell,"~TTSells","V");
Buy = ExRem(Buy,Sell) ;
Sell = ExRem(Sell, Buy);
Binary = Flip(Buy , Sell);
_SECTION_BEGIN("EMA 40");
P = ParamField("Price field",-1);
Periods = Param("Periods", 40, 2, 300, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorBlueGrey ), ParamStyle("Style"),styleThick );
_SECTION_END();
_SECTION_BEGIN("HHV Long term Entry");
HHVlongtermPeriod=Param("HHV Long termPeriod",70,1,50);
LongPeriodEntry=HHV(H,HHVLongtermPeriod);
Plot (LongperiodEntry," Highest High 70 Days ",colorRed,styleLine);
_SECTION_END();
_SECTION_BEGIN("HHV Short term Entry");
HHVshorttermPeriod=Param("HHV short term Period",10,1,50);
ShortperiodEntry=HHV(H,HHVshorttermPeriod);
Plot (ShortperiodEntry," Highest High 10 Days ",colorBlue,styleLine);
_SECTION_END();
_SECTION_BEGIN("EMA 180");
P = ParamField("Price field",-1);
Periods = Param("Periods", 180, 2, 300, 1 );
Plot( EMA( L, Periods ), _DEFAULT_NAME(), colorOrange , ParamStyle("Style"),styleThick );
_SECTION_END();
Bookmarks