FXCM Forex Trading

Stochastic signals

The custom signals are published in this forum.

Moderator: admin

Stochastic signals

Postby Alexander.Gettinger » Thu Aug 19, 2010 2:54 am

There are several ways to interpretation a Stochastic Oscillator. Three popular methods include:

1. Overbought / Oversold
Buy when the Oscillator %K falls below a specific level (e.g., 20) and then rises above that level. Sell when the Oscillator rises above a specific level (e.g., 80) and then falls below that level.

Stochastic_Overbought_Oversold_Signal.png


Code: Select all
function Init()
    strategy:name("Stochastic Overbought/Oversold signal");
    strategy:description("");

    strategy.parameters:addGroup("Parameters");
   
    strategy.parameters:addString("Period", "Timeframe", "", "m5");
    strategy.parameters:setFlag("Period", core.FLAG_PERIODS);
   
    strategy.parameters:addInteger("K", "K", "Parameter of stochastic", 5);
    strategy.parameters:addInteger("SD", "SD", "Parameter of stochastic", 3);
    strategy.parameters:addInteger("D", "D", "Parameter of stochastic", 3);
   
    strategy.parameters:addInteger("DownLevel", "DownLevel", "", 20);
    strategy.parameters:addInteger("UpLevel", "UpLevel", "", 80);

    strategy.parameters:addString("TypeSignal", "Type of signal", "", "direct");
    strategy.parameters:addStringAlternative("TypeSignal", "direct", "", "direct");
    strategy.parameters:addStringAlternative("TypeSignal", "reverse", "", "reverse");

    strategy.parameters:addGroup("Signals");
    strategy.parameters:addBoolean("ShowAlert", "Show Alert", "", true);
    strategy.parameters:addBoolean("PlaySound", "Play Sound", "", false);
    strategy.parameters:addFile("SoundFile", "Sound File", "", "");
end

local SoundFile;
local gSourceBid = nil;
local gSourceAsk = nil;
local first;

local BidFinished = false;
local AskFinished = false;
local LastBidCandle = nil;

local Stochastic;
local EMA8;

function Prepare()
    ShowAlert = instance.parameters.ShowAlert;
    if instance.parameters.PlaySound then
        SoundFile = instance.parameters.SoundFile;
    else
        SoundFile = nil;
    end
   
    assert(not(PlaySound) or (PlaySound and SoundFile ~= ""), "Sound file must be specified");
    assert(instance.parameters.Period ~= "t1", "Signal cannot be applied on ticks");

    ExtSetupSignal("Altr Trend signal:", ShowAlert);

    gSourceBid = core.host:execute("getHistory", 1, instance.bid:instrument(), instance.parameters.Period, 0, 0, true);
    gSourceAsk = core.host:execute("getHistory", 2, instance.bid:instrument(), instance.parameters.Period, 0, 0, false);

    Stochastic = core.indicators:create("STOCHASTIC", gSourceBid, instance.parameters.K, instance.parameters.SD, instance.parameters.D);

    first = Stochastic.DATA:first();

    local name = profile:id() .. "(" .. instance.bid:instrument() .. "(" .. instance.parameters.Period  .. instance.parameters.K  .. instance.parameters.SD  .. instance.parameters.D  .. instance.parameters.TypeSignal  .. instance.parameters.DownLevel  .. instance.parameters.UpLevel  .. ")";
    instance:name(name);
end

local LastDirection=nil;

-- when tick source is updated
function Update()
    if not(BidFinished) or not(AskFinished) then
        return ;
    end

    local period;

    -- update moving average
    Stochastic:update(core.UpdateLast);

    -- calculate enter logic
    if LastBidCandle == nil or LastBidCandle ~= gSourceBid:serial(gSourceBid:size() - 1) then
        LastBidCandle = gSourceBid:serial(gSourceBid:size() - 1);

        period = gSourceBid:size() - 1;
        if period > first then
         if Stochastic.K[period-1]>instance.parameters.UpLevel and Stochastic.K[period]<instance.parameters.UpLevel and instance.parameters.TypeSignal=="direct" and LastDirection~=-1 then
          ExtSignal(gSourceBid, period, "Sell", SoundFile);
          LastDirection=-1;
         end
         if Stochastic.K[period-1]<instance.parameters.DownLevel and Stochastic.K[period]>instance.parameters.DownLevel and instance.parameters.TypeSignal=="direct" and LastDirection~=1 then
          ExtSignal(gSourceAsk, period, "Buy", SoundFile);
          LastDirection=1;
         end

         if Stochastic.K[period-1]<instance.parameters.DownLevel and Stochastic.K[period]>instance.parameters.DownLevel and instance.parameters.TypeSignal=="reverse" and LastDirection~=-1 then
          ExtSignal(gSourceBid, period, "Sell", SoundFile);
          LastDirection=-1;
         end
         if Stochastic.K[period-1]>instance.parameters.UpLevel and Stochastic.K[period]<instance.parameters.UpLevel and instance.parameters.TypeSignal=="reverse" and LastDirection~=1 then
          ExtSignal(gSourceAsk, period, "Buy", SoundFile);
          LastDirection=1;
         end
       
        end
    end
end

function AsyncOperationFinished(cookie)
    if cookie == 1 then
        BidFinished = true;
    elseif cookie == 2 then
        AskFinished = true;
    end
end

local gSignalBase = "";     -- the base part of the signal message
local gShowAlert = false;   -- the flag indicating whether the text alert must be shown

-- ---------------------------------------------------------
-- Sets the base message for the signal
-- @param base      The base message of the signals
-- ---------------------------------------------------------
function ExtSetupSignal(base, showAlert)
    gSignalBase = base;
    gShowAlert = showAlert;
    return ;
end

-- ---------------------------------------------------------
-- Signals the message
-- @param message   The rest of the message to be added to the signal
-- @param period    The number of the period
-- @param sound     The sound or nil to silent signal
-- ---------------------------------------------------------
function ExtSignal(source, period, message, soundFile)
    if source:isBar() then
        source = source.close;
    end
    if gShowAlert then
        terminal:alertMessage(source:instrument(), source[period], gSignalBase .. message, source:date(period));
    end
    if soundFile ~= nil then
        terminal:alertSound(soundFile, false);
    end
end
Attachments
Stochastic_Overbought_Oversold_Signal.lua
(5.57 KiB) Downloaded 1687 times
Last edited by Alexander.Gettinger on Thu Aug 19, 2010 3:25 am, edited 1 time in total.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby Alexander.Gettinger » Thu Aug 19, 2010 2:56 am

2. Crossover

Buy when the %K line rises above the %D line and sell when the %K line falls below the %D line.

Stochastic_Crossover_Signal.png


Code: Select all
function Init()
    strategy:name("Stochastic Crossover signal");
    strategy:description("");

    strategy.parameters:addGroup("Parameters");
   
    strategy.parameters:addString("Period", "Timeframe", "", "m5");
    strategy.parameters:setFlag("Period", core.FLAG_PERIODS);
   
    strategy.parameters:addInteger("K", "K", "Parameter of stochastic", 5);
    strategy.parameters:addInteger("SD", "SD", "Parameter of stochastic", 3);
    strategy.parameters:addInteger("D", "D", "Parameter of stochastic", 3);

    strategy.parameters:addString("TypeSignal", "Type of signal", "", "direct");
    strategy.parameters:addStringAlternative("TypeSignal", "direct", "", "direct");
    strategy.parameters:addStringAlternative("TypeSignal", "reverse", "", "reverse");

    strategy.parameters:addGroup("Signals");
    strategy.parameters:addBoolean("ShowAlert", "Show Alert", "", true);
    strategy.parameters:addBoolean("PlaySound", "Play Sound", "", false);
    strategy.parameters:addFile("SoundFile", "Sound File", "", "");
end

local SoundFile;
local gSourceBid = nil;
local gSourceAsk = nil;
local first;

local BidFinished = false;
local AskFinished = false;
local LastBidCandle = nil;

local Stochastic;
local EMA8;

function Prepare()
    ShowAlert = instance.parameters.ShowAlert;
    if instance.parameters.PlaySound then
        SoundFile = instance.parameters.SoundFile;
    else
        SoundFile = nil;
    end
   
    assert(not(PlaySound) or (PlaySound and SoundFile ~= ""), "Sound file must be specified");
    assert(instance.parameters.Period ~= "t1", "Signal cannot be applied on ticks");

    ExtSetupSignal("Altr Trend signal:", ShowAlert);

    gSourceBid = core.host:execute("getHistory", 1, instance.bid:instrument(), instance.parameters.Period, 0, 0, true);
    gSourceAsk = core.host:execute("getHistory", 2, instance.bid:instrument(), instance.parameters.Period, 0, 0, false);

    Stochastic = core.indicators:create("STOCHASTIC", gSourceBid, instance.parameters.K, instance.parameters.SD, instance.parameters.D);

    first = Stochastic.DATA:first();

    local name = profile:id() .. "(" .. instance.bid:instrument() .. "(" .. instance.parameters.Period  .. instance.parameters.K  .. instance.parameters.SD  .. instance.parameters.D  .. instance.parameters.TypeSignal  .. ")";
    instance:name(name);
end

local LastDirection=nil;

-- when tick source is updated
function Update()
    if not(BidFinished) or not(AskFinished) then
        return ;
    end

    local period;

    -- update moving average
    Stochastic:update(core.UpdateLast);

    -- calculate enter logic
    if LastBidCandle == nil or LastBidCandle ~= gSourceBid:serial(gSourceBid:size() - 1) then
        LastBidCandle = gSourceBid:serial(gSourceBid:size() - 1);

        period = gSourceBid:size() - 1;
        if period > first then
         if Stochastic.K[period-1]>Stochastic.D[period-1] and Stochastic.K[period]<Stochastic.D[period] and instance.parameters.TypeSignal=="direct" and LastDirection~=-1 then
          ExtSignal(gSourceBid, period, "Sell", SoundFile);
          LastDirection=-1;
         end
         if Stochastic.K[period-1]<Stochastic.D[period-1] and Stochastic.K[period]>Stochastic.D[period] and instance.parameters.TypeSignal=="direct" and LastDirection~=1 then
          ExtSignal(gSourceAsk, period, "Buy", SoundFile);
          LastDirection=1;
         end

         if Stochastic.K[period-1]<Stochastic.D[period-1] and Stochastic.K[period]>Stochastic.D[period] and instance.parameters.TypeSignal=="reverse" and LastDirection~=-1 then
          ExtSignal(gSourceBid, period, "Sell", SoundFile);
          LastDirection=-1;
         end
         if Stochastic.K[period-1]>Stochastic.D[period-1] and Stochastic.K[period]<Stochastic.D[period] and instance.parameters.TypeSignal=="reverse" and LastDirection~=1 then
          ExtSignal(gSourceAsk, period, "Buy", SoundFile);
          LastDirection=1;
         end
       
        end
    end
end

function AsyncOperationFinished(cookie)
    if cookie == 1 then
        BidFinished = true;
    elseif cookie == 2 then
        AskFinished = true;
    end
end

local gSignalBase = "";     -- the base part of the signal message
local gShowAlert = false;   -- the flag indicating whether the text alert must be shown

-- ---------------------------------------------------------
-- Sets the base message for the signal
-- @param base      The base message of the signals
-- ---------------------------------------------------------
function ExtSetupSignal(base, showAlert)
    gSignalBase = base;
    gShowAlert = showAlert;
    return ;
end

-- ---------------------------------------------------------
-- Signals the message
-- @param message   The rest of the message to be added to the signal
-- @param period    The number of the period
-- @param sound     The sound or nil to silent signal
-- ---------------------------------------------------------
function ExtSignal(source, period, message, soundFile)
    if source:isBar() then
        source = source.close;
    end
    if gShowAlert then
        terminal:alertMessage(source:instrument(), source[period], gSignalBase .. message, source:date(period));
    end
    if soundFile ~= nil then
        terminal:alertSound(soundFile, false);
    end
end
Attachments
StochasticCrossover_Signal.lua
(5.3 KiB) Downloaded 1288 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby Alexander.Gettinger » Thu Aug 19, 2010 3:11 am

3. Divergences between the stochastic lines and the price

Stochastic_Divergence.png


Indicators for find divergence:

Code: Select all
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
function Init()
    indicator:name("Stochastic Divergence");
    indicator:description("");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

    indicator.parameters:addInteger("K", "K", "Parameter of stochastic", 5);
    indicator.parameters:addInteger("SD", "SD", "Parameter of stochastic", 3);
    indicator.parameters:addInteger("D", "D", "Parameter of stochastic", 3);
    indicator.parameters:addBoolean("I", "Indicator mode", "Keep true value to display labels and lines. Set this parameter to false when the indicator is used in another indicator.", true);
    indicator.parameters:addColor("D_color", "Color of Divergence line", "", core.rgb(0, 155, 255));
    indicator.parameters:addColor("UP_color", "Color of Uptrend", "", core.rgb(255, 0, 0));
    indicator.parameters:addColor("DN_color", "Color of Downtend", "", core.rgb(0, 255, 0));
end

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- Parameters block
local I;
local DD;
local UP_color;
local DN_color;

local first;
local source = nil;

-- Streams block
local D = nil;
local UP = nil;
local DN = nil;
local Stochastic = nil;
local lineid = nil;

-- Routine
function Prepare()
    I = instance.parameters.I;
    DD = instance.parameters.DD;
    UP_color = instance.parameters.UP_color;
    DN_color = instance.parameters.DN_color;
    source = instance.source;
    Stochastic = core.indicators:create("STOCHASTIC", source, instance.parameters.K,instance.parameters.SD,instance.parameters.D);
    first = Stochastic.DATA:first();

    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.K .. ", " .. instance.parameters.SD .. ", " .. instance.parameters.D .. ")";
    instance:name(name);
    D = instance:addStream("Stochastic", core.Line, name .. ".Stochastic", "Stochastic", instance.parameters.D_color, first, -1);
    D:addLevel(20);
    D:addLevel(80);
    if I then
        UP = instance:createTextOutput ("Up", "Up", "Wingdings", 10, core.H_Center, core.V_Top, instance.parameters.UP_color, -1);
        DN = instance:createTextOutput ("Dn", "Dn", "Wingdings", 10, core.H_Center, core.V_Bottom, instance.parameters.DN_color, -1);
    else
        UP = instance:addStream("UP", core.Bar, name .. ".UP", "UP", instance.parameters.D_color, first, -1);
        DN = instance:addStream("DN", core.Bar, name .. ".DN", "DN", instance.parameters.D_color, first, -1);
    end
end

local pperiod = nil;
local pperiod1 = nil;
local line_id = 0;

-- Indicator calculation routine
function Update(period, mode)
    -- if recaclulation started - remove all
    if pperiod ~= nil and pperiod > period then
        core.host:execute("removeAll");
    end
    pperiod = period;
    -- process only candles which are already closed closed.
    if pperiod1 ~= nil and pperiod1 == source:serial(period) then
        return ;
    end
    pperiod1 = source:serial(period)
    period = period - 1;

    Stochastic:update(mode);
    if period >= first then
        D[period] = Stochastic.K[period];
        if period >= first + 2 then
            processBullish(period - 2);
            processBearish(period - 2);
        end
    end
end

function processBullish(period)
    if isTrough(period) then
        local curr, prev;
        curr = period;
        prev = prevTrough(period);
        if prev ~= nil then
            if Stochastic.K[curr] > Stochastic.K[prev] and source.low[curr] < source.low[prev] then
                if I then
                    DN:set(curr, Stochastic.K[curr], "\225", "Classic bullish");
                    line_id = line_id + 1;
                    core.host:execute("drawLine", line_id, source:date(prev), Stochastic.K[prev], source:date(curr), Stochastic.K[curr], DN_color);
                else
                    DN[period] = curr - prev;
                end
            elseif Stochastic.K[curr] < Stochastic.K[prev] and source.low[curr] > source.low[prev] then
                if I then
                    DN:set(curr, Stochastic.K[curr], "\225", "Reversal bullish");
                    line_id = line_id + 1;
                    core.host:execute("drawLine", line_id, source:date(prev), Stochastic.K[prev], source:date(curr), Stochastic.K[curr], DN_color);
                else
                    DN[period] = -(curr - prev);
                end
            end
        end

    end
end

function isTrough(period)
    local i;
    if Stochastic.K[period] < Stochastic.K[period - 1] and Stochastic.K[period] < Stochastic.K[period + 1] then
        for i = period - 1, first, -1 do
            if Stochastic.K[i] > 80 then
                return true;
            elseif Stochastic.K[period] > Stochastic.K[i] then
                return false;
            end
        end
    end
    return false;
end

function prevTrough(period)
    local i;
    for i = period - 5, first, -1 do
        if Stochastic.K[i] <= Stochastic.K[i - 1] and Stochastic.K[i] < Stochastic.K[i - 2] and
           Stochastic.K[i] <= Stochastic.K[i + 1] and Stochastic.K[i] < Stochastic.K[i + 2] then
           return i;
        end
    end
    return nil;
end

function processBearish(period)
    if isPeak(period) then
        local curr, prev;
        curr = period;
        prev = prevPeak(period);
        if prev ~= nil then
            if Stochastic.K[curr] < Stochastic.K[prev] and source.high[curr] > source.high[prev] then
                if I then
                    UP:set(curr, Stochastic.K[curr], "\226", "Classic bearish");
                    line_id = line_id + 1;
                    core.host:execute("drawLine", line_id, source:date(prev), Stochastic.K[prev], source:date(curr), Stochastic.K[curr], UP_color);
                else
                    UP[period] = curr - prev;
                end
            elseif Stochastic.K[curr] > Stochastic.K[prev] and source.high[curr] < source.high[prev] then
                if I then
                    UP:set(curr, Stochastic.K[curr], "\226", "Reversal bearish");
                    line_id = line_id + 1;
                    core.host:execute("drawLine", line_id, source:date(prev), Stochastic.K[prev], source:date(curr), Stochastic.K[curr], UP_color);
                else
                    UP[period] = -(curr - prev);
                end
            end
        end

    end
end

function isPeak(period)
    local i;
    if Stochastic.K[period] > Stochastic.K[period - 1] and Stochastic.K[period] > Stochastic.K[period + 1] then
        for i = period - 1, first, -1 do
            if Stochastic.K[i] < 20 then
                return true;
            elseif Stochastic.K[period] < Stochastic.K[i] then
                return false;
            end
        end
    end
    return false;
end

function prevPeak(period)
    local i;
    for i = period - 5, first, -1 do
        if Stochastic.K[i] >= Stochastic.K[i - 1] and Stochastic.K[i] > Stochastic.K[i - 2] and
           Stochastic.K[i] >= Stochastic.K[i + 1] and Stochastic.K[i] > Stochastic.K[i + 2] then
           return i;
        end
    end
    return nil;
end

and
Code: Select all
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
function Init()
    indicator:name("Stochastic Divergence");
    indicator:description("Shows Stochastic Divergence");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);

    indicator.parameters:addInteger("K", "K", "Parameter of stochastic", 5);
    indicator.parameters:addInteger("SD", "SD", "Parameter of stochastic", 3);
    indicator.parameters:addInteger("D", "D", "Parameter of stochastic", 3);
    indicator.parameters:addColor("UP_color", "Color of Uptrend", "", core.rgb(255, 0, 0));
    indicator.parameters:addColor("DN_color", "Color of Downtend", "", core.rgb(0, 255, 0));
end

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- Parameters block
local first;
local source = nil;

-- Streams block
local lineid = nil;
local dummy;

-- Routine
function Prepare()
    UP_color = instance.parameters.UP_color;
    DN_color = instance.parameters.DN_color;
    source = instance.source;
    Stochastic = core.indicators:create("STOCHASTIC_DIVERGENCE", source, instance.parameters.K,instance.parameters.SD,instance.parameters.D, false);
    first = Stochastic.DATA:first();

    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.K .. ", " .. instance.parameters.SD .. ", " .. instance.parameters.D .. ")";
    instance:name(name);
    dummy = instance:addStream("D", core.Line, name .. ".D", "D", UP_color, 0);
end

local pperiod = nil;
local pperiod1 = nil;
local line_id = 0;

-- Indicator calculation routine
function Update(period, mode)
    local l;
    -- if recaclulation started - remove all
    if pperiod ~= nil and pperiod > period then
        core.host:execute("removeAll");
    end
    pperiod = period;
    -- process only candles which are already closed closed.
    if pperiod1 ~= nil and pperiod1 == source:serial(period) then
        return ;
    end
    pperiod1 = source:serial(period)
    period = period - 1;

    Stochastic:update(mode);

    if Stochastic:getStream(1):hasData(period - 2) then
        l = math.abs(Stochastic:getStream(1)[period - 2]);
        local prev = period - 2 - l;
        line_id = line_id + 1;
        core.host:execute("drawLine", line_id, source:date(prev), source.high[prev], source:date(period - 2), source.high[period - 2], UP_color);
    end
    if Stochastic:getStream(2):hasData(period - 2) then
        l = math.abs(Stochastic:getStream(2)[period - 2]);
        local prev = period - 2 - l;
        line_id = line_id + 1;
        core.host:execute("drawLine", line_id, source:date(prev), source.low[prev], source:date(period - 2), source.low[period - 2], DN_color);
    end
end


For work Stochastic_Divergence1.lua must be installed Stochastic_Divergence.lua
Attachments
Stochastic_Divergence.lua
(7.21 KiB) Downloaded 1440 times
Stochastic_Divergence1.lua
(2.78 KiB) Downloaded 1214 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby Alexander.Gettinger » Thu Aug 19, 2010 3:24 am

Stochastic divergence signal:

Code: Select all
function Init()
    strategy:name("Stochastic Divergence");
    strategy:description("Signals when the Stochastic Divergence detected");

    strategy.parameters:addInteger("K", "K", "Parameter of stochastic", 5);
    strategy.parameters:addInteger("SD", "SD", "Parameter of stochastic", 3);
    strategy.parameters:addInteger("D", "D", "Parameter of stochastic", 3);

    strategy.parameters:addString("Period", "Time frame", "", "m1");
    strategy.parameters:setFlag("Period", core.FLAG_PERIODS);

    strategy.parameters:addBoolean("ShowAlert", "Show Alert", "", true);
    strategy.parameters:addBoolean("PlaySound", "Play Sound", "", false);
    strategy.parameters:addFile("SoundFile", "Sound file", "", "");
end

local SoundFile;
local gSource = nil;        -- the source stream

function Prepare()

    ShowAlert = instance.parameters.ShowAlert;

    if instance.parameters.PlaySound then
        SoundFile = instance.parameters.SoundFile;
    else
        SoundFile = nil;
    end

    assert(not(PlaySound) or (PlaySound and SoundFile ~= ""), "Sound file must be specified");

    ExtSetupSignal(profile:id() .. ":", ShowAlert);

    assert(instance.parameters.Period ~= "t1", "Can't be applied on ticks!");

    gSource = ExtSubscribe(1, nil, instance.parameters.Period, true, "bar");

    local name = profile:id() .. "(" .. instance.bid:instrument()  .. "(" .. instance.parameters.Period  .. ")" .. "," .. instance.parameters.K .. "," .. instance.parameters.SD .. "," .. instance.parameters.D .. ")";
    instance:name(name);
end

local Stochastic = nil;

-- when tick source is updated
function ExtUpdate(id, source, period)
    if Stochastic == nil then
        Stochastic = core.indicators:create("STOCHASTIC_DIVERGENCE", gSource, instance.parameters.K,instance.parameters.SD,instance.parameters.D, false);
    end

    Stochastic:update(core.UpdateLast);


    if period <= instance.parameters.K + 10 then
        return ;
    end

    local v;

    if Stochastic:getStream(1):hasData(period - 2) then
        v = Stochastic:getStream(1)[period - 2];
        if v ~= 0 then
            ExtSignal(gSource, period, "Bearish", SoundFile);
        end
    end
    if Stochastic:getStream(2):hasData(period - 2) then
        v = Stochastic:getStream(2)[period - 2];
        if v ~= 0 then
            ExtSignal(gSource, period, "Bullish", SoundFile);
        end
    end
end

dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");


For work Stochastic_Divergence_Signal.lua must be installed indicator Stochastic_Divergence.lua
Attachments
Stochastic_Divergence_Signal.lua
(2.48 KiB) Downloaded 1035 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby thetruth » Mon Sep 12, 2011 8:52 am

can you develop an strategy for this indicator? (stochastic divergence.lua)
thanks
thetruth
 
Posts: 43
Joined: Thu Feb 25, 2010 3:39 pm

Re: Stochastic signals

Postby Apprentice » Tue Sep 13, 2011 4:36 am

First, it is not indicators it is a signal.
Can you tell me for which signal you want strategy to be developed.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 14799
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Stochastic signals

Postby thetruth » Wed Oct 05, 2011 4:42 pm

Apprentice wrote:First, it is not indicators it is a signal.
Can you tell me for which signal you want strategy to be developed.

Sorry for mistake, is for signal stochastic_divergence_signal thanks!
thetruth
 
Posts: 43
Joined: Thu Feb 25, 2010 3:39 pm

Re: Stochastic signals

Postby Alexander.Gettinger » Fri Oct 07, 2011 10:28 am

OK.
I shall write the strategy for you.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby Alexander.Gettinger » Sat Oct 08, 2011 11:30 am

Strategies:

Stochastic_Overbought_Oversold_Strategy.lua
(12.44 KiB) Downloaded 957 times


StochasticCrossover_Strategy.lua
(12.25 KiB) Downloaded 883 times


Stochastic_Divergence_Strategy.lua
(12.42 KiB) Downloaded 1001 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 2518
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Stochastic signals

Postby germano » Sun Oct 09, 2011 1:04 pm

Sirs,

I work with the Stochastic indicator. On the graph of Marketscope2 I have mounted "Stochastic_Divergence.lua" and "Stochastic_Divergence1.lua" and all is OK.
Then I followed the steps indicated in "How to Download and Install a Custom Signal/Strategy" to mount “Stochastic_Divergence_Signal.lua.” in “Menage custom strategy” and in "Add Panel Strategy" I have select "Stochastic_Divergence_Signal.lua.", I have set the parameters and I have click OK, but I can't place it on the chart.
Why this? Can someone help me?

Thanks
Germano
germano
 
Posts: 7
Joined: Thu Jul 29, 2010 8:59 am

Next

Return to Custom Signals

Who is online

Users browsing this forum: No registered users and 2 guests