Have you been following any guides?
There's one in this post about it in the old DPPt FAQ thread (which I will move sometime to the current FAQ).
General gist is go for the spot that is four spots in any direction away from you (or at least the one furthest away from you), avoid spots that touch other shaking spots, never walk up (because the protagonist's head blocks the spot above you), don't go for spots of a different kind than the previous (ie the way it shakes should be the same as the spot you went into previously), and don't go into spots on the edge/corners of grass patches (because there's a chance all four spots generated afterwards will be outside of the patch and hence the chain would end). Even then the chain may break because there's still some luck in it, but I can vouch that it is possible to get to 40 as I've done so many times myself.
If you have any other questions please ask them in the Help thread sticky. Closed.