Skip to content

Create (Advanced)

Create Plus is the advanced version of the Create page that allows creation of longer and more complicated strategies. You can access it by heading over to the Create page and click on following icon as shown here in the top right corner of the Create page. There are several differences between the Basic Create page and the Advanced Create page.

Switch mode

Comparator

Create Plus supports the following comparators:

  1. up by/down by
  2. crosses above/crosses below
  3. lower than equal to/higher than equal to
  4. lower than/higher than/equal to

Detailed explanation for each of the comparators is explained here

Math operator

You can also use math operators to add, subtract divide and multiply values. Math operators are usefull for creating complex conditions. How is it helpfull?

Let's understand this with an example

Example

Suppose you want to trigger an entry when there is a rising RSI. But you don't know by what percentage the RSI should rise. Now, how do we create this condition?

Ok, first lets consider a stock moving in a straight line. Straight price line For the above stock, what is the difference between the price on September 3rd and September 2nd? The answer is 0. So, if I were to create a condition to look for the movement like in the above chart, I would put in the below mentioned condition: Close(0) - Close(-1) equal to 0

Again, lets consider a stock, whose price is rising gradually. Slope price line For the above stock, there is a price difference between the candles. The difference between the price on September 3rd and September 2nd = INR 10 and the difference between the price on September 4th and September 3rd = INR 10. So, if we calculate the difference between all the candle it is going to give a positive number( i.e. higher than 0). So, if I were to create a condition to look for the movement like in the above chart, I would put in the following mentioned condition: Close(0) - Close(-1) higher than 0

Now, we are going to use the same logic for rising RSI, we are going to take the help of indicator offset and math operator to do this. An uptrending RSI can denoted by positive difference.

Condition:
RSI(14,0) - RSI(14,-1) higher than 0 and
RSI (14,-1) - RSI (14,-2) higher than 0 and
RSI(14,-2) - RSI(14,-3) higher than 0

The above expression calculating the difference between current candle RSI and previous candle RSI and checking whether this is higher than 0.

Rising RSI

Math Functions

You can also perform mathematical operations in a strategy using the Create Advanced page. This is not available in the Basic Create page.

Period Min and Period Max

Period Min: The period min function returns the item with the lowest value within stated period. This function takes in two arguments, one is the period and the other is a variable that users want to compare Period min(Period, Variable). It will process all the values mentioned for the period number specified and return the minimum value.

Example

Entry on:SBIN Time frame:1 day

Conditions: Close(0) lower than Period Min(5, Low(-1))

The above query would generate a entry trigger on SBIN, whose current candle close price is lower than lowest low price of the past five days.

Example

In this example we are going to take the rising RSI example and simplify our conditions using Period min function.

Condition: Period Min (3,RSI(14,0) - RSI(14,-1)) higher than 0

The above condition is going to check for the same condition as in the RSI example, but we just write one line instead of 3 lines. Rising RSI with Math function

Period Max: The period max function returns the item with the highest value within stated period. This function takes in two arguments, one is the period and the other is a variable that users want to compare Period max(Period, Variable). It will check through all the values mentioned for the period specified and returns the maximum value.

Example

Entry on:SBIN Time frame:1 day

Conditions: Close(0) higher than Period Max(5, high(-1))

The above query would generate a entry trigger on SBIN, whose current candle close price is higher than highesh high price of the past five days.

Min and Max

Min: The min() function compares two variables and returns the item with the lowest value. This function takes in two variable arguments, that users want to compare Min(Variable, Variable). This is different from Period min as this consider two variables instead of one. The min function is especially helpfull when you want to compare two independent conditions.

Example

Entry on:SBIN Time frame:1 day

Conditions: Close(0) lower than Min(SMA(Low,20,0), Low(-1))

The above query would first calculate previous 20 period's simple moving average(low price) and previous candle's low price and check which variable has the lowest value among them. Then the system will check if the current close price of the selected scrip (SBIN as per our example) is lower than the lowest of the two variables.

Max: The max() function compares two variables and returns the item with the highest value. This function takes in two variable arguments, that users want to compare Max(Variable, Variable). This is different from Period max as this consider two variables instead of one. The max function is especially helpfull when you want to compare two independent conditions.

Example

Entry on:TCS Time frame:1 day

Conditions: Close(0) higher than Max(SMA(High,20,0), High(-1))

The above query would first calculate previous 20 period's simple moving average(high price) and previous candle's high price and check which variable has the highest value among them. Then the system will check if the current close price of the selected scrip (TCS as per our example) is higher than the highest of the two variables.

Ceil and Floor

Ceil: The ceil() function approximates the given number to the smallest integer, greater than or equal to the given float value. This function is helpful when creating conditions that involve calculation of value and you are unsure about the result. This function rounds up the value to the nearest largest integer. Ceil(5.678) would be rounded up to 6.

Floor: The floor () function returns the largest integer less than or equal to the given number. Similar to Ceil function, this function lets you round off the value to the nearest largest integer. Floor(5.678) would be rounded off to 5.

Abs

The abs() function is similar to mod function and is used to return the absolute value of a number. abs(-6) and abs(6), both would return the absolute value of 6.

Example

Suppose, you want to create a condition to enter a instrument in which there is a sudden change in price level, in a short timeframe (current candle). To do this you want to calculate the difference in open and close price of the same candle and then check if the range is more than a specified level. In the below mnetioned example, the specified level is the previous days's Open - Close range.

Entry on:TCS Time frame:5 min

Conditions: Abs(Open(0) - Close(0)) higher than Abs(Prev N(Open,-1,day) - Prev N(Close,-1,day))

The above query would calculate difference between current candle (Open - Close) and previous day's (Open - Close) and check if current candle's open close range is higher than previous whole day's open close range. If this is true, an entry will be triggered

But I was unable to understand, why did you use abs() function?

Because abs function always returns a value and ignores whether it is positive or negative. In case of a green candle (Open - Close) would be negative but for a red candle (Open - Close) would be positive. So, the above condition will trigger a trade whenever there is a big price move irrespective of trend (Up or Down). Red and Green candle

Multi-Timeframe Functions

Multi-Timeframe (MTF): The multi timeframe() function allows users to perform multi timeframe analysis i.e check conditions for two different timeframes in a single query.

Note

MTF calculates value of larger timeframe indicator values on partial candles (since the larger timeframe candle takes more time to form). When MTF is used for backtesting, it can have look-ahead bias and live alerts may not always be verifiable with charts or match when backtested. This is because it is not possible to predict future OHLC values and indicator. You should test your strategy and understand the backtest result charts and not just deploy it on the basis of Profit/Loss.

Example

Suppose, you want to create a query where you want to create a strategy and take an entry when the stock is
a. trading above 10 EMA on a daily timeframe, and
b. hourly RSI is above 50, and
c. MACD is giving a buy signal in 5 min timeframe

You will be able to do this with just 3 lines now...

Candle Interval:5 min
Conditions:Close (0) higher thanMulti timeframe(day, EMA(Close,10,0)) and
Multi timeframe(hour, RSI(14,0) higher than 50) and
MACD (12,26,9,macd,0)higher than MACD (12,26,9,signal,0)



How does multi timeframe looks like without Streak?

Multi timeframe chart

Multi-Timeframe Completed (MTF-Completed): The multi timeframe Completed() function checks for completely formed candle(of same or larger timeframe). Unlike the MTF, MTF-Completed does not consider Partial candle information and does not have a look ahead bias.

If you create a condition as Close(0) crosses above Multi-timeframe completed(day, Supertrend(7,3,0)), then it will compare current candle’s close with the Supertrend on a completely formed day candle i.e yesterday’s Supertrend value. So Multitime-frame with offset of -1 = Multitime-frame completed

Example

Suppose, you want to create a query where you want to create a strategy and take an entry when the stock is
a. trading above 10 EMA on a daily timeframe, and
b. hourly RSI is above 50, and
c. MACD is giving a buy signal in 5 min timeframe

Candle Interval:5 min
Conditions:Close (0) higher thanMulti-timeframe Completed(day, EMA(Close,10,0)) and
Multi-timeframe Completed(hour, RSI(14,0) higher than 50) and
MACD (12,26,9,macd,0)higher than MACD (12,26,9,signal,0)

Brackets

Brackets are used to denote and group sub-expression. Bracket follow BODMAS rules. It allows you to exactly create your ideas the way you want. Let's say you have five logics based on which you want to create a strategy condition.

Example: Logic A and Logic B or Logic C or Logic D and Logic E
Conditions with Bracket: (Logic A and Logic B)OR Logic C OR (Logic D and Logic E)

The above condition will trigger an alert when either Logic A and B are true OR when Logic C is true OR when Logic D and E are true.

Risk Management and Position Sizing

Risk management is one of the most important factors when it comes to creating a strategy. Hence with the Create Advanced mode you get more options to fine tune your exit parameters using various types of target profit and stoploss, additionally you can choose to size your positions using two different methods. These parameters will allow you to mangage your risk better and further optimise your strategy.

Types Of Target profit (TP) and Stoploss (SL)

In Create Advanced mode you can choose to set your Target Profit (TP) and Stoploss (SL) in three different types as mentioned below

  • Percentage (Pct)
  • Absolute (Abs)
  • Points (Pts)

You can find these types under the exit condition section on the top right hand corner.

TPSL

  1. Percentage (Pct) Type TPSL

    This is quite simple and works exactly the same way it works in the Create Basic mode. The values entered here will be calculated on the basis of percentage from the entry price. When backtesting with multiple scrips with different values, Pct (%) type of TP/SL can be useful as the levels will be calculated with respect its value no matter if the scrip is worth 100 or 5000.

    Example:

    Position: Long
    Entry price: 500
    Stoploss % = 2 the SL level will be (500 - 2%) = 490
    Target Profit % = 4 the TP level will be (500 + 4%) = 520

  2. Absolute (Abs) Type TPSL

    As the name suggest this will consider the absolute amount of the trade while calculating the levels. In simple terms, you can input the total profit/loss amount where you'd like to exit your trade. Here the quantity has a significant impact on the TP/SL calculation. To determine the TP/SL level for Abs type, you have to take Total TP/SL value and divide it with the quantity. This result will then be added/subtracted from the entry price to get the respective TP/SL level.

    Example:

    Particulars Input TP SL levels Particulars Input TP SL levels
    Entry 500 Entry 500
    Quantity 40 Quantity 25
    Total SL 1000 475 Total SL 1000 460
    Total TP 2000 550 Total TP 2000 580

    From the above table we can see that the quantity indeed has a big impact on the TP/SL level. With the same Absolute TP and SL input, the levels differ when the quantity is changed. Let's further breakdown the numbers to understand how the TP/SL levels were generated.

    Position: Long
    Entry price: 500
    Quantity: 40
    Total Stoploss = 1000 the SL level will be (500 - [1000/40]) = 475
    Total Target Profit = 2000 the TP level will be (500 + [2000/40]) = 550

  3. Points (Pts) Type TPSL

    This is quite straight forward and similar to Pct type TPSL. The values entered here will be calculated on the basis of points (irrespective of the quantity and value of scrip) from the entry price. Let's say you want to exit when the scrip moves up by 10 points, now this movement can be big move for a scrip whose value is say 100, however the same movement can be quite a small move for a scrip whose value is 5000. This is something to keep in mind while using Points based TPSL type.

    Example:

    Position: Long
    Entry price: 500
    Stoploss = 12 the SL level will be (500 - 12) = 488
    Target Profit = 25 the TP level will be (500 + 25) = 525

Position Sizing

To manage and optimize risk, traders use different ways to size their positions. With Streak you can decide your position size using two methods

  1. Capital Based
  2. Risk Based

Capital Based

This parameter allows you to size your position based on the capital you assign. Once you assign the capital, the system will automatically calculate the maximum quantity that it can enter with the specified amount. Let’s understand this with an example.

Example

I want to allocate INR 25000 for each instrument. So you just have to enter “25000” under the Max allocation field and select the Position Sizing Type as “Capital Based”. Now let's assume the stock TCS is priced at 3294, the position size that can be bought at this price level with INR 25000 will be equal to 7.58 ~ 7 quantity. This is calculated as [ Max allocation / instrument price ]

If the same allocation is used for the stock SBIN which is priced at, let’s assume, 486.9 then the position size will be 25000/486.9 = 51.34 ~ 51 quantity.

Risk Based

As the name suggests, this method gives more importance to the risk aspect of the trade and helps you size the position accordingly. To size your position in this method, you have to input two values

A. Max SL per trade
B. Max SL per quantity

Value B is dependent on the type of TPSL selected by you. It is also important to note that with Risk-based position sizing, you can only select Percentage % (pct) and Points (Pts) based TPSL. Let us now understand more about this with examples

Example

  1. Risk-based position sizing with Percentage type TPSL

    Let’s assume, if in a single trade you don't want to risk more than 2% and the maximum that you want to risk is INR 3500 then the 2% becomes the Max SL per quantity and INR 3500 becomes the Max SL per trade.

    In such a scenario, your position size will be calculated as [ Max SL per trade / Max SL per quantity ]. So if you want to go long in SBIN, which as per our example is priced at 486.9, the position size will be 359.416 ~ 359 quantity [ 3500 / (486.9 *2%) ]

    After buying if SBIN falls by 2%, i.e breaches the SL of 477.16, the loss will be [486.9 - 477.16] * 359 = 3496.66. Which is within the Max SL limit that was mentioned in the strategy.

    With the same example if we change the SL to 4% (i.e increase the risk), the position size will be 179.7 ~ 179 quantity [ 3500 / (486.9 *4%) ]. As you can notice, with more risk (4% from 2%) the position size is reduced. Ergo, allowing you to control the risk better.

  2. Risk-based position sizing with Points type TPSL

    This is similar to the method for Pct type TPSL. Just that here the Max SL per quantity remains the same for every scrip. Hence the position size will also remain same for all scrips. Continuing with the same example of SBIN, priced at 486.9, with Max SL per quantity as 12 Points (Pts) and Max SL per trade as INR 3500. The position size will be 291.66 ~ 291 quantity [ 3500 / 12 ].

    If after buying, SBIN falls by 12 points, i.e breaches the SL of 474.9, your loss will be [486.9 - 474.9] * 291 = 3492. Which is within the Max SL limit that was mentioned in the strategy.

Note

Position sizing doesn't assume any margin requirements or leverage. It uses allocation and instrument price directly to calculate the order quantity. You should enter the allocation value such that margin requirements are being satisfied in your trading account for live trades. To check the margin requirements, visit your brokers' website.