• Australian (ASX) Stock Market Forum

Hello and welcome to Aussie Stock Forums!

To gain full access you must register. Registration is free and takes only a few seconds to complete.

Already a member? Log in here.

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

Discussion in 'Software and Data' started by Richard888, May 19, 2015.

  1. Richard888

    Richard888

    Posts:
    15
    Likes Received:
    0
    Joined:
    Jul 6, 2013
    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;
     
  2. trash

    trash

    Posts:
    412
    Likes Received:
    17
    Joined:
    Mar 31, 2012
    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; 
     
  3. Richard888

    Richard888

    Posts:
    15
    Likes Received:
    0
    Joined:
    Jul 6, 2013
    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!


     
  4. trash

    trash

    Posts:
    412
    Likes Received:
    17
    Joined:
    Mar 31, 2012
    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");
     
Loading...

Share This Page