Indicator and Strategy Parameters

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

Moderator: admin

Indicator and Strategy Parameters

Postby MrRiversideDude » Wed Apr 16, 2014 1:07 am

Is it possible to access the parameters set in an indicator from a strategy?

Something like:

TRD = instance.parameters.TRD; (syntax for a strategy)

But the parameter was actually set in an indicator attached to the chart. If not, is there a way to pass information\values from an indicator to a strategy?

Thanks!!
MrRiversideDude
 
Posts: 87
Joined: Fri Feb 21, 2014 7:50 am

Re: Indicator and Strategy Parameters

Postby Apprentice » Wed Apr 16, 2014 11:36 am

Strategy Builder is a good example of how this is done.
viewtopic.php?f=31&t=2368&hilit=builder

Generic Channel is another indicator that uses this functionality.
viewtopic.php?f=17&t=15195&p=28723&hilit=generic#p28723
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Indicator and Strategy Parameters

Postby MrRiversideDude » Thu Apr 17, 2014 7:07 am

Thanks Apprentice, but strategy builder is a lot more complex then what I'm looking for. I want to add one particular custom indicator and reference the parameters by name from my strategy. Do you have any examples of that or did I miss something?

Thanks in advance.
MrRiversideDude
 
Posts: 87
Joined: Fri Feb 21, 2014 7:50 am

Re: Indicator and Strategy Parameters

Postby Apprentice » Fri Apr 18, 2014 3:08 am

Generic Channel Indicator is simpler example.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Indicator and Strategy Parameters

Postby MrRiversideDude » Sun Apr 20, 2014 5:15 pm

Thanks, I was able to get it to work. When I change the parameter value in the indicator I want that updated value to be used by the strategy. Is there a refresh method for the parameters table?

I tried reloading the updated value in the ChangeParameters() by duplicating the code used in prepare(), but that didn't work.

Thanks in advance.
MrRiversideDude
 
Posts: 87
Joined: Fri Feb 21, 2014 7:50 am

Re: Indicator and Strategy Parameters

Postby LindenNYC » Mon Apr 21, 2014 1:37 am

I had this same problem, I couldn't get the new values in the indicator to show up in the strategy after I changed the value. It seems like the values were cached in the strategy. Any help on this from the experts would be appreciated.

Thanks!!!!
LindenNYC
 
Posts: 2
Joined: Sun Apr 20, 2014 8:58 pm

Re: Indicator and Strategy Parameters

Postby Apprentice » Mon Apr 21, 2014 10:43 am

Can provide your coding example.
Then I will be able to say more.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Indicator and Strategy Parameters

Postby MrRiversideDude » Mon Apr 21, 2014 11:09 am

I'll send the actual code as soon as I can.

Pseudo code:

Prepare()
-- get parameter values by name

ExtUpdate()
-- get parameter values by name

The problem occurs when I change the parameter value on the indicator. How do I get the updated value in the strategy?

Thanks.
MrRiversideDude
 
Posts: 87
Joined: Fri Feb 21, 2014 7:50 am

Re: Indicator and Strategy Parameters

Postby MrRiversideDude » Mon Apr 21, 2014 8:02 pm

This is a snippet of the code:

function Prepare(nameOnly)

AllowedSide = instance.parameters.AllowedSide;
PlaySound = instance.parameters.PlaySound;
ShowAlert = instance.parameters.ShowAlert;
TimeFrame = instance.parameters.TF;

INDICATOR = instance.parameters.INDICATOR;
local tmpprofile = core.indicators:findIndicator(instance.parameters:getString("INDICATOR"));
local tmpparams = instance.parameters:getCustomParameters("INDICATOR");

Process = tmpparams:getString("Process");

This works the first time. The problem happens when I change the value of the "Process" parameter. How do I get the new value into my strategy? I thought the best would be in the function ExtUpdate.

Goal: Use the indicator to print to the chart like a dashboard, pass values to the strategy to manage my trades.

Thanks again.
MrRiversideDude
 
Posts: 87
Joined: Fri Feb 21, 2014 7:50 am

Re: Indicator and Strategy Parameters

Postby Apprentice » Tue Apr 22, 2014 2:54 am

If I understand, this problem arises during Rael / demo testing,
not within Strategy back testing.
If You hesitate to reveal the entire code, I need this for my insight,
use my private email mario.jemic(@)gmail.com
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Next

Return to Discussions

Who is online

Users browsing this forum: No registered users and 10 guests