instance:createCandleGroup

Moderator: admin

instance:createCandleGroup

Postby robocod » Thu Dec 06, 2012 7:44 am

Hi,

I have an indicator (defined as an 'oscillator', i.e it is displayed in a frame underneath the price chart). I want it to paint the bar colours of the price chart, according to some computation.

I tried something like this...

Code: Select all
    open = instance:addStream("OPEN", core.Line, name .. ".OPEN", "OPEN", core.rgb(0,0,0), 0);
    high = instance:addStream("HIGH", core.Line, name .. ".HIGH", "HIGH", core.rgb(0,0,0), 0);
    low = instance:addStream("LOW", core.Line, name .. ".LOW", "LOW", core.rgb(0,0,0), 0);
    close = instance:addStream("CLOSE", core.Line, name .. ".CLOSE", "CLOSE", core.rgb(0,0,0), 0);

    host:execute("attachOuputToChart", "OPEN");
    host:execute("attachOuputToChart", "HIGH");
    host:execute("attachOuputToChart", "LOW");
    host:execute("attachOuputToChart", "CLOSE");
   
    instance:createCandleGroup(name, name, open, high, low, close);


But I just get the candle group drawn in the oscillator window. If I remove the 'instance:createCandleGroup' line, then I see the separate open,high,low,close lines in the price chart, so that bit is working - but the candle group only seems to get created in the oscillator frame.

Is it possible to do what I want to do?

Alternatively, I can create a 2nd indicator and have this handle the paint bars, but it would have been nice to do this from a single indicator.

Thanks.
User avatar
robocod
FXCodeBase: Graduate
 
Posts: 298
Joined: Thu May 10, 2012 4:25 pm

Re: instance:createCandleGroup

Postby Nikolay.Gekht » Mon Dec 10, 2012 4:10 pm

In theory - candles must be on main chart. Looks like a bug.

The earliest we can fix it on prod (counting the fact that the current release is still not on production for two months as it is ready), will be... I'm afraid something like April or May.

What we can do is to provide you with the beta as soon as we have the defect fixed (btw, with support of new SDK spec, including owner-drawn indicators).
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: instance:createCandleGroup

Postby Alexey.Pechurin » Wed Dec 12, 2012 10:30 pm

It will be fixed in the upcoming TS release. But the following code must be used:

Code: Select all
    open = instance:addStream("OPEN", core.Line, name .. ".OPEN", "OPEN", core.rgb(0,0,0), 0);
    high = instance:addStream("HIGH", core.Line, name .. ".HIGH", "HIGH", core.rgb(0,0,0), 0);
    low = instance:addStream("LOW", core.Line, name .. ".LOW", "LOW", core.rgb(0,0,0), 0);
    close = instance:addStream("CLOSE", core.Line, name .. ".CLOSE", "CLOSE", core.rgb(0,0,0), 0);

    instance:createCandleGroup(name, candleGroupID, open, high, low, close);
    host:execute("attachOuputToChart", candleGroupID);
Alexey.Pechurin
 
Posts: 98
Joined: Sun Jul 22, 2012 11:26 pm

Re: instance:createCandleGroup

Postby robocod » Thu Dec 13, 2012 2:21 am

8-) Cool! Many thanks :D
User avatar
robocod
FXCodeBase: Graduate
 
Posts: 298
Joined: Thu May 10, 2012 4:25 pm

Re: instance:createCandleGroup

Postby gpatel » Thu Jan 24, 2013 2:48 pm

Is there any way to reference this CandleGroup from a strategy? I want a stream that has open, high, low, close properties like the source stream to pass to another indicator that uses a barstream.
gpatel
 
Posts: 13
Joined: Wed Jan 11, 2012 10:51 am

Re: instance:createCandleGroup

Postby Apprentice » Fri Jan 25, 2013 7:08 am

It's possible.
If Bar chart generated by the indicator,
You can access the bar chart data, as u would with any other 4 stream output indicator.

Something like this.
IndicatorName.OPEN[period];
IndicatorName.CLOSE[period]
IndicatorName.HIGH[period];
IndicatorName.LOW[period]
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: instance:createCandleGroup

Postby gpatel » Fri Jan 25, 2013 2:29 pm

How would you send this to another indicator that needs bar data(open, high, low, close)? Lets say I want to send HA bars to ZigZag. How do you do that?
gpatel
 
Posts: 13
Joined: Wed Jan 11, 2012 10:51 am

Re: instance:createCandleGroup

Postby Apprentice » Mon Jan 28, 2013 1:40 pm

Here you can find several examples.
For Strategy
viewtopic.php?f=31&t=27800&p=48715&hilit=HA+Smoothed#p48715
And for Indicator
viewtopic.php?f=17&t=606&hilit=HA+Smoothed

I hope this will help.
If not contact me privatly, So we can talk.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: instance:createCandleGroup

Postby gpatel » Tue Jan 29, 2013 9:53 am

This is not what I'm looking for. The strategy simply gets the data back from one of the moving average indicator and bases its logic on it.

I'm looking to go 1 step further and send this open, high, low, close (Indicator["O"], Indicator["C"], Indicator["H"], Indicator["L"]) data to another indicator that uses OHLC (Eg. zigzag). How do you achieve that?

It is easy to do it on the chart by changing the source of zigzag to HA or SC(smoothed candle), but there is no way to do it in the code.
gpatel
 
Posts: 13
Joined: Wed Jan 11, 2012 10:51 am

Re: instance:createCandleGroup

Postby Apprentice » Wed Jan 30, 2013 4:04 am

Now I understand.
Unfortunately at present, it is not possible.
SDK 2.2, currently available as a beta, have this functionality.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 5 guests