We are taking all your queries on writing your script/strategy on algoZ in the blog, “Code your Technical Analysis Strategy”. I have gotten a few queries like, “Once you have written a script, what next?” Though it is explained in the user manual, let me show you below how to take the strategy live, how to run/stop it, how to have a preset stop loss, and more…
In the simple example, we had used a really basic strategy which was on a 14-candle EMA. So, basically, the strategy is “buy” if the price of the stock goes over the 14 EMA and “sell” if it goes under. The problem with a strategy like this is that if you are looking at a 1-minute/5-minute/hourly candle, this crossover will happen quite frequently giving a lot of trades. In the simple example, we had gotten 823 trades over a 22-day period in the backtesting report which is pretty high by any standards.
To explain how to manage your script, I will use another example, the one that has been asked in the tutorial blog by one of you.
Strategy: The same 14 EMA crossover as mentioned in the example above, but we use RSI as a filter. Typically, RSI below 30 means that it is getting oversold and if above 70 it is getting overbought. So what we want to do is buy/sell on 14 EMA crossover but buy if RSI is below 45 and sell if RSI is above 55.
Here’s the script:
Buy Expression: Close>EMA(Close,14) AND RSI(Close,14)<45
Sell Expression: Close<EMA(Close,14) AND RSI(Close,14)>55
Buy exit : 0
Sell exit: 0
Contract: Nifty Futures.
The script window will look like this:
Backtest Window: You will see that by having the RSI condition, the total number of trades in the 22-day period has dropped from 823 to 19, but the net profit on backtesting shows only 43 points. See the pic below. Also, if you notice in the backtest report the largest loss making trade was 200 points and this could have been controlled at 50 points by having a SL which would have improved the profitability of this strategy.
Taking it live/Alert Preference: As shown in the first example, when you click on the Live button you get a new window “Alert preference”, which is the menu to preset the Quantity/SL/Type of the order you want to execute when the strategy gives you a signal.
Managing your script once you have taken it live:
In the pic above, once you have clicked on submit, the strategy goes live. To see all the live scripts/strategies that you are running on your account you can go to the link shown below:
Once you click on Pulse Running Scripts you will get the window as shown below:
Once you have taken a strategy live, all you have to do now is wait for the buy/sell alerts to pop up. If you click “Act on Alert” an order is placed based on your alert preference as shown above.