Page 1 of 3

Stochastic Momentum Index indicator

PostPosted: Sun Sep 05, 2010 10:55 pm
by Alexander.Gettinger
viewtopic.php?f=27&t=1870#p3972

SMI.png


Code: Select all
function Init()
    indicator:name("SMI indicator");
    indicator:description("SMI indicator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("Period_Q", "Period_Q", "Period_Q", 2);
    indicator.parameters:addInteger("Period_R", "Period_R", "Period_R", 8);
    indicator.parameters:addInteger("Period_S", "Period_S", "Period_S", 5);
    indicator.parameters:addInteger("Period_Signal", "Period_Signal", "Period_Signal", 5);

    indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("DATAclr", "Color of DATA line", "Color of DATA line", core.rgb(0, 255, 0));
    indicator.parameters:addColor("SIGNALclr", "Color of SIGNAL line", "Color of SIGNAL line", core.rgb(255, 0, 0));
end

local first;
local source = nil;
local Period_Q;
local Period_R;
local Period_S;
local Period_Signal;
local HQ;
local SM;
local HQ_MA_R;
local HQ_MA_S;
local SM_MA_R;
local SM_MA_S;
local sig;

function Prepare()
    source = instance.source;
    Period_Q=instance.parameters.Period_Q;
    Period_R=instance.parameters.Period_R;
    Period_S=instance.parameters.Period_S;
    Period_Signal=instance.parameters.Period_Signal;
    first = source:first()+math.max(Period_R,Period_S);
    HQ = instance:addInternalStream(first+Period_Q, 0);
    SM = instance:addInternalStream(first+Period_Q, 0);
    HQ_MA_R = core.indicators:create("EMA", HQ, Period_R);
    HQ_MA_S = core.indicators:create("EMA", HQ_MA_R.DATA, Period_S);
    SM_MA_R = core.indicators:create("EMA", SM, Period_R);
    SM_MA_S = core.indicators:create("EMA", SM_MA_R.DATA, Period_S);
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Period_Q .. ", " .. instance.parameters.Period_R .. ", " .. instance.parameters.Period_S .. ", " .. instance.parameters.Period_Signal .. ")";
    instance:name(name);
    DataBuff = instance:addStream("DataBuff", core.Line, name .. ".Data", "Data", instance.parameters.DATAclr, first);
    SignalBuff = instance:addStream("SignalBuff", core.Line, name .. ".Signal", "Signal", instance.parameters.SIGNALclr, first);
    sig = core.indicators:create("EMA", DataBuff, Period_Signal);
end

function Update(period, mode)
    if (period>first+Period_Q) then
     HQ[period]=core.max(source.high,core.rangeTo(period,Period_Q))-core.min(source.low,core.rangeTo(period,Period_Q));
     SM[period]=source.close[period]-(core.max(source.high,core.rangeTo(period,Period_Q))+core.min(source.low,core.rangeTo(period,Period_Q)))/2.;
     HQ_MA_R:update(mode);
     HQ_MA_S:update(mode);
     SM_MA_R:update(mode);
     SM_MA_S:update(mode);
     DataBuff[period]=100.*SM_MA_S.DATA[period]/(0.5*HQ_MA_S.DATA[period]);
     sig:update(mode);
     SignalBuff[period]=sig.DATA[period];
    end
end

SMI.lua
(2.83 KiB) Downloaded 2704 times

SMI with Alert.lua
(21.87 KiB) Downloaded 70 times

EURUSD m1 (09-05-2017 1031).png

MTF MCP SMI Heat Map with Alert.lua
(17.82 KiB) Downloaded 72 times

MTF MCP SMI Heat Map with Alert Carimwell.lua
(17.99 KiB) Downloaded 7 times

Based on the request.
viewtopic.php?f=27&t=65054&start=10

Re: SMI indicator

PostPosted: Mon Aug 22, 2011 2:29 am
by RJH501
Hello Alexander

Thank you for the SMI indicator. When you get time could you make the following improvements?

Thanks and Regards,

Richard

Re: SMI indicator

PostPosted: Mon Aug 22, 2011 2:32 am
by RJH501
Hello Alexander and Members;

A short description of the SMI for anyone interested:

"Stochastic Momentum Index"

SMI was created by William Blau in January 1993 issue of Technical Analysis of Stocks & Commodities. The SMI demonstrates where the close is relative to the middle of the last high/low range, in comparison to the close relative to the recent low/high with the Stochastic Oscillator, which resembles the Stochastic Momentum Index.
This oscillator shifts between 100 and 100 and can be a bit less inconstant than an equal period Stochastic Oscillator. The oscillator consists of 2 lines: the moving average of the SMI (red) and the SMI (blue). The SMI will be negative if the close is less than the middle point of the range. The SMI will be positive if the close is greater than the middle point of the range.
The SMI interpretation is in fact the same as that of the Stochastic Oscillator. The most ordinary way of using it is to trade from is to sell when the SMI rises above +40 and then returns to the point under that level and to purchase at the moment when the SMI decreases under -40 and then shifts back above it. Another trading sign is to purchase when the SMI shifts above the moving average, and sell when the SMI decreases below the moving average.
Usually before basing any trades on strict oversold or overbought levels, it is better to qualify the trendiness of the market using an indicator, for example, R-Squared. If indicators provide a non-trending market trades based on strict oversold or overbought, then levels should provide the most effective results.

Regards,

Richard

Re: SMI indicator

PostPosted: Mon Aug 22, 2011 2:48 am
by RJH501
Hello Alexander,

I have attached a Strategy outline for use with the SMI Indicator. When you get time would create this strategy using the SMI Indicator?

Thanks and Regards,

Richard

.pdf attachment outlines the SMI improvements and strategy

Re: SMI indicator

PostPosted: Sun Nov 20, 2011 5:06 pm
by Alexey
Hello,

The Marketscope application has been upgraded by FXCM this weekend. And a lot of users of the SMI.lua file mentionned in this topic, are embarrassed.
I mean after adding the SMI indicator to the marketscope, there isn't any signal now ... (Signal: H/A)
I think the SMI script need to be revised in order to be compatible again.

Do you have the same problem since the upgrade of yesterday ?

Best regards,


Alexey, for the members of the french community optionbinaire.net.

Re: SMI indicator

PostPosted: Sun Nov 20, 2011 6:12 pm
by Apprentice
Now I see what is missing.
Signal lines.
and I'll take a look tomorrow.

Re: SMI indicator

PostPosted: Mon Nov 21, 2011 4:01 am
by Apprentice
Signal Line Problem Fixed.

Re: SMI indicator

PostPosted: Mon Nov 21, 2011 8:47 am
by Alexey
Thank you very much for the revision.
It runs again now !
Bye.

Re: SMI indicator

PostPosted: Wed Nov 23, 2011 2:56 am
by wonder68
Hi Apprentice,

Could you please create an alert with this indicator ? Only an alert when both lines cross ?
Thanks for your help

Re: SMI indicator

PostPosted: Sat Jan 14, 2012 11:43 am
by nicolovitch
Hello members !

Do you have news for this alert (strategy) about the SMI ??

Thanks