You have to add that code to the expressions of the columns used by the original statistic and not directly in the statistic itself. When you have the new columns then you can create a new statistic that uses them. See
this guide for the basics on custom statistics creation and
this guide for a deeper walkthrough.
Also you do not need to create a custom statistic to display that information in your HUD. You can do this via the 'Item Properties' tab at the top right of the HUD Profile Editor window. Select the stat you wish to configure and scroll down to where it says 'Has Position'. So if you want to do 'Fold to F CBet IP' you would select the 'Fold to F CBet' stat, and change the 'Has Position' item property to 'In Position on Flop'. This works for any of the postflop stats in our library. Also you can choose any of the 6 major positions (Early, Middle, Cutoff, Button, Small Blind, Big Blind) for any preflop stats.