Stock Portfolio Organizer
The ultimate porfolio management solution.
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Frecuency Distribution Returns for Amibroker (AFL)
Display Frecuency Distribution Returns Chart of selected ticker with
some statistical information.
Screenshots
Similar Indicators / Formulas
Indicator / Formula
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | _SECTION_BEGIN ( "Frecuency Distribution Returns" ); //Plot histogram of the number of bars which fall between percentiles between 2 data points // Porcentaje de cada barra y periodos a sumar. binpercent= Param ( "Numero de Barras" ,15,5,20,1); timeperiod= Param ( "period for observation" ,200,50,2000,50); ColorBar= ParamColor ( "Color barras" , colorAqua ); ColorText= ParamColor ( "Color Texto" , colorWhite ); // Escalares con la suma de apariciones frequency=0; f=0; //Recupera en un array los retornos diarios percent= Nz (100*( log ( C / Ref ( C ,-1)))); //percent=Nz(100*((L-Ref(C,-1))/Ref(C,-1))); //Diferencia porcentual entre el minimo y el cierre anterior // numero de barras dividiendo el 100% entre el % de cada barra mas 1 numbins=binpercent+1; //Obtiene la maxima y minima ganancia en el periodo yMax= SelectedValue ( HHV (percent,timeperiod))+0.01; yMin= SelectedValue ( LLV (percent,timeperiod))-0.01; //Obtiene el rango del minimo valor al maximo valor yRange=yMax-yMin; //divide el mismo entre el numero de barras de la grafica y asigna entonces el ancho de cada barra. BinSize=yRange/(numbins-1); // primer loop de 1 al numero de barras for (i=0;i<=numbins;i++) //el array f se carga inversamente con el valor de las escalares minimo +el tamoƱo de la barra por el numero de la barra //esto para configurar los limites de cada barra { f[ BarCount -i-1]= SelectedValue (ymin+binsize*i); } //Segundo Loop este va a cargar la suma de las frecuencias //Genera el loop uno por cada barra for (i=1;i<=numbins;i++) { frequency[ BarCount -numbins+(i-1)]= SelectedValue ( Sum (((percent>=f[ BarCount -i]) AND (percent<=f[ BarCount -(i+1)])),timeperiod)); } //Tercer Loop genera el string con los nombres del ejes de las x. XaxisNames = "" ; for ( y = 1; y < numbins; y++ ) { XaxisNames = XaxisNames + " | " + StrFormat ( "%.2f" , f[ BarCount -y])+ "," + StrFormat ( "%.2f" , f[ BarCount -y]) ; } _N (XaxisNames = XaxisNames + " | " + StrFormat ( "%.2f" , f[ BarCount -numbins])) ; ///////////////////////////////////////////////// // Drawing code & helper functions //////////////////////////////////////////////// GfxSetOverlayMode ( 0 ); GfxSelectFont ( "Tahoma" , 12 ); GfxSetTextColor (colortext); GfxSetBkMode ( 1 ); YOffset = 25; XOffset = 15; // ========================================= FUNCIONES ================================================= // Pinta las barras ARG ( texto del eje x, barra a pintar, function DrawBar( text, bar, numbars, y, Miny, Maxy ) { BarWidth = ( Status ( "pxwidth" ) - 4 * XOffset )/( numbars + 1 ); BarHeight = Status ( "pxheight" ) - 2 * YOffset; relpos = ( y - Miny ) / (Maxy - Miny ); xp = XOffset + ( bar + 0.5 ) * BarWidth; yp = YOffset + BarHeight * ( 1 - relpos ); xe = XOffset + ( bar + 1 ) * BarWidth; ye = YOffset + BarHeight * ( 1 - ( -miny )/( maxy - miny ) ); if ( y > 0 ) { GfxGradientRect ( xp, yp, xe , ye, colorBar, colorBar ); } else { GfxGradientRect ( xp, ye, xe , yp, ColorHSB ( 0, 20, 255 ), ColorHSB ( 0, 255 * ( 1 - relpos ), 255 ) ); } GfxSelectFont ( "Tahoma" , 8 ); GfxTextOut ( text, xp, ye ); // valores eje x GfxSelectFont ( "Tahoma" , 12 ); GfxTextOut ( StrFormat ( "%.0f" , y ), xp+10, yp-20 ); // valor de la barra } // Pinta el grid y los niveles function DrawLevels( Miny, Maxy ) { range = Maxy - Miny; grid = 100; if ( range < 10 ) grid = 1; else if ( range < 20 ) grid = 2; else if ( range < 50 ) grid = 5; else if ( range < 100 ) grid = 10; else if ( range < 200 ) grid = 20; else if ( range < 500 ) grid = 50; width = Status ( "pxwidth" ) - 4 * XOffset; height = Status ( "pxheight" ) - 2 * YOffset; GfxSelectPen ( colorBlack , 1, 2 ); for ( y = grid * ceil ( Miny / grid ); y <= grid * floor ( Maxy / grid ); y += grid ) { yp = YOffset + Height * ( 1 - ( y - Miny ) / (Maxy - Miny ) ); GfxMoveTo ( XOffset, yp ); GfxLineTo ( XOffset + width , yp ); GfxTextOut ( "" + y, XOffset + 2 + width, yp ); } GfxSelectPen ( colorBlack , 1, 0 ); GfxMoveTo ( XOffset, YOffset ); GfxLineTo ( XOffset + width, YOffset ); GfxLineTo ( XOffset + width, YOffset + Height ); GfxLineTo ( XOffset , YOffset + Height ); GfxLineTo ( XOffset , YOffset ); } function DisplayFrecuency() { Bar = 0; //Alto MinAvgProf = MaxAvgProf = 0; //determina alto de las frecuencias for ( y = 0; y < numbins; y++ ) { Chg = frequency[ BarCount -numbins+y]; MinAvgProf = Min ( MinAvgProf, Chg ); MaxAvgProf = Max ( MaxAvgProf, Chg ); } // Pinta las barras for ( y = 0; y < numbins-1; y++ ) { Chg = frequency[ BarCount -numbins+y]; DrawBar( StrExtract (XaxisNames, y+1 ), Bar++, numbins-1, Chg, MinAvgProf , MaxAvgProf ); } DrawLevels( MinAvgProf , MaxAvgProf ); //pinta el grid } //////////////////////////// // Main program - chart type switch //////////////////////////// DisplayFrecuency(); _N (Title = StrFormat ( "Symbol: {{NAME}} Date: {{DATE}} \n\n" + "FRECUENCY DISTRIBUTION RETURNS\n" + "\nPeriods : " + WriteVal (timeperiod,1.0) + " " + Interval (2) + "\n\nMax " + Interval (2) + " Return : " + WriteVal (yMax-0.01,1.2) + " %%" + "\nMin " + Interval (2) + " Return : " + WriteVal (yMin+0.01,1.2) + " %%" + "\nAverage " + Interval (2) + " Return : " + WriteVal ( MA (percent,timeperiod)) + " %%" + "\nStandard Deviation : " + WriteVal ( StDev (percent,timeperiod)) + "\n\nMedian : " + WriteVal ( Median (percent,timeperiod),1.3)+ "\nVaR Level 99 : " + WriteVal ( Percentile (percent,timeperiod,1),1.2) + " %%" )); _SECTION_END (); _SECTION_BEGIN ( "Background Color" ); BKswitch = ParamToggle ( "Background Color" , "On,Off" ,1); OUTcolor = ParamColor ( "Outer Panel Color" , colorWhite ); TitleColor = ParamColor ( "Title Color " , ColorRGB (245,245,245)); if ( NOT BKswitch) { SetChartBkColor (OUTcolor); // color of outer border Gradient = ParamToggle ( "Gradient Background Y/N" , "NO|YES" ); INUPcolor = ParamColor ( "Inner Panel Upper" , colorLightYellow ); INDNcolor = ParamColor ( "Inner Panel Lower" , colorSeaGreen ); if (gradient) SetChartBkGradientFill (INUPcolor,INDNcolor,TitleColor); // color of inner panel } _SECTION_END (); |
3 comments
Leave Comment
Please login here to leave a comment.
Back
How it works?
how to use this indicator can you please explain?
Hi!
This is a statistical tool. Not properly an indicator.