Can anyone program this algorithm through IB api?: Initiate 5 long(or short) contracts positions with MHI for every 1 Short (or long) position with HSI simulanteously: On the winning side (regardless of long or short position), Average UP 1, 2, 3 â¦ contracts (variation of Anti-Martingale Model) adding 1 contract at each level. Levels are based on N/2 increment where N could be 20, 30, 40 or more ticks(pts). i.e. +1@ N/2, +1@ N,... basically, just accumulate one every N/2. On the losing side (short or long), Routine: Just average 1 contract every N, 2N, 4N, 7N levelsâ¦ (*In practice, I close both sides at 3N to reduce exposure and re-start the whole algorithm*) If the direction reverses and the winning side retrace by N/4 (round UP to whole number) i) For 2 contracts accumulated, square off both sides ii) For 3 contracts, take profit of 1 contract... iii) For 4 contracts, take profit of 2 contracts... iv) For 5 contracts, take profit of 3 contracts... etc When it retrace to the average of the losing side, square off both sides. If, however, after taking profit, it changes direction again and reverts forward by N/4, square off both sides. When it trends more than 3N level on either the long or short side, you can choose to continue or close both sides and restart the whole procedure. The net should always be a profit even after commissions for N>20 ticks & it moves beyond N.