[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Wierd Programming Problem- Please help!



PureBytes Links

Trading Reference Links

How AB works. When you change charts AB runs a scan on all the 
formulas on the visible page, top to bottom. If you hard code the 
static to "ATI" then that is what it will always have. It will not 
have the name of the current chart unless that is ATI. If you cange 
to an new chart it shows they are not the same. So it will depend on 
where in your chart you put the name. 

If the last line in your formula is 

_N(StaticVarSetText( "Old_Symbol_Name", name() );

and the first line is your chart is

if(StaticVarGetText( "Old_Symbol_Name" ) != "" and 
   StaticVarGetText( "Old_Symbol_Name" ) == name())

then you should be able to tell when you change charts. 
 
I coded this and it works:

if(StaticVarGetText( "Old_Symbol_Name" ) != "" and 
   StaticVarGetText( "Old_Symbol_Name" ) == name() )
  SetChartBkColor( colorpink );
else // false or new symbol leg
  SetChartBkColor( coloryellow );
StaticVarSetText( "Old_Symbol_Name", Name()); 

The last line above has to be after the if statement above, not 
necessarily at the end of the chart.

When you switch charts the chart will stay yellow until you click 
somehwere on the worksheet, whatever it takes to make AB scan the 
chart. Then the name will be the same and it will turn pink. 

If you change the true path color to your normal backbround color 
then it will only be yellow on a change.

Barry

<jorgen.wallgren@xxx> wrote:
>
> Either this is weird, or I am stupid! Let's see which it is. LOL! 
> Please help me to figure out this programming problem. I have spent 
> hours getting a code to work and I have finally found the strange 
> and problem part and here is some test code:
> ------------------------------------------------------
> StaticVarSetText( "Symbol_Name1", "ATI" );
> StaticVarSetText( "Symbol_Name2", "ATI" );
> 
> TempName1 =  StaticVarGetText("Symbol_Name1");
> TempName2 = StaticVarGetText("Symbol_Name2");
> 
> if( TempName1 != TempName2 )
> {
>   Say("New Symbol");
> }
> 
> GfxTextOut( TempName1 , x2Bull/4 , (y2Main/2));
> GfxTextOut( TempName2, x2Bull/3 , (y2Main/2));
> ------------------------------------------------------
> 
> This works and when I change for example one "ATI" to "ATI2", the 
> program will recognize it's a difference and say "New Symbol". And 
> the symbols show up correctly on the screen.
> 
> But when I change for example 
> "StaticVarSetText( "Symbol_Name2", "ATI" );" to 
> "StaticVarSetText( "Symbol_Name2", Name() );"
> 
> It doesn't work anymore, and the program say "New Symbol" all the 
> time, despite the fact that in my opinion both have the same symbol-
 
> my current symbol is ATI, so that's what Name() picks up. And the 2 
> GfxTextOut plot both ATI on the screen.!??
> 
> So either I can't mix and compare Name() with StaticVarSetText and 
> StaticVarGetText- or it is something else. Please advice.
> 
> The problem I am trying to solve is how to get the program to 
> recognize that I change the chart to another symbol. So if there is 
> a better way to that that with programming- please let me know.
> 
> Looking forward to finally get this solved. :-)
> 
> Thanks and Regards,
> 
> Jorgen
>



------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/