You are on page 1of 15

StrategyQuant

AlgoWizard
QuantAnalyzer
QuantDataManager

Company
Learn & Support
Blog

Account

Forum
Login

Products

StrategyQuant

AlgoWizard

QuantDataManager

QuantAnalyzer

Company

About
Contact us
Partner with us
Team
Blog
Support
Spojte se s námi i na

sociálních sítích

Blog
Documentation
Codebase

More

Shared
Forum
Contact us

Introduction to the StrategyQuant templating


system – Part II
In the previous article (link) I explained how StrategyQuant templating system works and how you can define strategy logic using template. In this
article I will continue with practical example directly in StrategyQuant.

Loading templates into StrategyQuant


How to generate strategies using a template? You can choose which template will be used in Builder/Full Settings/What to build tab. The third option is
“Strategy from template”. Let’s choose example template SQ4StrategyTemplateExample.sq4 from folder C:\StrategyQuant
X\user\settings\StrategyTemplates
Using templates for generating strategies in StrategyQuant

Modifying templates logic


Now let’s move into AlgoWizard module and load above mentioned template SQ4StrategyTemplateExample.sq4 from folder C:\StrategyQuant
X\user\settings\StrategyTemplates
Loading template into AlgoWizard for further editing

On the image below, you can see template loaded in StrategyQuant. It consists of several tabs.

Trading signals
Long entry
Short entry
Long exit
Short exit

The number of tabs is optional. You can define one or even ten tabs depending on the complexity of the strategy and your preferences. Red markers
indicate parts in the template where building blocks or values will be used.

The template can consist of multiple tabs

Conditions part:
The section marked with orange frame defines conditions part.

Now let’s focus on the “Long entry” tab and describe its parts. The first section marked with the orange frame is “If conditions”. Here you define which
conditions must be met to perform the action. On the image above, you  can see that conditions defined on the “Trading signals” tab are being used.
However, you can add as many conditions you want, according to your preferences (will be discussed later in an example).

Action part:
The section marked with the orange frame define actions part.

This part of the template defines  what will happen if all conditions are met. You can find it on the image above marked with the orange frame. For
now, let me skip the details. You just need to know that this will simply open a trade.

Adding extra filter


Adding new condition

Finally, let me show you how to add your  first condition to the example template. Click on the  “Add another condition” button.

Select comparison “Is greater”


Now click on the #Left# and choose Close[1], then click on #Right” and  select MovingAverage(200)

The new condition has been added


You can save the template as a new file

Saving template
Selecting the template for generating strategies

Now you can start generating strategies using your modified template.

Conclusion
As you can see, using  templating system opens almost unlimited possibilities for generating strategies. Many of you have been asking me how to
preset StrategyQuant for creating strategies for Gaps , Pullbacks,.. etc. Now you can do it easily by yourself.

Thank you for your attention and I wish you a lot of success with the realization of your trading ideas.

Kornel Mazur

Please login to comment

8 COMMENTS   Oldest

Pieter Kotzee

February 27, 2020 4:25 am

Great article.
Is it possible to reference a second data source in the templates above? I am looking into
intermarket analysis and an example would be the ES and the NQ. If the ES is leading (and
NQ therefore lagging) and the NQ diverge, trade the NQ with the assumption the
divergence is temporary and it will follow the ES again eventually.

Mark Fric
 Reply to Pieter Kotzee 
February 27, 2020 8:40 am

you can use multiple charts (symbols or TFs) for your randomly generated blocks, but right
now it is not possible to choose that random block 1 will use chart 1 and random block 2 will
use chart 2.
But we are working on it, templates functionality will be greatly enhanced in the new build
127.

Emmanuel (@emmanuel1)

November 27, 2021 11:18 pm

This is very helpful, would it be possible to have more examples :


For example, closing 50% position at target price and breakeven stop
Then closing on random condition the other 50%
Another template, would be to take a second position on the first stop and close
Both position on profit or second stop loss.
Another, possibility, would be to take an hedge position instead of a stop loss
Another template would be multiplier position,
a sideway strategy template would be a good test as well

tomas262 (@tomas262) Admin

 Reply to Emmanuel 
November 29, 2021 8:39 pm

Partial closing is not possible now. Better open 2 orders with 50% size and set different
targets for each
1

Emmanuel (@emmanuel1)
 Reply to tomas262 
November 30, 2021 1:33 pm

Thank you tomas for your answer, I will use 2 orders 🙂

Emmanuel (@emmanuel1)

November 27, 2021 11:37 pm

where is this strategytemplate folder ? i didn’t find these example


It would be helpful to have example of ‘action’, ‘if then’, tab as well.
How do you declare variable ?
Can they work in a template in SQX ?
Thank you for this instructive article 👍

PaperoneJ12 (@davide-politecgmail-com)
 Reply to Emmanuel 
January 15, 2022 8:28 am

The folder is reported in the article 😉 Anyway, it is C:\StrategyQuant


X\user\settings\StrategyTemplates
You can create a new variable in the “other properties” menu on the top right of the streen 😉

 Last edited 1 month ago by PaperoneJ12

PaperoneJ12 (@davide-politecgmail-com)

January 15, 2022 8:30 am

I dont’ understand file extensions. Templates are .sq4 files, but strategies are saved as .sqx
files. Which is the difference between .sq4 and .sqx file?
Another question: is it possible to create a strategy template in java? I mean, create a .sqx
file from scratch.

 Last edited 1 month ago by PaperoneJ12


0

Continue reading

An interview with successful trader Naoufel

Kornel MazurFebruary 22, 2022

As first, I would like to thank you for your decision for sharing your trading insights with our trading community.  Before we will continue with discussing
algo-trading, could you please …

StrategyQuant vision for year 2022

Mark FricJanuary 24, 2022

The beginning of the new year is a special time for many of us. The previous year is definitely gone, and we feel like something new is starting again. I …
New What If Snippets

clonexDecember 28, 2021

Two new What If snippets, which allow us to test how strategy can be managed, depending on its current performance, have been added to the sharing
server. The first is …

Products
StrategyQuant
AlgoWizard
QuantAnalyzer
QuantDataManager

Resources
Blog
Documentation
Forum
Support
Report bug / suggest idea

Company
About us
Contact us
Team
Partner Program

Follow us
Facebook
YouTube
Twitter

Privacy policy
Terms of use

Risk Disclosure:
Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment.
Risk capital is money that can be lost without jeopardizing ones’ financial security or life style. Only risk capital should be used for trading and only those
with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical Performance Disclosure:


Hypothetical performance results have many inherent limitations, some of which are described below. no representation is being made that any account
will or is likely to achieve profits or losses similar to those shown; in fact, there are frequently sharp differences between hypothetical performance
results and the actual results subsequently achieved by any particular trading program. One of the limitations of hypothetical performance results is that
they are generally prepared with the benefit of hindsight. In addition, hypothetical trading does not involve financial risk, and no hypothetical trading
record can completely account for the impact of financial risk of actual trading. for example, the ability to withstand losses or to adhere to a particular
trading program in spite of trading losses are material points which can also adversely affect actual trading results. There are numerous other factors
related to the markets in general or to the implementation of any specific trading program which cannot be fully accounted for in the preparation of
hypothetical performance results and all which can adversely affect trading results.

Testimonial Disclosure:
Testimonials appearing on www.strategyquant.com may not be representative of the experience of other clients or customers and is not a guarantee of
future performance or success.

You might also like