Support Board
Date/Time: Mon, 25 Nov 2024 00:22:00 +0000
[Programming Help] - Simultaneous live/demo algo trading on one instance
View Count: 415
[2024-04-08 20:11:13] |
User414533 - Posts: 106 |
Is this possible? Any guidance that can be relayed to my coder?
|
[2024-04-09 04:25:51] |
User414533 - Posts: 106 |
Let me clarify my question with an example: Suppose I have 4 possibilities in a strategy: Trade A, B, C, and D. Each trade can trigger alone, or based upon the trigger of another possibility. Will the platform allow some of the possibilities to be set to execute on demo, with the remaining on live accounts? I can do this now with all demo, or all live; but we're trying to code for a combination. Thanks! |
[2024-04-09 14:01:54] |
emmanuel - Posts: 57 |
A trading study can only take trades on the trading account that's selected for the chart. So in the simplest sense, no it's not possible to have some trades on one account and other trades on another account. However, with some cleverness it may be possible to split trades as you suggested. You will first have to run two copies of the trading algo on separate charts; One copy per trading account. Then, you need a way for both instances of the algo to communicate with each other. DETERMINISTIC APPROACH This approach actually avoids the requirement that the two algo instances need to communicate with each other. Instead of communication, each instance "knows" which trades to take because the decision making process happens exactly the same way every time, without fail. An example would be that trade A always takes place on demo, but that it if triggers trade B always takes place on live. This can work because an algo can detect if a trade tiggers based on the price action, without actually taking the trade. Of course, when done this way there's no certainty that the trade actually triggered. NON-DETERMINISTIC APPROACH If the deterministic approach described above is a go-no, then you'll need to get the algos to communicate with each other. You can do this using a number of Microsoft Windows inner-process-communication (IPC) methods. I'll point out that IPC is non-trivial and error-prone, so if you can find a way to get the deterministic approach to work, that would be ideal. |
[2024-04-09 19:56:28] |
User414533 - Posts: 106 |
A trading study can only take trades on the trading account that's selected for the chart. So in the simplest sense, no it's not possible to have some trades on one account and other trades on another account.
However, with some cleverness it may be possible to split trades as you suggested. You will first have to run two copies of the trading algo on separate charts; One copy per trading account. Then, you need a way for both instances of the algo to communicate with each other. I am currently successfully running a configuration where I have two charts; one with a parent trading study and one with a child. My main study has two account settings where it shuffles conflicting trades to account #2. These do have to communicate with each other depending on trade conflicts. My initial layman's idea was to have 4 account settings coded with an added Deterministic Approach, like you mentioned above, to basically switch one or more accounts to demo. This new feature does not have to behave dynamically. But the original (dynamic) function must remain to avoid bi-directional trade conflicts. Date Time Of Last Edit: 2024-04-09 21:13:33
|
[2024-04-10 07:15:40] |
User61168 - Posts: 403 |
I am not a qualified programmer...just a guy keeping everything simple with simple alerts so here's my 2 cents: 1) clone the charts: one for live account and one or more for each demo account with their respective study collections 2) Use price overlay study on live chart to pull in the open position qty (and average price line if required) of each demo account chart 3) check for open trade qty/price in your live trade entry logic as a condition before sending the live order to your trading service. |
[2024-04-10 12:55:37] |
emmanuel - Posts: 57 |
To elaborate on User61168's idea, if you squint at a pair of subgraphs, you can see a form of inter-process communication, all taking place within Sierra Chart. Let's say you have a parent study that needs to send a message to a child study. The parent study can create two hidden subgraphs: 1. A signaling subgraph. 2. A data subgraph. Together, these two subgraphs form a unidirectional communication channel. The signaling subgraph would contain a value which indicates the message that's being "sent.": enum SignalEnum {
NO_SIGNAL // This simply makes NO_SIGNAL equal to 0, the default signal. , INTENT_TO_TAKE_TRADE // This makes INTENT_TO_TAKE_TRADE equal to 1. , IGNORE_TRADE // ... }; For instance, if the parent study intents to take a given setup, it would write the "INTENT_TO_TAKE_TRADE" message (which is simply a specific number) to the signal subgraph and then write the bar number (the array index) of the bar where the trade setup is to the data subgraph. The price overlay study which User61168 mentioned would be used to copy these subgraphs to the child study so that the child study can "see" them. The same idea can be used in the opposite direction to have the child study send messages to the parent study. |
To post a message in this thread, you need to log in with your Sierra Chart account: