Current location | Thread information | |
![]() ![]() ![]() ![]() ![]() ![]() |
Last Activity 7/6/2025 3:47 AM 68 replies, 61188 viewings |
Printer friendly version |
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
I have started converting all the base OT indicators into OmniLanguage scripts. This is mainly intended as an example reference for helping you learn how to use OmniLanguage. Some of you have asked in the past to get the formulas so you can tweak the calculations so here they are =). I am working on this in my down time and I will post more as I have the chance to write them. Some indicators may not make it to the list any time soon if at all due to the complexity of the formulas (I.E. OT Pivots points). Some scripts are dependent on other scripts attached here. If you get compile error messages that say some variable name with the prefix of OTind or OTSind is not declared then please check here for the script you need. These scripts were written in OT2009 and may not work in OT08 due to the difference in parsers. Click Here to download the zip file containing all indicator script files. (2-8-23 Link Fixed) *Update 3-2-09* All of indicators are done with the exception of the following indicators V,O,H,L,C Price And HighestHigh/LowestLow indicators - Thought these were too basic to add Commodity Selection Index (Futures) - Margin is require to calculate. Unable to get this value in OL. Correlation Normalized COT Index (Futures) - We do not have access to COT data in OL COT Net Longs (Futures) - We do not have access to COT data in OL Seasonality (Futures) - We do not have access to seasonality data in OL Linear Regression Line - This indicator cheats and we are unable to code cheating indicators in OL. Details of this indicator can be found at the following thread. http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=2086&posts=1 ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | ||
^ Top | |||
Xaiver Comelli![]() Member ![]() Posts: 28 Joined: 11/15/2008 Location: Raleigh, NC ![]() |
Many many thanks for such a great undertaken.... ...still I'll push the envelops :) :) :) and do encourage you to make a effort (might be a big one) and provide the formula for the OT PivotPoint. I had the formula provided by members of this forum (a great one!), which I use on a regular basis; however, it has some very minor flaws which could be solved if you provide OT formula... Thanks again! | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Matthew - What a great Christmas present! Thank you!!! Both for educational (coding) purposes, and for educational (understanding indicators) and for development starting-points, this is GREAT. I, too, would consider the Pivot Points code to be incredibly useful, particularly if it could be adapted for use as function calls with other indicators. I presume we are talking about OT's short/med/long pivots ... not floor-pivots. Please keep these on your list, even if you don't do them first! Thanks! | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Downloads would be a lot easier if you also provided a zip file with all of them ... we could extract any that we want. Thanks! | ||
^ Top | |||
Manfred![]() Veteran ![]() ![]() Posts: 210 Joined: 4/2/2006 Location: South Africa ![]() |
Matthew, thanks for such great work and as JD says a fab xmas present :-) Have been missing such a wonderful resource for a long while. Of course ya guessed it - the one you were thinking of skipping is one of the main one's I'd like to see. Pivot points! i.e. like the default Pivots(7) indicator with a return of the current Pivot level value for use in systems code. Ideally, for a current project what I'm looking for is to determine the last pivot swing high and pivot swing low level to base other calcs such as fibs off. Thanks | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Hi, Matthew - Manfred's post made me realize that I had not been very specific in my request re Pivot Points code. Since you've been posting code that duplicates the indicators, I presume that a "pivot" indicator you might create would be along the same lines ... ie it would calculate and draw all the same lines that we see when we select short, medium or long pivots in the Patterns box. From that code, we could extract whatever we needed to implement things of a specific nature. It's hard to predict exactly what all those needs may be. Some people might just want to know about the last validated PP, some might also want the most recent one not-yet-confirmed. Some might want the last two high or last two low. Some might want the slopes of the connecting lines. Some might want the bars (xaxis), some the values (yaxis), some both. So, rather than providing just some of these items, or trying to guess what they all might be, I suggest that you simply provide code that generates the S/M/L lines (all of them) on the chart, and leave it to us to parse out the parts we want. The only "special" variant of that which might be useful ... and might be a natural byproduct of the code anyway, would be to provide a parametric Pivots call ... not just ShortPivots(), MedPivots(), LongPivots(), but allow for one parameter that scales smoothly between/beyond those three canned periods. If you can provide the general code, I'll be happy to volunteer to parse it out into a bunch of variants for specifics that other users request, to save you the time (presuming that will in fact help :~) Thanks again for undertaking this project! Jim | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Hi, Matthew: If you get stumped on the LR indicators, I can probably help. The only one that I'd consider "useless" is the one that draws a straight line across the entire pane ... I never figured out what good it would be. Let me know if you'd like me to work up the code for you. Thanks a lot for doing this! Any chance of Pivot code appearing within the next month? | ||
^ Top | |||
01439![]() Regular ![]() ![]() Posts: 63 Joined: 5/24/2006 ![]() |
Matthew, Thanks for the ZIP file you loaded today. Happy New Year! | ||
^ Top | |||
TP![]() Veteran ![]() ![]() Posts: 125 Joined: 3/17/2006 Location: KC ![]() |
WOW Matthew. And double WOW as Tom H would say. Great idea and great customer service. Happy new year to you. TP | ||
^ Top | |||
Bill Kelemen![]() Regular ![]() ![]() Posts: 65 Joined: 12/22/2006 Location: Riverisde, CT ![]() |
Matthew, Thanks a lot for putting this together. Happy New Year Bill | ||
^ Top | |||
Steven S![]() Member Posts: 10 Joined: 1/3/2009 ![]() |
Thanks Matthew for the formulas. This is great for a novice system creator. This is probably a stupid question but how do you add H,L,C,O to an indicator for instance SMA. Instead of the SMA being created on close it will be calculated on the H - SMA (H,10)? Could this be done to any indicator that calculates itself on the close? Thanks in advance. Steven | ||
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
Steven, Please see the following FAQ. http://www.omnitrader.com/omnitrader/proforum/thread-view.asp?threadid=1683&posts=1 Also you can take a look at the OTindMACD indicator for an example. You will see that the signal line is created by using a EMA of the MACD line. | ||
^ Top | |||
Drew![]() Legend ![]() Posts: 509 Joined: 6/13/2008 ![]() |
Matthew, Great thread. I, amongst all other OT users, greatly appreciate your contribution. Apologies if asking too much, but do you think you could also provide some formulas for the stops? | ||
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
Most systems and/or stops are based off indicators. Once the Indicators are completed I can start working on systems and stops. | ||
^ Top | |||
Drew![]() Legend ![]() Posts: 509 Joined: 6/13/2008 ![]() |
thanks Matthew | ||
^ Top | |||
Steven S![]() Member Posts: 10 Joined: 1/3/2009 ![]() |
Thanks Matthew. I will give it a try. | ||
^ Top | |||
Steven S![]() Member Posts: 10 Joined: 1/3/2009 ![]() |
Matthew, I have been trying to create the ability to put in H,L,O options within a moving average and have digested what you wrote in the OT2009 reply. I understand how to do SMA(H,10) when creating a scan in omniscan but still don't seem to be able to do it in omni language when writing an indicator. I noticed in the OTindMovingAverageEnvelope description there is IF Then statements showing H,L,O,C parameters in the settings window. How do I write parameters into SMA omnilanguage for H,L,O,C so that only that parameter is being used in the calculation of the SMA? I hope I have written this correctly. Thanks. Steven | ||
^ Top | |||
Manfred![]() Veteran ![]() ![]() Posts: 210 Joined: 4/2/2006 Location: South Africa ![]() |
Hi Steven S, Butting in here so maybe my answer is too simplistic but if you're asking how to get one of OHL or C into your Omilanguage code assuming one is using built in functions like the SMA(H,10) you mention. Well in your example SMA(H,10) - the H in there is the H of OHLC so if you say wanted SMA(C,10) you could, also of course SMA(O,10) or SMA(L,10) or really whatever you wished to SMA in this case. e.g. you could do something like Dim A, B As single A = (H+L)/2 B = SMA(A,10) for example. OTOH if youre asking how to modify Matthew's code to say use only one of OHL or C in the SMA calcs well do something like this: (Caveat I never tested it so may have missed something below) Also note you will also need to have OTSindMAEnvelopeUpper indicator in the OT VBA/indicator folder for this code to work. 'cut and paste below #Indicator '#PARAM "HighPriceField", 2, 1, 4 '#PARAM "LowPriceField", 2, 1, 4 'or delete the above 2 lines #PARAM "Periods", 9 #PARAM "PercentAbove", 1 #PARAM "PercentBelow", 1 #PARAM "Offset", 0, 0, 50 Dim fHighPrice, fHighMA, fLowPrice, fLowMA, fUpperBand, fLowerBand as Single 'Now delete the following If then statements 'If HighPriceField = 1 Then ' fHighPrice = O 'ElseIf HighPriceField = 2 Then ' fHighPrice = H 'ElseIf HighPriceField = 3 Then ' fHighPrice = L 'ElseIf HighPriceField = 4 Then ' fHighPrice = C 'End If 'now add this line instead fHighPrice = H 'you could also change the above H to any of OHLC price i.e. whatever input you want to keep constant - as opposed to #param user changeable. 'Now delete the following If then statements 'If LowPriceField = 1 Then ' fLowPrice = O 'ElseIf LowPriceField = 2 Then ' fLowPrice = H 'ElseIf LowPriceField = 3 Then ' fLowPrice = L 'ElseIf LowPriceField = 4 Then ' fLowPrice = C 'End If 'now add this line instead fHighPrice = L 'you could also change the above L to any of OHLC price i.e. whatever input you want to keep constant - as opposed to #param user changeable. fHighMA = SMA(fHighPrice, Periods) fLowMA = SMA(fLowPrice, Periods) If Bar >= Periods - 1 Then fHighMA *= 1 + PercentAbove/100 fLowMA *= 1 - PercentBelow/100 End If fUpperBand = OTSindMAEnvelopeUpper(HighPriceField, Periods, PercentAbove)[Offset] fLowerBand = OTSindMAEnvelopeLower(LowPriceField, Periods, PercentBelow)[Offset] PlotPrice("Upper Band", fUpperBand) PlotPrice("Lower Band", fLowerBand) Return 0 '---- you can cut and paste the above and it *should* compile OK 'HTH, Cheers [Edited by Manfred on 1/5/2009 12:21 PM] | ||
^ Top | |||
Steven S![]() Member Posts: 10 Joined: 1/3/2009 ![]() |
Manfred, Thanks for the assistance. What I was trying to do originally was rewrite Matthew's SMA code to be able to use H,L,O,or C as the value that price is calculating from instead of only being able to use close (which is the default). I am a novice when it comes to writing code, so could I put in Dim A,B as single A = H B = SMA(A,"periods"), or is there a way to add a parameter with H,L,O,orC as the choices in his code or would I have to write a new indicator that uses Matthews SMA in it? I hope I am making sense? Thanks. Steven | ||
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
If you are changing the SMA the only line you need to change is fSMA = Sum(Periods)/Periods More specifically the Sum function. Just like with most other function calls it uses the close price as the default value. As pointed out in the FAQ I mentioned earlier most function calls have an 'overload' or a second way to call it. This overload will allow you to specify the values to use for the calculations. So you could change it to fSMA = Sum(H, Periods)/Periods or fSMA = Sum(L, Periods)/Periods or fSMA = Sum(O, Periods)/Periods If you wanted to make it fancy you could add a parameter that allows you to dynamically choose the value. #Indicator #PARAM "Periods", 14 #PARAM "PriceField", 2, 1, 4 Dim fPrice, fSMA as Single If PriceField = 1 Then fPrice = O ElseIf PriceField = 2 Then fPrice = H ElseIf PriceField = 3 Then fPrice = L ElseIf PriceField = 4 Then fPrice = C End If fSMA = Sum(fPrice, Periods)/Periods PlotPrice("SMA", fSMA) Return fSMA | ||
^ Top | |||
Steven S![]() Member Posts: 10 Joined: 1/3/2009 ![]() |
Matthew, Thanks for the help. I went with the fancier plan, and it worked great. Is there a programming book for novices that you might suggest to help me in my learning curve ie. "VBA for dummies". Steven | ||
^ Top | |||
Matthew Greenslet![]() Idol ![]() ![]() ![]() ![]() Posts: 2077 Joined: 2/27/2006 ![]() |
Any beginners guide to VB or VBA should do the trick. This should provide both enough logical programming concepts as well as VB syntax examples of how to structure your logic to give you the jump start in to writing in OmniLanguage. OmniLanguage is a purposely simplistic language to reduce the amount of VB syntax you need to learn. I would focus more heavily on logic structure rather than syntax. As far as VB syntax the only real concepts you need to know is.. What is a variable and how do I create one for the type I need? What is a variable type? What are If...Then...Else statements? What are For...Next loops And Do While Loop and how do I use them? More importantly how do avoid getting stuck in one? Most everything else is a pseudo language which is OmniLanguage. If you wanted to take it to the next level you could learn... What is an array and how are they used? What is the difference between a sub and a function? What is a method overload? From there you will understand a little more what is happening behind the scenes. | ||
^ Top | |||
jaxin![]() Veteran ![]() ![]() Posts: 222 Joined: 3/28/2006 Location: Vancouver ![]() |
Matthew.... you make me scared to update to omnitrader 2009. I have wriiten many of my own formula, and if you are having trouble... just imagine how much time I will have to waste. Any suggestions? | ||
^ Top | |||
Jim Dean![]() Sage ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3433 Joined: 3/13/2006 Location: L'ville, GA ![]() |
Jaxin: No need to fear - MG is here! :=D Seriously - differences are small. 09's adherance to VB is better than 08's. If you've already programmed on the 08 version, then you've learned 99% of the necessary stuff. The only main diff is variable carryover - you don't need the A=A[1] statements any more. Yes, you may need to update some code, but if you do it all at once, you get the hang of things quicker. If it's code you downloaded, then someone else prob already fixed it. | ||
^ Top | |||
jaxin![]() Veteran ![]() ![]() Posts: 222 Joined: 3/28/2006 Location: Vancouver ![]() |
Jim, I have 102 formula's to change.... and don't even know where to start... nor do I have the time and patience. |
Legend | Action | Notification | |||
Administrator
Forum Moderator |
Registered User
Unregistered User |
![]() |
Toggle e-mail notification |