Greetings!
I like to share with you a first alpha stage of a code Im writing in order to make basic indicator exploration on a daily, weekly and monthly timeframes with a "Percentage ScoreRank" result system. This alpha is basically the main body of a more complicated code (that will and could include as many indicators needed), so by now I put only a simple RSI(14) algorithm as a test bed for simplicity.
My current testing hardware-software setup is as follows:
* MacBook Pro Retina, Intel i7, 16GB RAM with:
* Clean VMWare Fusion 7.0 Vanilla Installation of Windows 8.1 64bit with NO ADDITIONAL SOFTWARE but AmiBroker and settings lowered to performance.
* Amibroker 5.80.3 32bit with data retrieved from TC2k v7.
The AFL Idea needs to work as follows:
1) Input "Importance Multipliers" for the 3 timeframes given.
2) Input "Importance Weight" of each Indicator.
3) For a given fulfilled condition algorithm rule for each indicator, add to a variable the number of point "2" multiplied by the given timeframe in regard of point "1".
4) For the Maximum Total of indicators for each timeframe, weight in percentage the hits of the results.
5) For all the 3 timeframe results, calculate a total "ScoreRank" in Percentage score.
The concerns that the current code gives me:
1) The RSI(14) sometimes do not correspond to the RSI(14) plotted on a different AFL simple chart.
2) It appears that the Percentage Results are not give the corresponding addition given by the algorithms conditions. Sometimes when the condition do not hit a lower level, the percentage counter takes it like it does.
Here is the current AFL Code.
Thanks in Advance and CHEERS!
XeL
I like to share with you a first alpha stage of a code Im writing in order to make basic indicator exploration on a daily, weekly and monthly timeframes with a "Percentage ScoreRank" result system. This alpha is basically the main body of a more complicated code (that will and could include as many indicators needed), so by now I put only a simple RSI(14) algorithm as a test bed for simplicity.
My current testing hardware-software setup is as follows:
* MacBook Pro Retina, Intel i7, 16GB RAM with:
* Clean VMWare Fusion 7.0 Vanilla Installation of Windows 8.1 64bit with NO ADDITIONAL SOFTWARE but AmiBroker and settings lowered to performance.
* Amibroker 5.80.3 32bit with data retrieved from TC2k v7.
The AFL Idea needs to work as follows:
1) Input "Importance Multipliers" for the 3 timeframes given.
2) Input "Importance Weight" of each Indicator.
3) For a given fulfilled condition algorithm rule for each indicator, add to a variable the number of point "2" multiplied by the given timeframe in regard of point "1".
4) For the Maximum Total of indicators for each timeframe, weight in percentage the hits of the results.
5) For all the 3 timeframe results, calculate a total "ScoreRank" in Percentage score.
The concerns that the current code gives me:
1) The RSI(14) sometimes do not correspond to the RSI(14) plotted on a different AFL simple chart.
2) It appears that the Percentage Results are not give the corresponding addition given by the algorithms conditions. Sometimes when the condition do not hit a lower level, the percentage counter takes it like it does.
Here is the current AFL Code.
Code:
/*
XeL GENERAL Market Ranking Explorer
The ebeded code within this work are
FREELEY AND PUBLICLY written
for NON LUCRATIVE USE OF IT, and must remain as is.
Corresponding authorship and NON COMERCIAL LICENCING
attributes are explicitly Licenced by its authors.
Open-Sourced by: *NO COMERCIAL* Creative Commons Licence
www.creativecommons.org 2014.
Revision: 07/10/2014
Version: 1.0.alpha3
Authorship: @XeL_Arjona (Twitter, StockTweets)
____________________________________________________________________________________
====================================================================================*/
///////////////
// M A I N //
///////////////
// CLEAR VARIABLES
_SECTION_BEGIN("MAIN SCAN CRITERIA");
// PARAMETERS
RNKM = ParamList("Scan For:","OVERBOUGHT|OVERSOLD",1);
dTFW = Param("DAILY Rank Multiplier:",1,0,3,1);
wTFW = Param("WEEKLY Rank Multiplier:",2,0,3,1);
mTFW = Param("MONTHLY Rank Multipilier:",3,0,3,1);
F = ParamStr("RELATIVE SIMBOL (INDEX):","VTI");
P_R = Param("Daily Period for Ratios:",360,10,500,1);
// FORMULAS AND VARIABLES
FP = Foreign( F , "C" );
TimeFrameSet(inDaily) ;
MF = V * Avg ;
MFA = MA( MF , P_R ) ;
MFB = 100 * MF/MFA ;
BETA = (( P_R * Sum(ROC( C,1) * ROC(FP,1),P_R )) - (Sum(ROC(C,1),P_R) * Sum(ROC( FP,1),P_R))) / ((P_R * Sum((ROC(FP,1)^2 ),P_R)) - (Sum(ROC(FP,1 ),P_R)^2 ));
ALPHA = (Sum(ROC( C,1) ,P_R) - ( BETA ) * Sum( ROC( FP,1) ,P_R ) ) / P_R ;
RSQD = Correlation(FP,C,P_R)^2 ;
TC = C ;
YC = Ref( C, -1 );
FDayMonth = BarsSince(Month() != Ref(Month(),-1));
FDayYear = BarsSince(Year() != Ref(Year(),-1));
TtD_Pd = 100 * (Close - Ref(Close, -1) ) / Ref(Close, -1);
TtD_Pw = 100 * (Close - Ref(Close, -DayOfWeek()) ) / Ref(Close, -DayOfWeek());
TtD_Pm = 100 * (Close - Ref(Close, -FDayMonth) ) / Ref(Close, -FDayMonth);
TtD_Py = 100 * (Close - Ref(Close, -FDayYear) ) / Ref(Close, -FDayYear);
TimeFrameRestore();
_SECTION_END();
_SECTION_BEGIN("RSI");
///////////////////////////////
// Relative Streighn Index //
///////////////////////////////
// PARAMETERS
P_RSI = Param("Periods:",14,1,200,1);
RNK_RSI = Param("Rank Weight:",50,0,100,1);
// FORMULAS AND VARIABLES
// Rank TF Multipliers
RM_RSId = (dTFW * RNK_RSI) ;
RM_RSIw = (wTFW * RNK_RSI) ;
RM_RSIm = (mTFW * RNK_RSI) ;
// CONDITION ALGORITHMS
switch ( RNKM )
{
case "OVERBOUGHT" : TimeFrameSet( inDaily ) ;
RSId = RSI(P_RSI) ;
RSId1 = RSId > 50 ;
RSId2 = RSId > 70 ;
Rd_RSI1 = IIf(RSId1, RM_RSId, 0) ;
Rd_RSI2 = IIf(RSId2, RM_RSId, 0) ;
Rd_RSIT = RM_RSId * 2 ;
TimeFrameSet( inWeekly ) ;
RSIw = RSI(P_RSI) ;
RSIw1 = RSIw > 50 ;
RSIw2 = RSIw > 70 ;
Rw_RSI1 = IIf(RSIw1, RM_RSIw, 0) ;
Rw_RSI2 = IIf(RSIw2, RM_RSIw, 0) ;
Rw_RSIT = RM_RSIw * 2 ;
TimeFrameSet( inMonthly ) ;
RSIm = RSI(P_RSI) ;
RSIm1 = RSIm > 50 ;
RSIm2 = RSIm > 70 ;
Rm_RSI1 = IIf(RSIm1, RM_RSIm, 0) ;
Rm_RSI2 = IIf(RSIm2, RM_RSIm, 0) ;
Rm_RSIT = RM_RSIm * 2 ;
TimeFrameRestore() ; break;
case "OVERSOLD" : TimeFrameSet( inDaily ) ;
RSId = RSI(P_RSI) ;
RSId1 = RSId < 50 ;
RSId2 = RSId < 70 ;
Rd_RSI1 = IIf(RSId1, RM_RSId, 0) ;
Rd_RSI2 = IIf(RSId2, RM_RSId, 0) ;
Rd_RSIT = RM_RSId * 2 ;
TimeFrameSet( inWeekly ) ;
RSIw = RSI(P_RSI) ;
RSIw1 = RSIw < 50 ;
RSIw2 = RSIw < 70 ;
Rw_RSI1 = IIf(RSIw1, RM_RSIw, 0) ;
Rw_RSI2 = IIf(RSIw2, RM_RSIw, 0) ;
Rw_RSIT = RM_RSIw * 2 ;
TimeFrameSet( inMonthly ) ;
RSIm = RSI(P_RSI) ;
RSIm1 = RSIm < 50 ;
RSIm2 = RSIm < 70 ;
Rm_RSI1 = IIf(RSIm1, RM_RSIm, 0) ;
Rm_RSI2 = IIf(RSIm2, RM_RSIm, 0) ;
Rm_RSIT = RM_RSIm * 2 ;
TimeFrameRestore() ; break;
}
RT_RSIT = Rd_RSIT + Rw_RSIT + Rm_RSIT ;
_SECTION_END();
///////////////////////
// Trend Score Count //
///////////////////////
_SECTION_BEGIN("TrendScore");
// TOTALS
RTd = Rd_RSIT ;
RTw = Rw_RSIT ;
RTm = Rm_RSIT ;
RTT = RT_RSIT ;
// MASTER COUNT
dTS = IIf(RSId1, Rd_RSI1,0)+
IIf(RSId2, Rd_RSI2,0);
dTSW = 100 * dTS/RTd ;
wTS = IIf(RSIw1, Rw_RSI1,0)+
IIf(RSIw2, Rw_RSI2,0);
wTSW = 100 * wTS/RTw ;
mTS = IIf(RSIm1, Rm_RSI1,0)+
IIf(RSIm2, Rm_RSI2,0);
mTSW = 100 * mTS/RTm ;
ScoreRank = dTS + wTS + mTS ;
ScoreRankW = 100 * ScoreRank/RTT ;
_SECTION_END();
_SECTION_BEGIN("Explorer");
// FILTER
Filter = ScoreRank > 0 ;
;
// DISPLAY COLUMNS
//AddColumn (High52,"52 Week High");
//AddColumn (Low52,"52 Week Low");
AddTextColumn( FullName(),"NAME",colorWhite,colorBlack );
AddTextColumn( SectorID(1),"SECTOR",colorWhite,colorBlack );
AddTextColumn( IndustryID(1),"INDUSTRY",colorWhite,colorBlack );
AddColumn ( MF, "Today $Flow",1.0,IIf( TC > YC, colorGreen, colorRed));
AddColumn ( MFB, "$Flow Buzz vs Avg",1.0,IIf(MFA>Ref(MFA,-1),colorGreen,colorRed));
AddColumn ( C ,"Close",1.2,IIf( TC > YC, colorGreen,colorRed));
AddColumn ( TtD_Pd,"d%ROC",1.2,IIf( TtD_Pd > 0, colorGreen,colorRed),colorBlack);
AddColumn ( TtD_Pw,"w%ROC",1.2,IIf( TtD_Pw > 0, colorGreen,colorRed),colorBlack);
AddColumn ( TtD_Pm,"m%ROC",1.2,IIf( TtD_Pm > 0, colorGreen,colorRed),colorBlack);
AddColumn ( TtD_Py,"YoY%",1.2,IIf( TtD_Py > 0, colorGreen,colorRed),colorBlack);
AddColumn ( RSQD,"RSquared",1.2,IIf( RSQD >= .85, colorLime, IIf( RSQD >= .70 AND RSQD < .85, colorYellow,colorRed)),colorDarkGrey);
AddColumn ( ALPHA,"ALPHA",1.2,IIf( ALPHA > 0, colorLime,colorRed),colorDarkGrey);
AddColumn ( BETA,"BETA",1.2,IIf( BETA >= 1, colorLime,colorOrange),colorDarkGrey);
AddColumn ( dTSW,"DailySCR",1.2,colorLightGrey,colorDarkBlue);
AddColumn ( wTSW,"WeekSCR",1.2,colorLightGrey,colorDarkBlue);
AddColumn ( mTSW,"MonthSCR",1.2,colorLightGrey,colorDarkBlue);
//AddColumn (Beta,"( ß )",1.2,IIf(Beta>0,colorGreen,colorRed));
AddColumn (ScoreRankW,"RANK",1.0,colorWhite,colorBlue);
_SECTION_END();
XeL