Strategies from PHI 1’s Webinar – Creating a MACD Strategy on PHI 1 (6th November 2020)

(Disclaimer: These strategies were showcased as part of our educational webinar – Creating a MACD Strategy on PHI 1 (6th November 2020). The purpose of sharing these strategies is purely educational. Please do not consider these for investment purpose)

1. MACD Strategy

Original Source: View Video

You will find the entry and exit condition in this video which you can create using PHI 1’s Strategy Creator in the Form Code (No coding required)

2. Guppy Multiple Moving Averages Strategy

Original Source: View Video

Since this one is a complex strategy, we have created this one using PHI 1’s Strategy Creator in the Code Mode.

Here’s the code for the same. You can try it out for free

INIT

# short term moving averages

self.sema1 = EMA(close,period=3)

self.sema2 = EMA(close,period=5)

self.sema3 = EMA(close,period=8)

self.sema4 = EMA(close,period=10)

self.sema5 = EMA(close,period=12)

self.sema6 = EMA(close,period=15)

 

# long term moving averages

self.lema1 = EMA(close,period=30)

self.lema2 = EMA(close,period=35)

self.lema3 = EMA(close,period=40)

self.lema4 = EMA(close,period=45)

self.lema5 = EMA(close,period=50)

self.lema6 = EMA(close,period=60)

# confirmation long term moving average

self.conf_lema = SMA(close,period=200)

# ATR

self.atr = ATR()

————————————
STEP

 

# entry

if self.position.size == 0:

list_sema = [self.sema1[0], self.sema2[0], self.sema3[0], self.sema4[0], self.sema5[0], self.sema6[0]]

list_lema = [self.lema1[0], self.lema2[0], self.lema3[0], self.lema4[0], self.lema5[0], self.lema6[0]]

 

if min(list_sema) > max(list_lema) and low[0] > self.conf_lema[0] and min(list_sema) > self.conf_lema[0] and min(list_lema) > self.conf_lema[0]:

# buy_bracket(limitprice=close[0] + self.atr*8, price=close[0], stopprice=close[0] – self.atr*4)

buy()

#exit

if self.position.size > 0:

list_sema = [self.sema1[0], self.sema2[0], self.sema3[0], self.sema4[0], self.sema5[0], self.sema6[0]]

list_lema = [self.lema1[0], self.lema2[0], self.lema3[0], self.lema4[0], self.lema5[0], self.lema6[0]]

if min(list_sema) <= max(list_lema) or low[0] <= self.conf_lema[0]:

square_off()

READ :   7 reasons PHI 1 is a unique algo trading platform

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_Webminar

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 : / / / / / / / /

Q & A – Creating a MACD Strategy on PHI 1 (Webinar)

(Disclaimer: This Q&A session was part of our educational webinar – Creating a MACD Strategy on PHI 1 (6th November 2020). The purpose of sharing these strategies is purely educational. Please do not consider these for investment purpose)

Q.1. What if I deploy a strategy on multiple symbols? If Symbol 1 matches the condition, then what happens to other Symbols?

A. If Symbol 1 matches the conditions in your strategy, then the system will generate a signal for Signal 1 only, not for any other Symbols. Even if you deploy the same strategy for multiple symbols, each symbol functions as an independent one and there’s no dependency on other symbols.

If your broker account has enough balance, the system will generate and execute signals whenever the conditions are met for each symbol.

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

Q.2. For how much duration can I run a strategy?

A. It’s up to you. You can run it forever or you can decide an end date for it and the strategy will run as per your instructions.

Q.3. If there is a tweak in my mind that is not possible within the form mode, can your team code it for me?

A. If you want to add an additional condition or make a change to the time period or your exit conditions, then you can do it from the Form Code itself.

If you think it is a complex one, and it is not possible from the Form Code, then you also have access to the Code Mode. You can edit it from the Code Mode as well.

We do realize that not all traders are familiar with coding syntax, so yes, if you need any assistance, do let us know and we will help you out.

Q.4. Can I add an ATR based stop loss?

A. Yes, you can

Q.4 Do I have to pay to try these strategies in PHI 1?

A. No. Both Creation Modes – Form Mode and Code Mode are available on the free plan. The only restriction is the number of strategies you can create at once.

READ :   7 reasons PHI 1 is a unique algo trading platform

Q.5. Is my strategy private? Or is it visible to other users as well?

A. Your account activity and strategy are completely private and only accessible to you. We encrypt all user information with the best in class encryption service. So, be assured that your strategy is only with you, not even us.

Q.6. Can I deploy this on Options?

A. Yes. You can.

Q.7 Which language do you use to code a strategy in PHI 1?

A. We use Python, but to code a strategy you just need to be aware of basic Python Syntax.

(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.

Take a free trial today ! Tagged : / / / / / / / /

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 : / / / / / / /