 This accout has been deleted
|
I modified a stochastic momentum indicator by Mel Dickover by adding a signal line and using the original formula by Blau. Since I no experience with programming, I was amazed that it works just like the TOS platform indicator. I want to make a system that produces a long signal when the SMI line crosses above signal line and vice versa for the short signal. I also wanted to produce code to do the same in omniscan. Unfortunately, as this indicator is coded, I have no idea how to do this. I don't know how to access "SMI" to write a crossover with the EMA(3) of the SMI. Any nudges in the right direction would be greatly appreciated. Indicator code listed below:
#Indicator
'MySMI
'Stochastic Momentum Index indicator
'with signal line
'Based off initial indicator, SMI
' Coded by Mel Dickover April 2012
'------------------------------------------
#param "lookback", 5
#param "thresholdLong",-80
#param "thresholdShort",+80
dim temp1, temp2, temp3, temp4, temp5, temp6 as single
dim x as single
dim y as single
temp1 = (HHV(H,lookback)+LLV(L,lookback))*0.5 ' C
temp2 = C[0] - temp1 ' D
temp3 = EMA(temp2,3) 'DS1
temp4 = EMA(temp3,3) 'DS2
temp5 = EMA((HHV(H,lookback) - LLV(L,lookback)),3) 'DHL
temp6 = ema(temp5*0.5,3) 'DHL2
x = 100*(temp4/temp6)
y = EMA(x,3)
plot("SMI",x)
plot("Signal line",y)
plot("Thresholdlong",thresholdLong)
plotLabel(thresholdLong)
plot("Thresholdshort",thresholdShort)
plotLabel(thresholdshort)
Return x ' Return the value calculated by the indicator
Return y ' Return the value calculated by the signal line
Attached file : mySMI.PNG (111KB - 404 downloads)
|
Jim Dean
 Sage
       Posts: 3433
Joined: 3/13/2006
Location: L'ville, GA
User Profile |
Here is a quick and dirty solution ... first, a mod to the Indicator so you can use it in an OScan ... the Return value will be +1 when SMI is greater than its EMA(3), and will be -1 when it's less than the EMA(3) ... OmniScan formula would be MySMI(lookback,-80,80) > 0 for long, or < 0 for short. Note that this is an extended STATE, not a single bar EVENT (system uses event):
#Indicator
'MySMI
'Stochastic Momentum Index indicator
'Returns +1 or -1 if above or below signal line
'Based off initial indicator, SMI
' Coded by Mel Dickover April 2012
'------------------------------------------
#param "lookback", 5
#param "thresholdLong",-80
#param "thresholdShort",+80
dim temp1, temp2, temp3, temp4, temp5, temp6 as single
dim x as single
dim y as single
temp1 = (HHV(H,lookback)+LLV(L,lookback))*0.5 ' C
temp2 = C[0] - temp1 ' D
temp3 = EMA(temp2,3) 'DS1
temp4 = EMA(temp3,3) 'DS2
temp5 = EMA((HHV(H,lookback) - LLV(L,lookback)),3) 'DHL
temp6 = ema(temp5*0.5,3) 'DHL2
x = 100*(temp4/temp6)
y = EMA(x,3)
plot("SMI",x)
plot("Signal line",y)
plot("Thresholdlong",thresholdLong)
plotLabel(thresholdLong)
plot("Thresholdshort",thresholdShort)
plotLabel(thresholdshort)
if x > y then
Return 1 ' bullish state
elseif x < y then
Return -1 ' bearish state
else
Return 0
end if
To make a system out of it, modify the code at the end and change the #Indicator at the start to #System and save it in the VBA\Systems folder:
#System
'MySMI
'Stochastic Momentum Index system creates
'Long/Short signal when crossover/under
'Based off initial indicator, SMI
' Coded by Mel Dickover April 2012
'------------------------------------------
#param "lookback", 5
#param "thresholdLong",-80
#param "thresholdShort",+80
dim temp1, temp2, temp3, temp4, temp5, temp6 as single
dim x as single
dim y as single
temp1 = (HHV(H,lookback)+LLV(L,lookback))*0.5 ' C
temp2 = C[0] - temp1 ' D
temp3 = EMA(temp2,3) 'DS1
temp4 = EMA(temp3,3) 'DS2
temp5 = EMA((HHV(H,lookback) - LLV(L,lookback)),3) 'DHL
temp6 = ema(temp5*0.5,3) 'DHL2
x = 100*(temp4/temp6)
y = EMA(x,3)
plot("SMI",x)
plot("Signal line",y)
plot("Thresholdlong",thresholdLong)
plotLabel(thresholdLong)
plot("Thresholdshort",thresholdShort)
plotLabel(thresholdshort)
if x > y and x[1] <= y[1] then
Signal = LongSignal
elseif x < y and x[1] >= y[1]then
Signal = ShortSignal
end if
[Edited by Jim Dean on 1/26/2015 5:13 PM]
|
 This accout has been deleted
|
Jim,
Thank you! Thank you! Thank you! I still have some hair left before pulling it all out. It worked nicely. For omniscan, I added the condition:
MySMIMODIFIED(5,-80,80) > 0 AND
MySMIMODIFIED(5,-80,80)[1] < 1
which gives me the crossover signal I needed.
You have just given me back at least an hour a day in preparation time.
Much gratitude for your help.
Paul
|