If someone is interested, this is the mt5 version. Should work identical to the mt4. i've changed some variables and function names for my ease of use because i was planning to experiment with it, but i've realized i don't know much about grids so ...