# Strategy Designer

StockHero's latest revolutionary Strategy Designer allows a trader to create complex strategies easily. A complex strategy can also be loosely called a MultiStrat in the hedge fund world. Multiple strategies are combined to create an overarching strategy. For example, a long-short strategy is considered MultiStrat as it consists of a long strategy followed by a short strategy, with each executing consecutively.

StockHero's Strategy Designer offers advanced traders the ability to create complex strategies that capture a greater part of the market movement. For example, a trader can create a long-short strategy using our Strategy Designer.

The actual implementation is via Daisy-Chain in StockHero. The Strategy Designer is only available for Advanced bot types.

Let us illustrate with an example on how to implement a Long-Short MultiStrat strategy.

* User creates Bot X (Advanced Bot) for Long strategy
* User creates Bot Y for Short strategy
* User configures Bot X to activate Daisy-Chain and also the "First in Daisy-Chain" option. When enabled, bot X will start to run after it is created. See picture below.

<figure><img src="https://4210655246-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLsxcsmD5Q5mNFpKtGm0X%2Fuploads%2FTowqWmNWjPovIn7HVjtl%2FScreenshot%202023-10-06%20at%2012.37.20%20AM.png?alt=media&#x26;token=a6e25c3a-faf0-48eb-8285-cc59e4a43b86" alt=""><figcaption></figcaption></figure>

* User sets Bot Y to activate Daisy-Chain but "First in Daisy-Chain" is NOT enabled. When bot Y is created, bot Y will NOT run. Its trigger is from Bot X as we will see below
* User sets bot X exit condition to trigger bot Y after X completes a deal. Similarly, Bot Y's exit condition has been set to trigger Bot X after Y completes a deal
* After X and Y are created, only X will run and monitor the market
* Bot X completes a deal and X sends trigger to Bot Y. X will NOT auto-restart. X will be deactivated
* Bot Y activates and monitors the market
* Bot Y completes a deal and triggers Bot X
* Bot X "wakes up" from its deactivated state and start to run. The whole cycle repeats.

As shown in the example above, a user has successfully created a Long-Short strategy.&#x20;

A user can link two or more bots in a daisy-chain as well.

\[Bot A]  > \[Bot B] > \[Bot C] > ….. > \[Bot Z]

If the LAST bot Z has NO trigger condition in the EXIT condition, the whole strategy (Bot A to Z) will only run once. But, if Bot Z Exit Condition has a trigger to Bot A, then the whole strategy repeats. I.e. Bot A will “wake up” and start to monitor the market.

StockHero's Strategy Designer is like a 4GL programming language for automated trading. A trader can create multiple bots, each with its own condition, in order to create a single holistic strategy. It is really up to the trader's expertise and imagination as to what complex strategy to setup using the Strategy Designer.

### Example 1

Three bots MultiStrat

| <p><br></p>     | Bot A                                                 | Bot B                                                  | Bot C                                                  |
| --------------- | ----------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------ |
| Entry Condition | <p>Activate Daisy Chain = True</p><p>First = True</p> | <p>Activate Daisy Chain = True</p><p>First = False</p> | <p>Activate Daisy Chain = True</p><p>First = False</p> |
| Exit Condition  | Trigger B                                             | Trigger C                                              | Trigger A                                              |

Above strategy will cause the following sequence: A > B > C > A > B > C > (repeats)

Bot A will activate on creating/updating since Activate Daisy-Chain = True AND First=True

### Example 2

| <p><br></p>     | Bot A                                                 | Bot B                                                  | Bot C                                                  |
| --------------- | ----------------------------------------------------- | ------------------------------------------------------ | ------------------------------------------------------ |
| Entry Condition | <p>Activate Daisy Chain = True</p><p>First = True</p> | <p>Activate Daisy Chain = True</p><p>First = False</p> | <p>Activate Daisy Chain = True</p><p>First = False</p> |
| Exit Condition  | Trigger B                                             | Trigger C                                              | Trigger B                                              |

Above strategy will cause the following sequence: A > B > C > B > C > (repeats)

You can see that Bot A is only run once as no other bot triggers Bot A.

### Example 3

<table data-header-hidden><thead><tr><th></th><th width="206"></th><th></th><th></th><th></th></tr></thead><tbody><tr><td><br></td><td>Bot A</td><td>Bot B</td><td>Bot C</td><td>Bot D</td></tr><tr><td>Entry Condition</td><td><p>Activate Daisy Chain = True</p><p>First = True</p></td><td><p>Activate Daisy Chain = True</p><p>First = False</p></td><td><p>Activate Daisy Chain = True</p><p>First = False</p></td><td><p>Activate Daisy Chain = True</p><p>First = False</p></td></tr><tr><td>Exit Condition</td><td>Trigger B</td><td>Trigger C</td><td>Trigger D</td><td>Trigger A</td></tr></tbody></table>

Above strategy will cause the following sequence A > B > C > D > A > (repeats)

### Example 4

<table data-header-hidden><thead><tr><th width="103"></th><th width="146"></th><th width="147"></th><th width="139"></th><th></th></tr></thead><tbody><tr><td><br></td><td>Bot A</td><td>Bot B</td><td>Bot C</td><td>Bot D</td></tr><tr><td>Entry Condition</td><td><p>Activate Daisy Chain = True</p><p>First = True</p></td><td><p>Activate Daisy Chain = True</p><p>First = False</p></td><td><p>Activate Daisy Chain = True</p><p>First = True</p></td><td><p>Activate Daisy Chain = True</p><p>First = False</p></td></tr><tr><td>Exit Condition</td><td>Trigger B</td><td>Trigger C</td><td>Trigger D</td><td>Trigger A</td></tr></tbody></table>

Above strategy will cause bots A and C to be activated together.

Sequence: A > B > C > D > A > (repeats)

What if Bot C activates BO first?, then, it will look like

C > D > A > B > C > D > A > (repeats)

Hence, there is a danger of “race condition” (in computer science where two resources compete for the same resource X) if a user sets two bots as First=True in a single daisy-chain.

So if a Bot X calls another bot Y to activate and Y is already active, X will become deactivated (as per normal, like a daisy-chain bot), but an error message will appear: “Attempt to call an active bot in the daisy-chain.” However, X can still be activated again if another bot triggers X as part of the Daisy Chain.

{% hint style="info" %}
Multiple Daisy Chains can be created as well such that each chain of bots are mutually exclusive.&#x20;
{% endhint %}

### Strategy Designer for TradingView

Daisy-Chain linking can also be activated for TradingView signals.&#x20;

Whenever a signal is received and if the bot has daisy-chain enabled, StockHero will check if the bot is "First in Daisy-Chain." If yes, the bot will execute a trade. If not, the bot will check the prior linked bot to see if it has already completed a deal. If yes, the bot will execute a trade; otherwise, it will do nothing.
