Transcription of Formula Primer II - MetaStock
1 Advanced Formula WritingFormula Primer IIPrinted in the USAAll Rights ReservedCopyright 2017 MetaStock4548 South Atherton Dr, Suite 200 Salt Lake City, UT 84123 of ContentsChapter 1: 5An Approach to Formula Writing ..5 The Proper Mind-set ..5 What is not covered ..6 Chapter 2: A Firm 7 Defining the end result ..7 Know your environment ..8 Know your tools ..9 Chapter 3: Customizing the 10 Average True Range ..10A Wilder Smoothing Method ..12 Volume with the RSI ..13 Chapter 4: Simulation 17 What are Simulation Functions ..17 Tracking Positions ..17 Counting Equity ..19 Trade Entry Price ..21 That does not always work ..222 Chapter 5: Line 24 Horizontal lines ..24 fibonacci Retracement ..25 Automatic Trendlines.
2 29 Looking at this from a new angle ..33 Channels ..34 Chapter 6: The Logical Switch .. 38 Two state switches ..38 Why uses switches ..39 Three state switches ..42 But wait there's more ..43 Counting positions ..44 There are limits ..46 Chapter 7: Pivot 47 Middle of the road ..47 Highs and Lows ..50 Parts of a Whole ..52 Building blocks ..54 Chapter 8: Logical 58 Dynamic constants ..58 Normalization ..593 Sequential Constructions ..60 Divergences ..62 Chapter 9: Custom 66 Profit target ..66 Trailing stop ..68 Maximum Loss stops ..69 Time based stops ..70 Putting it all together ..71 Chapter 10: Extrapolating Higher Time 74 Starting Simple ..74 Exponential Changes ..77 Relative Applications ..79 Stochastics.
3 82 Chapter 11: Value to Generate 87A Simple Example ..87 More Math ..89 All is not so Simple ..91 Chapter 12: 92 What does a commentary do? ..92 What is needed to write a commentary? ..924 The Initial Framework ..94 Adding Calculated Values ..95 Conditional Logic ..98 Coding the WriteIf() ..99 Making the code shorter ..103 Write the Exit States ..103 The Last State ..106 Final Touches ..108 Appendix 1: Simulation 109 Appendix 2: 1125 Chapter 1: IntroductionAn Approach to Formula WritingEverybody is different and will approach problems and issues in different ways. Some people will look at the MetaStock Formula Language and may think of the various functions as tools in a workshop. Others may think of them as ingredients in kitchen.
4 I have always loved puzzles and building things so for me, a more appropriate analogy would Lego building blocks. With enough time, patience, and blocks, you can build just about following sections will introduce the reader to concepts and ideas not covered in the Formula Primer . It will assume an understanding of the MetaStock Formula language as well as a strong proficiency in MetaStock . A good working knowledge of Algebra is also helpful. The reader may be at a disadvantage without these new concepts will be presented as a task or problem to be solved. The issues that affect it will be discussed and then a solution explained. The solution presented may not be the best solution, but it will meet the requirements. In showing the process used to find the solutions, I hope to instill the reader with the knowledge and confidence to take what is presented and play.
5 Rearrange the blocks, so to speak, and perhaps find something you are confident in your skills, you can skip to the last part of each solution. Should that there be any questions on how that Formula was created, please review the step by step process that pre-ceded it. I have tried to be as complete as possible when explaining how each Formula was Proper Mind-setWhen I was just starting, I would be presented with an idea for a Formula and my thoughts would always tend toward "That should be possible so how would I do it?" After making sure I under-stood all that a Formula entailed, I would examine the specifications. A Formula is almost always either a pattern to be recognized or a calculation to be performed. Occasionally, it will be first step is to break it apart, see what the different pieces are.
6 If the Formula requires three different conditions, I would treat each condition as a separate Formula and write each part indi-vidually. If there was any doubt a part was not working correctly, I would test it by itself. Finally, I would combine them to make the finished same approach applies when defining a pattern. Separate each part that makes up the pattern and write those parts. Then link them together to form the final Formula . Taking my Lego analogy, if you want to build a house, you have to build 1) a base, 2) four walls, one of which must have a door, and 3) a roof. Build the parts and then combine them to form the house. Sometimes parts will have to be further divided. Continuing the above example, one wall must have door.
7 It may also need a window. Build the window and door, and then build the wall to con-tain them. Finally, add it to the model of the , there are other approaches and some of them will work better, some will be worse. But don't let the size or complexity of the final product cause despair or thoughts of impossible solu-tions. Use what you know. If you need a shape (function) you don't have, think about how you might construct it with what you have. Not permitting something to be impossible is the first step to accomplishing is not coveredThis text will not discuss external Formula DLLs. There are several DLLs that have been created and circulated on the internet that do one or more of the tasks that are discussed in the following chapters.
8 It is up to the author of any DLL to explain how to use his code. This text is focused on getting the most out of the MetaStock Formula is beyond the scope of this work to explain how to create a DLL. The computer languages involved usually require a year of more of course work to learn. If such understanding is already possessed, the MetaStock Developer s Kit (MDK) provides all the further knowledge 2: A Firm FoundationDefining the end result"If you don't know exactly where you're going, how will you know when you get there?"- Steve Maraboli, Life, the Truth, and Being FreeThe question used for one's direction in life is equally valid in writing formulas. Before you can write a Formula , you must know what you want it to do.
9 Having a vague idea or a general concept is not enough. You can try many things to find a solution, but if you don't know what the solution looks like, how will you find it?Consider the term "support". It has many meanings but for the moment, focus on the one pertain-ing to technical analysis. A rough definition is a price at which a security will stop downward movement and reverse direction. How is this identified? Support can be found at: Trendlines Channel bottoms Historical lows Indicators, like moving averages fibonacci levels Pivot pointsIf a Formula is to be written that uses support, a method of identifying that support must be defined. The method used will affect the final result as each method will likely find support at different price levels.
10 In places they may be the same, or nearly so, but in others the values will be different, possibly considerably are similar issues with other common concepts. The general idea is understood, but the spe-cifics are hazy. To write the Formula , the method must be defined. If you do not know how some-thing is defined or what something actually looks like, it will be very difficult to finish the equally important question is how much. Some patterns, when they are expressed in English, will use terms like "close to", "large", and "long". While these terms, and others like them, may express and describe the concept, they are vague. Formulas do not do well with vague. If a for-mula is looking for something to be close to some value, the writer of the Formula needs to define how close it has to be.