FXCM Forex Trading

Belkhayate's Center Of Gravity

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

Re: Belkhayate's Center Of Gravity

Postby Hug Coder » Mon Feb 27, 2012 6:18 pm

See if this works. I haven't tested it.

Code: Select all
    -- Indicator profile initialization routine
    -- Defines indicator profile properties and indicator parameters
    function Init()
    strategy:name("Gravity signal");
    strategy:description("Signals when Price hits Gravity Edges");

    strategy.parameters:addGroup("Gravity parameters");
    strategy.parameters:addInteger("N", "Number of bars", "", 120);
    strategy.parameters:addInteger("O", "Order", "", 3);
    strategy.parameters:addDouble("E", "Eccart value", "", 1.61803399);

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

    strategy.parameters:addGroup("Signal parameters");
    strategy.parameters:addBoolean("ShowAlert", "Show Alert", "", true);
    strategy.parameters:addBoolean("PlaySound", "Play Sound", "", false);
    strategy.parameters:addFile("SoundFile", "Sound file", "", "");
    strategy.parameters:setFlag("SoundFile", core.FLAG_SOUND);
    strategy.parameters:addBoolean("Recurrent", "RecurrentSound", "", false);

    strategy.parameters:addGroup("Email Parameters");
    strategy.parameters:addBoolean("SendEmail", "Send email", "", false);
    strategy.parameters:addString("Email", "Email address", "", "");
    strategy.parameters:setFlag("Email", core.FLAG_EMAIL);

    -- Streams/Indicators
    local gSource, gTick;
    local BELCOG;
    local name;

    -- Parameters
    local SoundFile;
    local RecurrentSound;
    local Email;
    local ShowAlert;

    local N;
    local O;
    local E;

    -- Variables

    -- Init Routine
    function Prepare(onlyName)

       N = instance.parameters.N;
       O = instance.parameters.O;
       E = instance.parameters.E;

       ShowAlert = instance.parameters.ShowAlert;
       if instance.parameters.PlaySound then
       SoundFile = instance.parameters.SoundFile;
       SoundFile = nil;

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

       RecurrentSound = instance.parameters.Recurrent;
       local SendEmail = instance.parameters.SendEmail;
       if SendEmail then
       Email = instance.parameters.Email;
       Email = nil;
       assert(not(SendEmail) or (SendEmail and Email ~= ""), "Email address must be specified");

       name = profile:id() .. "(" .. instance.bid:instrument() .. "," .. N .. "," .. O .. "," .. E .. ")";

       if onlyName then

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

       gSource = ExtSubscribe(1, nil, instance.parameters.Period, true, "bar");
       gTick = ExtSubscribe(2, nil, "t1", true, "close");
       BELCOG = core.indicators:create("BELCOG", gSource, N, O, E);


    -- Process data routine
    function ExtUpdate(id, source, period)

       -- If ticksource, use bar period
       if id == 2 then
          period = gSource:size() - 1;
       if period < BELCOG.DATA:first() + 1 then

       if core.crossesOver(gSource.high, BELCOG.L3, period) then
          Signal("Gravity OverBought");
       elseif core.crossesUnder(gSource.low, BELCOG.L6, period) then
          Signal("Gravity OverSold");


    function Signal(Label)
        if ShowAlert then
            terminal:alertMessage(instance.bid:instrument(), instance.bid[NOW],  Label, instance.bid:date(NOW));

        if SoundFile ~= nil then
            terminal:alertSound(SoundFile, RecurrentSound);

        if Email ~= nil then
            terminal:alertEmail(Email, Label, profile:id() .. "(" .. instance.bid:instrument() .. ")" .. instance.bid[NOW]..", " .. Label..", " .. instance.bid:date(NOW));

    dofile(core.app_path() .. "\\strategies\\standard\\include\\helper.lua");
Hug Coder
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Belkhayate's Center Of Gravity

Postby virgilio » Tue Feb 28, 2012 5:49 pm

Hello developer(s), this is truly a nice treat. There is also another indicator that should be used with this Center of Gravity. It is a timing indicator that reinforces the Center of Gravity's entry and exit points. It can be viewed at the bottom of page 2 in the attached pdf document (Hot to use Belkhayate). The indicator is is called Belkhayate Timing. Is this something you would you be able to replicate and offer in conjunction with the Center of Gravity?
If so, then we have a formidable tool to use.
Thank you!
Posts: 66
Joined: Mon Aug 23, 2010 12:16 pm

Re: Belkhayate's Center Of Gravity

Postby Hug Coder » Wed Feb 29, 2012 4:35 am

This viewtopic.php?f=17&t=715 ?
Hug Coder
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Belkhayate's Center Of Gravity

Postby Karlo_Karlo » Thu Mar 01, 2012 6:56 am

Thank you gentlemen, but it looks no different than it was before.
There is the MBFX Timing Indicator subject also; MT4 version gives a color line while the lua version gives something very different, which I do not understand how to use. I understand that it's a subject of intellectual property but it very much looks like that the MT4 Timing Indicator is a colorized version of some common indicator. I tried to look for but did not succeed.
What do you think about it?
Posts: 11
Joined: Fri Jan 07, 2011 4:48 am

Re: Belkhayate's Center Of Gravity

Postby Hug Coder » Fri Mar 02, 2012 7:27 am

You have to define what you want exactly otherwise it's not so easy.

If you are requesting another indicator please make a proper request in the request forum, with enough information to make something out of it, e.g. a link or code (and picture+description) of the MT4 version.
Hug Coder
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Belkhayate's Center Of Gravity

Postby Karlo_Karlo » Sat Mar 03, 2012 8:49 am

Thank you Hug Coder,
Below is the "MBFX Timing.ex4" file, which is the additional indicator for MBFX system. But It is for the MT4 and we do not have a lua version. As it is said in the beginning of this thread that this system is an intellectual property of Mr.Belkhayate and it is not allowed to make a lua version of his indicator without his permission. But I think that this indicator is not a very sophisticated one. I tried to compare it with other common indicators in the MT4 but I could not find anything similar yet. In my recent post I was simply asking your opinion about this indicators resemblance with others.
MBFX Timing.ex4
(4.56 KiB) Downloaded 1231 times
Posts: 11
Joined: Fri Jan 07, 2011 4:48 am

Re: Belkhayate's Center Of Gravity

Postby trendwatch » Sun Mar 04, 2012 7:50 am

I've read several statements of mr. Belkhayate wherein he states he is in no way related to MBFX. So the MBFX inidcators are not the same as those mr. Belkhayate uses in his system. Just thought you might like know this before you started using these indicators.
Posts: 33
Joined: Wed Jul 13, 2011 2:49 am

Re: Belkhayate's Center Of Gravity

Postby Hug Coder » Tue Mar 06, 2012 5:15 am

As I said, if you want another indicator, you shouldn't post requests in this thread. If what you are looking for is a different version of the Belkhayate's Timing Indicator (viewtopic.php?f=17&t=715) then post there, otherwise post a new request thread for what you want, with proper descriptions etc.

The file you posted seems to be a compiled file which has no clear text/code so it's of no use.
Hug Coder
Posts: 38
Joined: Fri Jan 13, 2012 5:43 am

Re: Belkhayate's Center Of Gravity

Postby elliotwave5 » Thu May 31, 2012 8:33 pm

a) Can the Belkhayate indicators (BF long term reg and timing indicators) be used publicly? I believe reading that they are proprietary to him exclusively or are they public?
b) currently reviewing an H4 chart and the GBP/USD is way outside the L7 band. am i correct in that this indicates that one should take a long position? how many pips to risk on the stop and what would his limit be on profit taking?
any comments or suggestions would be greatly appreciated
Posts: 13
Joined: Wed Aug 10, 2011 7:40 pm

Re: Belkhayate's Center Of Gravity

Postby Apprentice » Fri Jun 01, 2012 3:17 am

I am not aware of such limitations.
Everything posted here can be used for your own private use.
User avatar
FXCodeBase: Confirmed User
Posts: 14260
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Custom Indicators

Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests