Go Back   DailyFX Forum > FXCM Products and Services > FXProgrammers > Discussion / Support Forum > Indicator SDK Support

Reply
 
Thread Tools Rate Thread
  #1 (permalink)  
Old 10-12-2009, 01:51 PM
Member
 
Join Date: Oct 2008
Posts: 474
Nikolay.Gekht is on a distinguished road
Example: Fractal Indicator

Here is a source code for the Bill Williams 5-bar Fractal oscillator as it is described at Fractals — Technical Indicators, Technical Analysis

1) Create the file fractal.lua
2) Copy the code below into this file
3) Save the file
or
1,2,3) Just right-click on this link and choose "Save As..." from the menu.

4) Go to "Charts/Chart/Manage Custom Indicators" menu of the Trading Station
5) Click "Load"
6) Choose the fractal.lua file created at the previous steps

Unfortunately, the current version of the Marketscope does not support the labels, so, the fractals
are specified as the red (up) or green (down) bars in the oscillator area.

Code:
function Init()
    indicator:name("Fractal");
    indicator:description("Bill Williams Fractal oscillator")
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);

    indicator.parameters:addColor("UpC", "Color of the up fractal", "", core.rgb(255, 0, 0));
    indicator.parameters:addColor("DownC", "Color of the down fractal", "", core.rgb(0, 255, 0));
end

local source;
local up, down;

function Prepare()
    source = instance.source;
    local name = profile:id();
    instance:name(name);
    up = instance:addStream("Up", core.Bar, name .. ".Up", "Up", instance.parameters.UpC, 4, -2);
    up:addLevel(1);
    up:addLevel(0);
    up:addLevel(-1);
    down = instance:addStream("Down", core.Bar, name .. ".Down", "Down", instance.parameters.DownC, 4, -2);
end

function Update(period, mode)
    if (period > 6) then
        local curr = source.high[period - 2];
        if (curr > source.high[period - 4] and curr > source.high[period - 3] and
            curr > source.high[period - 1] and curr > source.high[period]) then
            up[period - 2] = 1;
        else
            up[period - 2] = nil;
        end
        curr = source.low[period - 2];
        if (curr < source.low[period - 4] and curr < source.low[period - 3] and
            curr < source.low[period - 1] and curr < source.low[period]) then
            down[period - 2] = -1;
        else
            down[period - 2] = nil;
        end
    end
end
Attached Images
 

Last edited by Nikolay.Gekht; 10-12-2009 at 02:18 PM..
Reply With Quote
  #2 (permalink)  
Old 11-14-2009, 07:58 AM
Registered User
 
Join Date: Oct 2009
Posts: 4
ak_nomiss is an unknown quantity at this point
Angry

anyway can you change this to indicator so it can show like the regular fractors ? there is no way we can use this indicator and find out where are the fractors stand
Reply With Quote
  #3 (permalink)  
Old 11-16-2009, 12:46 PM
Member
 
Join Date: Oct 2008
Posts: 474
Nikolay.Gekht is on a distinguished road
Unfortunately, the current version of the marketscope does not allow to show labels using indicator. I'll think how can we do this using existing capabilities...

The fractors usually stands at the chosen candle high or low, so the question is how to detect the candle fast. I can only suggest to use the crosshair cursor which is drawn through prices and all indicators.
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.

All times are GMT -5. The time now is 07:52 PM.
Copyright ©2009 Daily FX. All Rights Reserved.