[Solved] Motion tracker ignores frame update

EDIT: Solution found and add-on made

I couldn’t put the “Detect Features” and “Track Markers” operators in a loop and have each loop operate from a different starting frame. The reason was I used the wrong frame update commands (commented in the script below)
Here’s the solution: a script that detects features 3 times, once every 20 frames and tracks them (during only 1 frame for faster testing). You can paste it in Blender’s text editor and run it, provided you have a Movie Clip Editor area with a clip open in it:

import bpy
C = bpy.context
ctx = C.copy()
for area in C.screen.areas:
    if area.type == 'CLIP_EDITOR':
        ctx['area'] = area

for step in range(3) :
    currFrame = (step*20)+1
    # ------------------WRONG COMMANDS-------------------
    #C.scene.frame_current = currFrame
    #bpy.ops.clip.change_frame (ctx, frame = currFrame)
    # ---------------------------------------------------

    # -------------------RIGHT COMMAND-------------------
    area.spaces[0].clip_user.frame_current = frameNumber
    # ---------------------------------------------------
    bpy.ops.clip.track_markers(ctx, backwards = False, sequence = False)