Urgent!!!

Moderator: admin

Urgent!!!

Postby aytacasan » Fri Dec 31, 2010 11:50 am

Hi,

I receive an error for my indicator. When i look what is wrong via debugger i see error message is "attempt to call upvalue 'crossUnder' (a boolean value)".

This error for this expression : crossUnder(source.close, TrendBandMiddleUp, 1).

source input barstream. TrendBandMiddleUp output stream. Any idea why this happen?

Regards.
aytacasan
 
Posts: 15
Joined: Thu Jun 03, 2010 3:40 pm

Re: Urgent!!!

Postby Apprentice » Fri Dec 31, 2010 12:40 pm

A little more info would help.
For example the name of the strategy.

That was probably a minor bug.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36489
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Urgent!!!

Postby aytacasan » Fri Dec 31, 2010 1:05 pm

Hi,

This is not strategy and i attached source code. I think this help you. But wait i can't attach, why i don't understand but i copy-paste all code below. Note that indicator group name contain turkish characters, maybe cause an error and you have to change this name.

Regards.

Code: Select all
-- Indicator profile initialization routine
-- Defines indicator profile properties and indicator parameters
-- TODO: Add minimal and maximal value of numeric parameters and default color of the streams
function Init()
    indicator:name(resources:get("name"));
    indicator:description(resources:get("description"));
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
    indicator:setTag("group", "İndikatörlerim");

    indicator.parameters:addGroup("Calculation");
    indicator.parameters:addInteger("BandDays", resources:get("param_BandDays_name"), resources:get("param_BandDays_description"), 28);
    indicator.parameters:addDouble("DevConstant", resources:get("param_DevConstant_name"), resources:get("param_DevConstant_description"), 3.5);
    indicator.parameters:addGroup("Style");
    indicator.parameters:addColor("TrendBandTop_color", resources:get("param_TrendBandTop_color_name"), resources:get("param_TrendBandTop_color_description"), core.rgb(0, 0, 0));
    indicator.parameters:addInteger("TrendBandTop_width", resources:get("param_TrendBandTop_width_name"), resources:get("param_TrendBandTop_width_description"), 2, 1, 5);
    indicator.parameters:addInteger("TrendBandTop_style", resources:get("param_TrendBandTop_style_name"), resources:get("param_TrendBandTop_style_description"), core.LINE_SOLID);
    indicator.parameters:setFlag("TrendBandTop_style", core.FLAG_LINE_STYLE);
    indicator.parameters:addColor("TrendBandMiddle_colorUp", resources:get("param_TrendBandMiddle_colorUp_name"), resources:get("param_TrendBandMiddle_colorUp_description"), core.rgb(0, 255, 0));
    indicator.parameters:addColor("TrendBandMiddle_colorDown", resources:get("param_TrendBandMiddle_colorDown_name"), resources:get("param_TrendBandMiddle_colorDown_description"), core.rgb(255, 0, 255));
    indicator.parameters:addInteger("TrendBandMiddle_width", resources:get("param_TrendBandMiddle_width_name"), resources:get("param_TrendBandMiddle_width_description"), 2, 1, 5);
    indicator.parameters:addInteger("TrendBandMiddle_style", resources:get("param_TrendBandMiddle_style_name"), resources:get("param_TrendBandMiddle_style_description"), core.LINE_SOLID);
    indicator.parameters:setFlag("TrendBandMiddle_style", core.FLAG_LINE_STYLE);
    indicator.parameters:addColor("TrendBandBottom_color", resources:get("param_TrendBandBottom_color_name"), resources:get("param_TrendBandBottom_color_description"), core.rgb(0, 0, 0));
    indicator.parameters:addInteger("TrendBandBottom_width", resources:get("param_TrendBandBottom_width_name"), resources:get("param_TrendBandBottom_width_description"), 2, 1, 5);
    indicator.parameters:addInteger("TrendBandBottom_style", resources:get("param_TrendBandBottom_style_name"), resources:get("param_TrendBandBottom_style_description"), core.LINE_SOLID);
    indicator.parameters:setFlag("TrendBandBottom_style", core.FLAG_LINE_STYLE);
end

-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
-- TODO: Refine the first period calculation for each of the output streams.
-- TODO: Calculate all constants, create instances all subsequent indicators and load all required libraries
-- Parameters block
local BandDays;
local DevConstant;

local first;
local source = nil;

-- Streams block
local TrendBandTop = nil;
local TrendBandMiddleUp = nil;
local TrendBandMiddleDown = nil;
local TrendBandBottom = nil;

-- Routine
function Prepare()
    BandDays = instance.parameters.BandDays;
    DevConstant = instance.parameters.DevConstant;
    source = instance.source;
    first = source:first();

    local name = profile:id() .. "(" .. source:name() .. ", " .. BandDays .. ", " .. DevConstant .. ")";
    instance:name(name);
    TrendBandTop = instance:addStream("TrendBandTop", core.Line, name .. ".TrendBandTop", "TrendBandTop", instance.parameters.TrendBandTop_color, first);
    TrendBandTop:setWidth(instance.parameters.TrendBandTop_width);
    TrendBandTop:setStyle(instance.parameters.TrendBandTop_style);
    TrendBandMiddleUp = instance:addStream("TrendBandMiddleUp", core.Line, name .. ".TrendBandMiddleUp", "TrendBandMiddleUp", instance.parameters.TrendBandMiddle_colorUp, first);
    TrendBandMiddleUp:setWidth(instance.parameters.TrendBandMiddle_width);
    TrendBandMiddleUp:setStyle(instance.parameters.TrendBandMiddle_style);
    TrendBandMiddleDown = instance:addStream("TrendBandMiddleDown", core.Line, name .. ".TrendBandMiddleDown", "TrendBandMiddleDown", instance.parameters.TrendBandMiddle_colorDown, first);
    TrendBandMiddleDown:setWidth(instance.parameters.TrendBandMiddle_width);
    TrendBandMiddleDown:setStyle(instance.parameters.TrendBandMiddle_style);
    TrendBandBottom = instance:addStream("TrendBandBottom", core.Line, name .. ".TrendBandBottom", "TrendBandBottom", instance.parameters.TrendBandBottom_color, first);
    TrendBandBottom:setWidth(instance.parameters.TrendBandBottom_width);
    TrendBandBottom:setStyle(instance.parameters.TrendBandBottom_style);
end

local serial = nil;
local bOBLow = 0.0;
local bOBHigh = 0.0;
local expSmoothPrice = 0;
local expSmoothRange = 0;
local crossOver = false;
local crossUnder = false;
local directionUp = false;

-- Indicator calculation routine
-- TODO: Add your code for calculation output values
function Update(period)
    if period > first and source:hasData(period - 1) and serial ~= source:serial(period) then
        if period == first + 1 then
            expSmoothPrice = source.close[period - 1];
            expSmoothRange = source.high[period - 1] - source.low[period - 1];
            if source.open[period - 1] > expSmoothPrice then
                directionUp = true;
            end
        else
            expSmoothPrice = (expSmoothPrice * (BandDays - 1) + source.close[period - 1]) / BandDays;
            expSmoothRange = (expSmoothRange * (BandDays - 1) + (source.high[period - 1] - source.low[period - 1])) / BandDays;
        end

        TrendBandTop[period] = expSmoothPrice + (expSmoothRange * DevConstant);
        if directionUp then
            TrendBandMiddleUp[period] = expSmoothPrice;
        else
            TrendBandMiddleDown[period] = expSmoothPrice;
        end
        TrendBandBottom[period] = expSmoothPrice - (expSmoothRange * DevConstant);

        if bOBHigh > 0 and source.close[period - 1] > bOBHigh then
            directionUp = true;
            bOBHigh = 0;
        elseif bOBLow > 0 and source.close[period - 1] < bOBLow then
            directionUp = false;
            bOBLow = 0;
        end
         
        if crossOver and source.high[period - 1] >= expSmoothPrice and source.low[period - 1] >= expSmoothPrice then
            bOBHigh = source.high[period - 1];
            crossOver = false;
        elseif crossUnder and source.high[period - 1] <= expSmoothPrice and source.low[period - 1] <= expSmoothPrice then
            bOBLow = source.low[period - 1];
            crossUnder = false;
        end

        if directionUp and crossUnder(source.close, TrendBandMiddleUp, 1) then
            crossUnder = true;
        elseif not(directionUp) and crossOver(source.close, TrendBandMiddleDown, 1) then
            crossOver = true;
        end

        serial = source:serial(period);
    end
end
aytacasan
 
Posts: 15
Joined: Thu Jun 03, 2010 3:40 pm

Re: Urgent!!!

Postby aytacasan » Sat Jan 01, 2011 2:31 am

Hi Apprentice,

Also, please explore the code and tell me if there is more proffessional way for anything. For exmple i'm using 2 series for plot coloured(mean 2 color) middle line(TrenBandMiddleUp & TrenBandMiddleDown). Maybe there is solution do the same one series. If so please inform me.

PS:At the same time why i can't attach a file via my posts. Any idea?

Regards.
aytacasan
 
Posts: 15
Joined: Thu Jun 03, 2010 3:40 pm

Re: Urgent!!!

Postby Apprentice » Sat Jan 01, 2011 3:30 am

Only one thing, before answering.

Can you add the corresponding lua.rc.
You can send it to my private mail

Which you can find here.
memberlist.php?mode=viewprofile&u=437
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36489
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Urgent!!!

Postby Apprentice » Sat Jan 01, 2011 5:49 am

TrendBands.png

TrendBands.lua
(6.85 KiB) Downloaded 756 times

TrendBands.lua.rc
(1.43 KiB) Downloaded 764 times


First, why this urgency.

I have Corrected an error, I commented your code that I replaced, in order to see the difference.
Happens to the best of us.

Soon released version, will have support for single stream outputs, with different colors.
Beta Version is available here.
viewtopic.php?f=28&t=2178#p7029

I have not had time to review your code in more detail.
If you agree, I will optimize it and publish it on the forum, to be accessible to other users.

You can not post the file, because you probably do not have permission to do so.
Unfortunately I can not change your profile.

From which part of Turkey, are you.
Balkan or Asian.

You can respond through the mail, too.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36489
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Urgent!!!

Postby aytacasan » Sat Jan 01, 2011 7:06 am

Hello,

Many thanks for your help and response. Actually reason for urgency is a little bit personal. Shortly, I'm writing a few indicators for months for different trading platforms metatrader, ninja trader, strategy trader, etc. And for various reasons I did not satisfy all of that. At the end i decide the best will be Trading Station II. This mean writing process is start again but new year trading season is opening in 1-2 weeks.

Support for single stream for different colours, this is very good news. About SDK and TS, Do you have an exact day for final release? At least what is planned?

Certainly I agree, You can optimize it and publish it on the forum. I would appreciate it. But I think there is a logic error in code. I'll fix it and send it you again.

I don't have permission, this is a sad thing for me. So how do I get this right?

Actually, I'm from Asia part of Turkey but I'm from city of Bursa. I mean i'm very close to Balkan. For example, I can go to Greece for a few hours.

Take Care.
aytacasan
 
Posts: 15
Joined: Thu Jun 03, 2010 3:40 pm

Re: Urgent!!!

Postby Apprentice » Sat Jan 01, 2011 7:15 am

In One week Time, If I'm not mistaken .
Ask Nikolay.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36489
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Urgent!!!

Postby Nikolay.Gekht » Sat Jan 01, 2011 1:03 pm

ATM, the release is planed to the first friday of 2011. If nothing will happen again (e.g. somebody who must participate in release will go to vactation) - it will. I'll have the final decision of FXCM this Thursday.
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: Urgent!!!

Postby aytacasan » Sat Jan 01, 2011 1:32 pm

Very good news Nikolay. God bless you.
aytacasan
 
Posts: 15
Joined: Thu Jun 03, 2010 3:40 pm


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 47 guests