OmniTrader Professional Forum OmniTrader Professional Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


Only Forum Moderators, Administrators, and the owner of this message may delete it.

 
Jim Dean

Sage
2000100010010010010025
Posts: 3433

Joined: 3/13/2006
Location: L'ville, GA

User Profile
 
Subject : RE: Help with making system out indicator.
Posted : 1/26/2015 1:35 PM
Post #23319 - In reply to #23318

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]

Deleting message 23319 : RE: Help with making system out indicator.


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.