ALGO transfers via TRADE struct manipulation

Posted By: Jack_Zodiac

ALGO transfers via TRADE struct manipulation - 01/15/23 16:01

Hello,
I am working on a script that has both counter-trend and trend-follower component ALGOs. Not infrequently the trend-follower wants to start buying before, or at the same time as, the CT ALGO wants to sell. So it would be desirable to hand off lots between the ALGOs without buying/selling to market. While preserving Zorro's profit statistics for each ALGO. (I.e., as if there had been a cost-less sell/buy at the average bar price)

So the question: is it possible (or advisable) to try to handle this by selecting an open TRADE of the lot-holding ALGO and decrementing its lots, and then entering (or lot-incrementing, if open) a TRADE of the lot-receiving ALGO. (Or if that won't work directly, cancelling an existing TRADE and entering an altered one.) And then what components of the modified TRADE structs will Zorro update for me, and what do I have to figure out & also update manually (open/closed flags, profit, entry/exit prices, etc.) to preserve profit stats and otherwise not mess things up?

Thanks in advance for any insights!
Posted By: jcl

Re: ALGO transfers via TRADE struct manipulation - 01/16/23 13:43

You're right in avoiding simutaneous long and short positions of the same asset. But you need no special code for that, simply set Hedge = 5.
Posted By: Jack_Zodiac

Re: ALGO transfers via TRADE struct manipulation - 01/16/23 15:57

Thanks for the pointer!

Is the difference between virtual hedging and TR_PHANTOM TradeMode, that in TR_PHANTOM mode the phantom trades are not collected into the pool trades that the broker receives?
Posted By: jcl

Re: ALGO transfers via TRADE struct manipulation - 01/19/23 16:01

Exactly. TR_PHANTOM does not affect pool trades.
© 2024 lite-C Forums