Australian (ASX) Stock Market Forum

Can any Amibroker pros tell me what's wrong with this code?

Joined
6 July 2013
Posts
15
Reactions
0
Im trying to use a paramlist in one pane to control the title text in another pane. So far, I've come up with the following code which, although probably very crude, is almost there but I must be doing something wrong which I cant quite figure out. Thanks.

//code in the pane containing the paramlist:
strattype= ParamList("Strategy Type", "AAA,BBB,CCC");
StaticVarSetText("strategytype", strattype);


//code in the pane which contains the title text:
strategytype = StaticVarGetText("strategytype");

strategytext =
WriteIf( strategytype== "AAA", " This is the text for strategy AAA",
WriteIf( strategytype == "BBB", " This is the text for strategy BBBB ",
WriteIf( strategytype == "CCC", " This is the text for strategy CCC",
" " ) ) );

Title =
EncodeColor(colorBrightGreen) +strategytext;
 
Im trying to use a paramlist in one pane to control the title text in another pane. So far, I've come up with the following code which, although probably very crude, is almost there but I must be doing something wrong which I cant quite figure out. Thanks.

//code in the pane containing the paramlist:
strattype= ParamList("Strategy Type", "AAA,BBB,CCC");
StaticVarSetText("strategytype", strattype);


//code in the pane which contains the title text:
strategytype = StaticVarGetText("strategytype");

strategytext =
WriteIf( strategytype== "AAA", " This is the text for strategy AAA",
WriteIf( strategytype == "BBB", " This is the text for strategy BBBB ",
WriteIf( strategytype == "CCC", " This is the text for strategy CCC",
" " ) ) );

Title =
EncodeColor(colorBrightGreen) +strategytext;

But you haven't mentioned what is the actual problem.
Do you mean that the second pane does not update?

Well, in that case you use local database which does not refresh but only if you click a pane or scroll a pane etc.

In order to auto-refresh panes of DBs not using streaming plugin add RequestTimedRefresh

Code:
//code in the pane which contains the title text:
RequestTimedRefresh( 1 );

strategytype = StaticVarGetText("strategytype");

strategytext = WriteIf( strategytype == "AAA", " This is the text for strategy AAA",
               WriteIf( strategytype == "BBB", " This is the text for strategy BBBB ",
               WriteIf( strategytype == "CCC", " This is the text for strategy CCC",
                        " " ) ) );

Title = EncodeColor(colorBrightGreen) +strategytext;
 
Thanks Trash.. sorry for not explaining what the problem was.. but you worked it out anyway in that it wasn't updating when the paramlist values change. And the autorefresh solves the problem completely. I feel an idiot because it was so simple yet I was scratching my head for ages wondering why it wasnt changing! Well.. learnt something new with your help.. again! Cheers!


But you haven't mentioned what is the actual problem.
Do you mean that the second pane does not update?

Well, in that case you use local database which does not refresh but only if you click a pane or scroll a pane etc.


In order to auto-refresh panes of DBs not using streaming plugin add RequestTimedRefresh

Code:
//code in the pane which contains the title text:
RequestTimedRefresh( 1 );

strategytype = StaticVarGetText("strategytype");

strategytext = WriteIf( strategytype == "AAA", " This is the text for strategy AAA",
               WriteIf( strategytype == "BBB", " This is the text for strategy BBBB ",
               WriteIf( strategytype == "CCC", " This is the text for strategy CCC",
                        " " ) ) );

Title = EncodeColor(colorBrightGreen) +strategytext;
 
No probs.

BTW you could just do it this way

Code:
//code in the pane containing the paramlist:
strattype = ParamList("Strategy Type", "AAA,BBB,CCC");

switch( strattype ) {
  case "AAA":
        strategytext = "";  
        break;
  case "BBB":
        strategytext = ""; 
        break;        
  case "CCC":
        strategytext = ""; 
        break;        
  default:
        // default action
        break;
}

StaticVarSetText("strategytext", strategytext);


Code:
//code in the pane which contains the title text:
RequestTimedRefresh( 1 );
Title = EncodeColor(colorBrightGreen) + StaticVarGetText("strategytext");
 
Top