The printf for StaticVarGet didn't work as I expected. Used if(StaticVarGet == 1) and am able to printf the status.
-Ron --- In [email protected], "rselmanl" <no-cents-...@...> wrote: > > > > > Newbie question here. This has been giving me lots of trouble! > StaticVarSet does not seem to work. I have Intel 940, XP 64, and AB V5.3 > running. Sorry about the long statements below. > > Try to init a StaticVar after a few bars. The Interpretation Window printf's > then start to show meaningful numbers i.e. '0'. They never show anything > else. Also the StaticVarSet never returns a '1' showing the set was > successful. Fairly sure saw a '1' returned many hours ago, but not lately. > Didn't have the StaticVarRemove originally. I do restart AB from time to > time. > > Can anyone please help, this is making my hair grey (what's left)! > > Var1 = 0; > Var2 = 1; > > "BarIndex() = " + WriteVal(BarIndex()); > if(LastValue(BarIndex(), False) == 3) //This isn't suppose to be necessary > StaticVarRemove("Static*"); //placed here to > delete any remnants. > > if(LastValue(BarIndex(), False) == 5) > { > retval = StaticVarSet("StaticPositionHeld", Var1); //Does not return 1. > printf("Inside bar 5\n"); //Below prints a 0 in Interpretation Window. > printf("retval returned = %d\n", retval); > printf("StaticVarGet, StaticPositionHeld 0 = > %d\n",StaticVarGet("StaticPositionHeld")); > } > > printf("Outside of bar 5 now.\n"); //Below always prints 0 in Interpretation > Window. > printf("StaticVarGet, StaticPositionHeld, True = > %d\n",StaticVarGet("StaticPositionHeld", True)); > printf("StaticVarGet, StaticPositionHeld, False = > %d\n",StaticVarGet("StaticPositionHeld", False)); > printf("StaticVarGet, StaticPositionHeld = > %d\n\n",StaticVarGet("StaticPositionHeld")); > > if(LastValue(BarIndex(), False) == 10) > { > retval1 = StaticVarSet("StaticPositionHeld", Var2); //Set the > "StaticPositionHeld" to 1. > printf("Inside bar 10\n"); //retval1 is not == 1. > printf("retval1 returned = %d\n", retval1); //Below still prints 0 in > Interpretation Window. > printf("StaticVarGet, StaticPositionHeld = > %d\n",StaticVarGet("StaticPositionHeld", True)); > printf("StaticVarGet, StaticPositionHeld = > %d\n",StaticVarGet("StaticPositionHeld", False)); > } > > printf("Outside of bar 10 now.\n"); //Below still prints 0 in Interpretation > Window. > printf("StaticVarGet, StaticPositionHeld, True = > %d\n",StaticVarGet("StaticPositionHeld", True)); > printf("StaticVarGet, StaticPositionHeld, False = > %d\n",StaticVarGet("StaticPositionHeld", False)); > printf("StaticVarGet, StaticPositionHeld = > %d\n\n",StaticVarGet("StaticPositionHeld")); > > > printf("Print the StaticVars with LastValue\n"); //Below still prints 0 in > Interpretation Window. > printf("StaticVarGet, StaticPositionHeld, True = > %d\n",LastValue(StaticVarGet("StaticPositionHeld", True), False)); > printf("StaticVarGet, StaticPositionHeld, False = > %d\n",LastValue(StaticVarGet("StaticPositionHeld", False), False)); > printf("StaticVarGet, StaticPositionHeld = > %d\n\n",LastValue(StaticVarGet("StaticPositionHeld"), False)); > > Plot(StaticVarGet("StaticPositionHeld"), "PositionHeld", colorYellow, > styleLine); > > //End of my problem code. > //Thanks in advance for your assistance! > > //-Ron > > --- In [email protected], Herman <psytek@> wrote: > > > > apply it to an indicator also, there you can clear staticvariables. > > > > h > > > > > > > My code was in a scan and so i cannot use param trigger. > > > > > --- In [email protected], Herman <psytek@> wrote: > > >> > > >> try the code below, seems to work fine: > > >> > > >> if ( ParamTrigger( "Delete StaticVar", "DELETE" ) ) > > >> StaticVarRemove( "LastBar" ); > > >> > > >> CurrentBarNo = LastValue( TimeNum() ); > > >> //Lastbarvalues=StaticVarGet("LastBar"); > > >> if ( IsNull( StaticVarGet( "LastBar" ) ) ) > > >> { > > >> StaticVarSet( "LastBar", CurrentBarNo ); > > >> _TRACE( "setting static array" + NumToStr( CurrentBarNo ) ); > > >> } > > >> > > >> herman > > >> > > >> > i had this code which would run only once during the first run of > > >> > the afl. now its seems to be running every time. i upgraded to 5.3 > > >> > recently. > > >> > > >> > CurrentBarNo=LastValue(TimeNum()); > > >> > > >> > //Lastbarvalues=StaticVarGet("LastBar"); > > >> > if(IsNull(StaticVarGet("LastBar"))){ > > >> > StaticVarSet("LastBar", CurrentBarNo ); > > >> > > >> > _TRACE("setting static array" + NumToStr(CurrentBarNo)); > > >> > } > > >> > > >> > i was using a version that did not support static arrays before and > > >> > so i may be missing something that i should be doing when checking > > >> > for existance of a static variable. can someone point out what mistake > > >> > i am making. > > >> > > >> > > >> > > >> > ------------------------------------ > > >> > > >> > **** IMPORTANT PLEASE READ **** > > >> > This group is for the discussion between users only. > > >> > This is *NOT* technical support channel. > > >> > > >> > TO GET TECHNICAL SUPPORT send an e-mail directly to > > >> > SUPPORT {at} amibroker.com > > >> > > >> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at > > >> > http://www.amibroker.com/feedback/ > > >> > (submissions sent via other channels won't be considered) > > >> > > >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > >> > http://www.amibroker.com/devlog/ > > >> > > >> > Yahoo! Groups Links > > >> > > > > > > > > > > > ------------------------------------ > > > > > **** IMPORTANT PLEASE READ **** > > > This group is for the discussion between users only. > > > This is *NOT* technical support channel. > > > > > TO GET TECHNICAL SUPPORT send an e-mail directly to > > > SUPPORT {at} amibroker.com > > > > > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at > > > http://www.amibroker.com/feedback/ > > > (submissions sent via other channels won't be considered) > > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > > http://www.amibroker.com/devlog/ > > > > > Yahoo! Groups Links > > >
