Does bar stream update automatically in strategy?

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Does bar stream update automatically in strategy?

Postby tllewell » Tue Oct 23, 2012 1:08 pm

I am working on a stragegy to check the position of bars against a pivot level. This is not checking whether the price crosses the pivot. For instance, it could tell if the bar was completely above or below the pivot.

So, I use helper.lua and subscribe to a bar source, and I also subscribe to another bar source to create the pivot indicator:

Code: Select all
function Prepare()
source = ExtSubscribe(200, nil, instance.parameters.PivotTF, priceType, "bar");
pivot = core.indicators:create("PIVOT", source, PivotTF, "Pivot", "HIST");
   
barSource = ExtSubscribe(100, nil, instance.parameters.PriceTF, priceType, "bar");


So I update the pivot indicator with ExtUpdate. Does the bar source update auto-magically? There does not seem to be an update function for price streams.
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm


Re: Does bar stream update automatically in strategy?

Postby sunshine » Wed Oct 24, 2012 2:40 am

The ExtUpdate function is called on update of barSource (when new bar appears). Bar source is updated automatically.
sunshine
 

Re: Does bar stream update automatically in strategy?

Postby tllewell » Wed Oct 24, 2012 6:13 pm

One last question, and this changes the subject a bit... Is there a way to get just one or a few candles in the price history? In good old Order2Go you could specify the number of bars to get in the MarketEnumAut price history command. For my purposes I only need one previous candle; one in the pivot price stream to calculate the current pivot and one in the trading time frame to check against the pivot. Is there really no alternative to calculating the number of days and seconds since 1899?
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm

Re: Does bar stream update automatically in strategy?

Postby sunshine » Fri Oct 26, 2012 4:18 am

If you need the previous candle, you can get it by calling "source[NOW - 1]".
You can also use "host:execute("getHistory", ...)" with zero values for the "from" and "to" parameters. Please note that unlike Order2Go the returned price collection is automatically updated when new bars appear.
sunshine
 

Re: Does bar stream update automatically in strategy?

Postby tllewell » Sat Oct 27, 2012 7:40 am

If I understand you, "source.close[NOW - 1]" is the equivalent of "source.close[source.close:size() - 2]".

I'm not sure I understand the second point. Putting zeroes in the from and to of the get history call in Indicore gets the server default number of bars up to the current time, usually 300 bars. That would include the previous one.

I did see the discussions about how to calculate the value needed to call just a few bars, it just seems tedious. After all, we're putting up with a format created to fix a bug in a program that predates the World Wide Web. It would be nice to have another parameter that just called the number of bars directly, like O2G had.
tllewell
 
Posts: 76
Joined: Thu Mar 01, 2012 4:06 pm


Return to Discussions

Who is online

Users browsing this forum: No registered users and 6 guests