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] |