pass variables from indicaotr to strategy

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

Moderator: admin

pass variables from indicaotr to strategy

Postby pipReaper » Mon Dec 03, 2012 4:32 am

I wish to access a variable of an indicator from a strategy.

1/. Is there any way to pass a variable value from an indicator to a strategy. I see obviously I can pass the streams but I cannot see how to pass single state information. Is this intentional or am I missing something?

I can pass state information in a separate stream but I cannot access internal streams of an indicator from within a strategy and cannot get the a output stream to NOT display when I use xxx:setStyle(core.LINE_NONE) for the stream - it adjusts the chart to reflect the hidden stream, which is not the effect that I desire.

2/. I cannot access indicator methods from a strategy - again is this intentional?
pipReaper
 
Posts: 5
Joined: Tue Nov 27, 2012 9:37 am

Re: pass variables from indicaotr to strategy

Postby Apprentice » Mon Dec 03, 2012 10:16 am

For single variable, u can use persistent storage.
Example of persistent storage use.
viewtopic.php?f=17&t=4360&p=12626&hilit=tool#p12626

Value Passing.lua
Example of how to hide the stream.
(1.58 KiB) Downloaded 776 times


U can use my example or use only last period;
Something like this.

Code: Select all
function Update(period)
    if period == source:size()-1 then
        Out[source:size()-1 ] = Value;
    end
end
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: pass variables from indicaotr to strategy

Postby pipReaper » Mon Dec 10, 2012 3:32 am

I dont think this helps - I don't want to access streams - I want to access the value of a CUSTOM INDICATOR from a STRATEGY. It would also be nice to be able to call an indicators methods from a STRATEGY. Maybe for this work

Also I don't think this helps with hiding streams for access within a STRATEGY?

I should be pushing everything that is the property of an indicator into a strategy?
pipReaper
 
Posts: 5
Joined: Tue Nov 27, 2012 9:37 am

Re: pass variables from indicaotr to strategy

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

With any indicator it is not possible.

However, if both indicator AND strategy are prepared to use interop table, introduced in SDK 2.0 spec (currently on production), it is possible. A strategy can call an function or read a global variable in other strategies and indicators.

See http://www.fxcodebase.com/documents/Ind ... terop.html
Nikolay.Gekht
FXCodeBase: Site Admin
 
Posts: 1235
Joined: Wed Dec 16, 2009 6:39 pm
Location: Cary, NC

Re: pass variables from indicaotr to strategy

Postby pipReaper » Wed Dec 12, 2012 8:36 am

Yes - that stuff works well.

I will not post my solution as it is in the place you told me to look as you detail above.

Many Thanks
pipReaper
 
Posts: 5
Joined: Tue Nov 27, 2012 9:37 am


Return to Discussions

Who is online

Users browsing this forum: No registered users and 7 guests