Stochastic Momentum Index indicator

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Stochastic Momentum Index indicator

Postby Alexander.Gettinger » Sun Sep 05, 2010 10:55 pm

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 2734 times

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

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

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

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

Based on the request.
viewtopic.php?f=27&t=65054&start=10
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3113
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: SMI indicator

Postby RJH501 » Mon Aug 22, 2011 2:29 am

Hello Alexander

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

Thanks and Regards,

Richard
Attachments
SMI IMPROVEMENTS..JPG
RJH501
 
Posts: 84
Joined: Mon May 30, 2011 8:38 pm

Re: SMI indicator

Postby RJH501 » Mon Aug 22, 2011 2:32 am

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
RJH501
 
Posts: 84
Joined: Mon May 30, 2011 8:38 pm

Re: SMI indicator

Postby RJH501 » Mon Aug 22, 2011 2:48 am

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
Attachments
SMI IMPROVEMENTS.pdf
(49.25 KiB) Downloaded 1260 times
RJH501
 
Posts: 84
Joined: Mon May 30, 2011 8:38 pm

Re: SMI indicator

Postby Alexey » Sun Nov 20, 2011 5:06 pm

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.
Alexey
 
Posts: 4
Joined: Sun Nov 20, 2011 4:51 pm

Re: SMI indicator

Postby Apprentice » Sun Nov 20, 2011 6:12 pm

Now I see what is missing.
Signal lines.
and I'll take a look tomorrow.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18487
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: SMI indicator

Postby Apprentice » Mon Nov 21, 2011 4:01 am

Signal Line Problem Fixed.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 18487
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: SMI indicator

Postby Alexey » Mon Nov 21, 2011 8:47 am

Thank you very much for the revision.
It runs again now !
Bye.
Alexey
 
Posts: 4
Joined: Sun Nov 20, 2011 4:51 pm

Re: SMI indicator

Postby wonder68 » Wed Nov 23, 2011 2:56 am

Hi Apprentice,

Could you please create an alert with this indicator ? Only an alert when both lines cross ?
Thanks for your help
wonder68
 
Posts: 33
Joined: Tue Jul 19, 2011 12:25 pm

Re: SMI indicator

Postby nicolovitch » Sat Jan 14, 2012 11:43 am

Hello members !

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

Thanks
nicolovitch
 
Posts: 6
Joined: Sat Jan 14, 2012 11:26 am

Next

Return to Custom Indicators

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 5 guests