Q & A – Trading Strategies: Introduction (Webinar)

(Disclaimer: This Q&A session was part of our educational webinar – Trading Strategies: Introduction on 18th September 2020 by PHI 1 – An end-to-end algo trading platform. The purpose of sharing these strategies is purely educational. Please do not consider these for investment purpose)

(Click here to watch the complete recording of the webinar)

Q.1. How are you carrying the short trades for so many days? Aren’t you supposed to square off the position at the end of the day? (Starts at 15:00 in the video)

A. That is correct. What we are doing here is backtesting our strategy. The idea here is that you can easily create a strategy, check whether it works or not. We are trying it out on equities. You also have an option to try this out on the Futures and rollover the contracts whenever they expire.

Once you are confident enough, you can try it on real-world conditions. For example, you can run it at a higher time-frequency, at an hourly level or minute level. All those frequencies are available in the platform, in which case you will get your long/ short signals and the square off within the day or within the week itself.

Q. 2. Can you analyze multiple symbols or instruments at the same time? (Starts at 18.30 in the video)

A. You can analyze up to 8 symbols or instruments at the same time. Not only symbols, but you can run your strategy on multiple time intervals as well.

Q. 3. Is this code available on the platform? (Starts at 23.00 in the video)

A. The code shown in this webinar is not available on the platform. We have shared the code in the form of a blog article. You can view the code here – (link)

Although, there are a few code templates available in the platform which you can try out at any time. (Shown in the screenshot below)

Create Strategy

Q. 4. Are there any more calendar controls other than the day controls? (Starts at 23.55 in the video)

A. Apart from day control, there is time control, week control, month control, and date control.

Time Control

You can specify the start and end date for the day.
For example – Trade between 10 am and 2 pm, if you think the volatility at the start and the end of the day is too much for your strategy.

Week Control

You can specify during which week to trade or not to trade
For example – Do not trade in the week when there is monthly expiry

Month Control

You can specify during which months to trade or not to trade

Date Control

You can specify dates on which you do not want to trade
For example – Budget Day or Monthly Expiry, etc.

Q. 5. Is there a way to learn these parameters? (Starts at 25.15 in the video)

A. You can visit our learn section to know more about the parameters to use in your code. The key here is to try out multiple things and backtest it multiple times to understand what works and what doesn’t.

Q. 6. Can I run a strategy on multiple time intervals?

A. You can run your strategy at multiple time intervals.

Q.7. Can I build a Keltner Channel Trading Strategy on PHI 1? (Starts at 28.15 in the video)

A. You have more than 120+ indicators to play around with on the PHI 1 platform so even building a complex strategy like Keltner is not a problem. If you want help in coding it, then please schedule a demo session with us and we will help you out.

You can also access the code guidelines in our learn section – https://app.phi1.io/Learn You can code the strategy using these 120+ technical indicators.

Example – Code for MACD – https://app.phi1.io/articles/macd

Q.8. I don’t know how to code. How do I get started with PHI 1? (Starts at 30.00 in the video)

A. There are 2 ways we can help you here.

If you have a trading strategy with clear rules with you, then schedule a session with us and we will help you code it.

The other piece is in progress. We are working on a form-based strategy builder that will help you build your strategy without any coding. That’s still in progress. Till then, you can always connect with us and we are happy to help you code your strategy.

(Click here to watch the complete recording of the webinar)

If you need any help or have any questions, then please schedule a demo session with us and we will help you out.

Tagged : / / / / / / /

3 Trading Strategies You Can Code and Backtest on PHI 1 Right Now

(Disclaimer: These strategies were showcased as part of our educational webinar – Trading Strategies: Introduction on 18th September 2020. The purpose of sharing these strategies is purely educational. Please do not consider these for investment purpose)

1. Pairs Trading Strategy (Using Kotak Bank & HDFC Bank using Day Frequency)

Init:

self.val = self.datas[0].close/self.datas[1].close

self.boll = BollingerBands(self.val, period=40, devfactor=2)

—————————————————————————————

Step:

if (self.val[0] < self.boll.lines.bot[0]) and (self.position.size==0):

  self.sell(data = self.datas[1])

  self.buy(data =  self.datas[0])

if (self.val[0] > self.boll.lines.mid[0]) and (self.position.size>0):

  self.sell(data = self.datas[0])

  self.buy(data =  self.datas[1])

READ :   Top 5 Best Algo Trading Software in India 2021

2. Trend Following Strategy (TURTLE TREND on Reliance Industries, 1 day)

Init:

class DonchianChannels(bt.Indicator):

    lines = (‘dch’, ‘dcl’,)  #dc high, dc low

    params = dict(

        period=20,

        lookback=-1,  # consider current bar or not

    )

    def _init_(self):

        hi, lo = self.data.high, self.data.low

        hi, lo = hi(self.p.lookback), lo(self.p.lookback)

 

        self.l.dch = bt.ind.Highest(hi, period=self.p.period)

        self.l.dcl = bt.ind.Lowest(lo,  period=self.p.period)

       self.donchian = DonchianChannels()

self.count1 = 0      

———————————————————————————————

Step:

if (self.data.close[0] > self.donchian.dch[0]) and (self.position.size==0):

   order_target_percent(target=1)

if (self.data.close[0] < self.donchian.dcl[0]) and (self.position.size>0):

   order_target_percent(target=0)

if (self.data.close[0] < self.donchian.dcl[0]) and (self.position.size==0):

   order_target_percent(target=-1)    

if (self.data.close[0] > self.donchian.dch[0]) and (self.position.size<0):

   order_target_percent(target=0)

3. Mean Reversion Strategy (ONGC Hour frequency; Calendar Selection: Wednesday)

Init:

self.boll = BollingerBands(period=21, devfactor=2)

self.count1 = 0

Step:

curr_date = self.datetime.datetime(ago=0)

if risk_control_window(curr_date):

 

   if (close < self.boll.lines.bot) and (self.position.size==0):

       order_target_percent(target=1)

 

if (self.position.size > 0):

   self.count1 = self.count1 + 1

  

if (close > self.boll.lines.top) and (self.position.size>0) and (close[0] > close[-self.count1]):

    order_target_percent(target=0)

    self.count1 = 0

 

if (self.count1 > 4) and (close > self.boll.lines.mid) and (self.position.size>0) and (close[0] > close[-self.count1]):

    order_target_percent(target=0)

    self.count1 = 0

 

if (self.count1 > 4) and (close[0]/close[-self.count1] > 1.02) and (self.position.size>0):

    order_target_percent(target=0)

    self.count1 = 0

   

if (self.count1 > 4) and (close[0]/close[-self.count1] < 0.98) and (self.position.size>0):

    order_target_percent(target=0)

    self.count1 = 0

  

if (self.count1 > 10):

   order_target_percent(target=0)

   self.count1 = 0

(Click here to watch the complete recording of the webinar)

How to use this code on PHI 1?

  1. Copy & Paste the Init code in the – Enter initialize code here section
  2. Copy & Paste the Step code in the – Enter step code here section
  3. Click Run And Save

Trading Strategies Webinar Screenshot

If you need any help or have any questions, then please schedule a demo session with us and we will help you out.

Happy Trading,
Team PHI 1

Tagged : / / / / / / /