The download file has been overwritten with a new, slightly tidier, version.
I find the key concepts, demonstrated in the file, very helpful indeed. Arithmetic Mean, Geometric Mean and StdDev are a beautiful things (and I am not even a mathematician). My teacher taught me that "an apple doesn't ripen overnight" ... he used it in a different context but Tomaasz said the same about AB when he said "it takes time to sink in" ... this is a fundamental truth of learning. There are some hints in the file for new programmers: - understand the logic first - lay the logic out - start at the top and work sequentially, line by line, (this rules covers the majority of basic situations) - test the veracity of your logic/code line by line (in AB I do that by plotting everything I can ... one line at at time if I am stuck ... as I get better I can skip more and more blocks of lines because experience tells me they are correct if the syntax and logic are correct. In this case: - focus on method one - start at the top of the worksheet and find a way to express each line in AFL - leverage could be a Param function or optimizeable or a static variable or a variable that you change manually in your code. - you have the price series e.g. Close - you have the begin value of the Close - use the functions to create the rows as arrays - substitute the numerical factor, in the manual OHLC example, for the ShiftFactor array. That is easy enough. The most important thing is to steep yourself in the logic. --- In [email protected], "longarm61" <no...@...> wrote: > > Thanks for the replies, Brian. I'm very much inept when it comes to AFL so > I'll have to try to make sense of it all. In answer to your previous post, > my plan was to use it for charting, but backtesting capability might come in > handy too. Charting would be the priority though. > > Thanks again, > > Grant > > > --- In [email protected], "brian_z111" <brian_z111@> wrote: > > > > Grant, > > > > I found your idea interesting so I did a little bit more. > > > > > 1) make separate arrays for ROC(X,1) where X = O,H,L,C,Ave etc (as > > > >required) > > > > > > factorO = ROC(O,1);//as GrowthFactor e.g. 2% = 1.02, -2% = 0.98 > > > etc > > > > I missed a couple of steps out ... you probably figured that already but > > just in case here is an excel file that demos the logic ... I show two > > methods to produce a simulated leveraged price series from a base price > > series; log/antilog and relativeGeometricMean. > > > > Scroll down to section 2 Miscellaneous Files >> LeveragedPriceSeries.xls > > > > http://zboard.wordpress.com/downloads/ > > > > > > > > > > > > > > > > --- In [email protected], "brian_z111" <brian_z111@> wrote: > > > > > > To toggle your thinking: > > > > > > (I am just imagining a chart to start with ... not sure what your final > > > objective is ... if PLOTOHLC helps you could work it towards a > > > backtesting array version ... versions might be different depending on > > > whether you want it for chart reading, backtesting or both) > > > > > > 1) make separate arrays for ROC(X,1) where X = O,H,L,C,Ave etc (as > > > required) > > > > > > factorO = ROC(O,1);//as GrothFactor e.g. 2% = 1.02, -2% = 0.98 > > > etc > > > > > > 2) substitute factorO, factorH etc in PLOTOHLC example > > > - when you want to go back to 'Price', instead of leveraged Price, use > > > factor == 1, which is ROC neutral. > > > > > > 3) if you get something going there and you like it maybe ParamToggle > > > will let you switch from Price to Leveraged Price in live chart mode > > > > > > - ParamToggle is boolean so toggle P or LP yes or no? > > > - conditional statement (if toggle is yes use leveraged price array) > > > > > > There would be other ways so comeback if you want options. > > > > > > I think ATC can store conditioned arrays so you could also use that and > > > save leveraged Price arrays as pseudo tickers (if you aren't up to speed > > > on ATC reference Hermans PDF tutorial at the UKB). > > > > > > > > > > > > --- In [email protected], "longarm61" <norm1@> wrote: > > > > > > > > Thanks much, Brian, I will look into that. > > > > > > > > Grant > > > > > > > > --- In [email protected], "brian_z111" <brian_z111@> wrote: > > > > > > > > > > What about 211. (indexed from AFL by name) PLOTOHLC (Exploration / > > > > > Indicators) - plot custom OHLC chart (AFL 2.2) > > > > > > > > > > Will that do the job? > > > > > > > > > > > > > > > --- In [email protected], "longarm61" <norm1@> wrote: > > > > > > > > > > > > Hi, I'm guessing that this is a simple thing, but of course, it's > > > > > > not for me. I'm trying to simulate the performance of leveraged > > > > > > ETFs going back farther than they go back themselves, hence the > > > > > > following: > > > > > > > > > > > > I would like to plot a line which moves 2x percentage-wise the > > > > > > gain/loss of a particular stock PER DAY (bar). E.g., if I have SPY > > > > > > up, and SPY moves up 1% on Monday, the line moves up 2%. If SPY > > > > > > moves down .5% on Tuesday, the line moves down 1%. And so on. > > > > > > It'd be nice to have an option to switch between PRICE and > > > > > > PERCENTAGE on the current value (from the first bar showing to the > > > > > > last), but if it's a choice between one or the other, I'd prefer > > > > > > price. > > > > > > > > > > > > Thanks so much for any assistance on this. > > > > > > > > > > > > Grant > > > > > > > > > > > > > > > > > > > > >
