Quick-tip 29 shows an example of creating a very simple counter that increments each bar by 1 and another that increments each tick by 1.
The quick-tip then explains why the counter does not seem to work when we try to increment it with a value that is less than one.
Video explanation
{ THIS SHOW ME STUDY IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION IS AT YOUR OWN RISK. THIS SHOW ME STUDY AND ASSOCIATED TECHNIQUES IS AN EXAMPLE ONLY, AND HAS BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF THIS SHOW ME STUDY DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.} Vars: intrabarpersist int Ctr1( 0 ), int Ctr2( 0 ); Once ClearPrintLog; Ctr1 += 1; // Equivalent to Ctr1 = Ctr1 + 1; Ctr2 += 1; // Equivalent to Ctr2 = Ctr2 + 1; Print( "Quick-tip 29 Ctr1 (intrabarpersist) ", Ctr1," Ctr2 (NOT intrabarpersist)", Ctr2 ); { ** Copyright (c) 2019 Markplex Corporation. All rights reserved. ** ** Markplex Corporation reserves the right to modify or overwrite this analysis technique on its https://markplex.com Web site. ** }
After
{ THIS SHOW ME STUDY IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION IS AT YOUR OWN RISK. THIS SHOW ME STUDY AND ASSOCIATED TECHNIQUES IS AN EXAMPLE ONLY, AND HAS BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF THIS SHOW ME STUDY DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.} Vars: intrabarpersist double Ctr1( 0 ), double Ctr2( 0 ); Once ClearPrintLog; Ctr1 += 0.25; Ctr2 += 0.25; Print( "Quick-tip 29 Ctr1 (intrabarpersist) ", Ctr1," Ctr2 (NOT intrabarpersist)", Ctr2 ); { ** Copyright (c) 2019 Markplex Corporation. All rights reserved. ** ** Markplex Corporation reserves the right to modify or overwrite this analysis technique on its https://markplex.com Web site. ** }