TradestoryTradeStory Website↗️

No results

Help CenterStoriesStory ItemsSet Context

Set Context

Last updated February 10, 2024

Every time a story runs it has its own Context.  This is a mechanism of allowing the story to execute and be aware of any data it accesses or changes.

The Set Context Story Item allows you to save a value in the current story context, that other story Items can have access to if they wish. 

For example, if your story requires access to your account balance multiple times within the same story, it will be more efficient to get your account balance one time, save it, and refer to it directly.  That way TradeStory only has to access your broker one time to get the information it needs to run quickly, rather than having to wait for your broker to send account information multiple times.  The example below gets the balance, saves it to context and shows an example of referring to this context to log out the balance.

Note: setting Context data does not store the value long term - the context only ‘lives’ as long as the story runs.  If you wish to store and refer to data/variables for longer term access or cross-story data storage, please refer to Strategy Variables and Set Strategy Variable Item.

Accessing context data later on in your story is easy using the Context Data Data Item.

Was this article helpful?