HB,
To
smooth out the risk, I would like to try to properly position size as
well as normalize the risk per trade based on the "Average Standard
Deviation of Daily Percent Returns", and do some back testing and see what
happens on lesser than daily time frames as well...
I would like to
use it on a 1Min base database, but have it be time "Interval()
Independent", so, as I select a view of a different time frame,
it numerically remains proportionally constant per viewing
interval().
So, I
started with a 1 Min database and ...
TimeFrameSet( inDaily );
// switch to
Daily timeframe /* Daily Percent Returns from 1Min Bars
*/ DailyPercentReturn = abs((Close -
Ref(C,-1)) / Close); TimeFrameRestore(); // restore time frame to original
TimeFrameSet( inDaily ); // switch now to Daily //AvgDailyPercentReturn = MA(StDev(abs(MA(
DailyPercentReturn , 15 )),15),15); AvgDailyPercentReturn = StDev(abs(MA(
DailyPercentReturn , 20)),20); TimeFrameRestore();
// restore time frame
to original TimeFrameSet( inDaily ); // switch to Daily frame /* ATR Daily
Bars */ DailyATR15 = ATR(15); // 1N Risk in Daily Frame TimeFrameRestore();
// restore time frame to
original //Plot( Close,
"Price", colorWhite, styleCandle | styleOwnScale);
Plot(Close,"Close",128,1); //Plot(
TimeFrameExpand( DailyPercentReturn , inDaily ), "Daily Pecent Returns",
colorBlue ); //Plot( TimeFrameExpand( AvgDailyPercentReturn *Close , inDaily
), "Risk Normalized Daily ", colorWhite ); //Plot( TimeFrameExpand( DailyATR15 , inDaily
), "DailyATR15 ", colorWhite); Plot( TimeFrameExpand( Close +
(AvgDailyPercentReturn *Close) , inDaily ), "\nClose + Risk Normalized Daily
",
colorGreen ); Plot( TimeFrameExpand( ((Close +
(AvgDailyPercentReturn *Close) + Close - (AvgDailyPercentReturn
*Close))/2) , inDaily ), "\nRisk Normalized Avg Daily Percent
Returns Average ",
colorWhite ); Plot( TimeFrameExpand( Close -
(AvgDailyPercentReturn *Close) , inDaily ), "\nClose - Risk Normalized Daily ", colorRed
);
//////////////// Thanks MV
Hi Mr. Valley --
I recognize this as Figure 22.5 in Quantitative
Trading Systems. It is not intended to be plotted. It is intended to define
the cumulative distribution function that will later be used to
generate pseudo-random variables.
What is it you want to
accomplish?
Thanks, Howard
On 12/3/07, Mr. Valley <valleymj@xxxxxxxxnet>
wrote: > Hopefully gracious soul can help me. > I am having a very
difficult time trying to plot something so easy as a c > style function
I think and I just don't "get it". > Sometimes I can get it to work and
others not. > > What is the logic behind plotting a "function"
used this way. > > Just thinking of plotting a distribution of the
Close or even a random > number just to get it working... > ...the
[index] brackets are throwing me off... with a syntax error... > >
Thanks in advance... > > Mr Valley > >
//////////////////////////////////////////////////////////////////////////// >
/////////// > > // InitializeNormalCDF.afl > // >
function InitializeNormalCDF() > > // array for the
Normalized Cum Dist function. > { > NormCDF[0] = -3.090; >
NormCDF[1] = -2.326; > NormCDF[2] = -2.053; > NormCDF[3] =
-1.881; > NormCDF[4] = -1.751; > NormCDF[5] = -1.645; >
NormCDF[6] = -1.555; > NormCDF[7] = -1.476; > NormCDF[8] =
-1.405; > NormCDF[9] = -1.341; > NormCDF[10] = -1.282; >
NormCDF[11] = -1.227; > NormCDF[12] = -1.175; > NormCDF[13] =
-1.126; > NormCDF[14] = -1.080; > NormCDF[15] = -1.036; >
NormCDF[16] = -0.994; > NormCDF[17] = -0.954; > NormCDF[18] =
-0.915; > NormCDF[19] = -0.878; > NormCDF[20] = -0.842; >
NormCDF[21] = -0.806; > NormCDF[22] = -0.772; > NormCDF[23] =
-0.739; > NormCDF[24] = -0.706; > NormCDF[25] = -0.674; >
NormCDF[26] = -0.643; > NormCDF[27] = -0.613; > NormCDF[28] =
-0.583; > NormCDF[29] = -0.553; > NormCDF[30] = -0.524; >
NormCDF[31] = -0.496; > NormCDF[32] = -0.468; > NormCDF[33] =
-0.440; > NormCDF[34] = -0.412; > NormCDF[35] = -0.385; >
NormCDF[36] = -0.358; > NormCDF[37] = -0.332; > NormCDF[38] =
-0.305; > NormCDF[39] = -0.279; > NormCDF[40] = -0.253; >
NormCDF[41] = -0.228; > NormCDF[42] = -0.202; > NormCDF[43] =
-0.176; > NormCDF[44] = -0.151; > NormCDF[45] = -0.126; >
NormCDF[46] = -0.100; > NormCDF[47] = -0.075; > NormCDF[48] =
-0.050; > NormCDF[49] = -0.025; > NormCDF[50] = 0.000; >
NormCDF[51] = 0.025; > NormCDF[52] = 0.050; > NormCDF[53] =
0.075; > NormCDF[54] = 0.100; > NormCDF[55] = 0.126; >
NormCDF[56] = 0.151; > NormCDF[57] = 0.176; > NormCDF[58] =
0.202; > NormCDF[59] = 0.228; > NormCDF[60] = 0.253; >
NormCDF[61] = 0.279; > NormCDF[62] = 0.305; > NormCDF[63] =
0.332; > NormCDF[64] = 0.358; > NormCDF[65] = 0.385; >
NormCDF[66] = 0.412; > NormCDF[67] = 0.440; > NormCDF[68] =
0.468; > NormCDF[69] = 0.496; > NormCDF[70] = 0.524; >
NormCDF[71] = 0.553; > NormCDF[72] = 0.583; > NormCDF[73] =
0.613; > NormCDF[74] = 0.643; > NormCDF[75] = 0.674; >
NormCDF[76] = 0.706; > NormCDF[77] = 0.739; > NormCDF[78] =
0.772; > NormCDF[79] = 0.806; > NormCDF[80] = 0.842; >
NormCDF[81] = 0.878; > NormCDF[82] = 0.915; > NormCDF[83] =
0.954; > NormCDF[84] = 0.994; > NormCDF[85] = 1.036; >
NormCDF[86] = 1.080; > NormCDF[87] = 1.126; > NormCDF[88] =
1.175; > NormCDF[89] = 1.227; > NormCDF[90] = 1.281; >
NormCDF[91] = 1.341; > NormCDF[92] = 1.405; > NormCDF[93] =
1.476; > NormCDF[94] = 1.555; > NormCDF[95] = 1.645; >
NormCDF[96] = 1.751; > NormCDF[97] = 1.881; > NormCDF[98] =
2.054; > NormCDF[99] = 2.326; > NormCDF[100] = 3.090; >
return(Null); > } > > > // plot goes here ... I
think > > > > //
NormalRandomizedNumber.afl > // > function
NormalRandomNumber() > { > Index = int(100* rand()) +
1; > return(NormCDF[index]); > } > > // plot goes
here ... I think >
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
__,_._,___
|