question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use or implement Opening Range Breakout Strategy with EMA in real market

See original GitHub issue

Which version are you running? The lastest version is on Github. Pip is for major releases.

import pandas_ta as ta
print(ta.version)

0.1.97b

Upgrade.

$ pip install -U git+https://github.com/twopirllc/pandas-ta

Is your feature request related to a problem? Please describe. Not exactly. I want to understand how to use pandas_ta for opening range or time range breakout strategies in real market. Is it only for technical analysis or can be used in real market.

Describe the solution you’d like Some example in real market suppose I want to use it for Indian broker like Zerodha/AliceBlue/Samco who provide API and tick data. I want to create a simple opening range breakout strategy for first 15min or 30min or 1hr time. But at the same time want to check whether LTP is above EMA 21, how can I do it using pandas_ta? How to create this custom strategy and where I should use the broker API when I get a signal. I saw the jupyter notebooks there is too much information and it confuses me a lot. Simple examples can be helpful.

Thanks for using Pandas TA!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
rahulmrcommented, Dec 29, 2020

So finally I started working on this long pending stuff. Here is my code

import yfinance as yf
import pandas_ta as ta

import schedule

sbin = yf.Ticker("SBIN.NS")

def place_order(order_type):
    print(f"Place {order_type} order")

def run_strategy():
    df = sbin.history(period="3d", interval="15m")
    print(df)
    df.ta.cdl_inside(append=True)
    df.ta.vwap(append=True)
    print(df)
    condition = df.iloc[-1]['CDL_INSIDE'] == 1 and df.iloc[-1]['VWAP'] > df.iloc[-1]['close']
    if condition:
        place_order('buy')

# This is expected to run every 15 minutes (some 10-15 seconds like 9:30:10 AM IST) 
# Yfinance provides data with some delay - broker data will not have that delay
schedule.every(interval=15).minutes.do(run_strategy)



# df = sbin.history(period="3d", interval="15m")
# print(df)
# df.ta.cdl_inside(append=True)
# df.ta.vwap(append=True)
# print(df.iloc[-1]['CDL_INSIDE'])
# print(df.iloc[-1]['VWAP'])
# ## TODO Add EMA 7 and EMA 21 , can we also get Pivot Points Fibonacci ?
## I also have thoughts on how can we create a simulation of previous days
# Like getting data by adding 15 minutes to it. That is another part though.
# creating a watchlist of Indian Stocks and applying this.

1reaction
twopirllccommented, Mar 2, 2021

Hello @rahulmr,

Just came across hackingthemarkets: Fullstack Trading App repo. It contains an ORB Strategy (backtest.py) but using Alpaca API (import alpaca_trade_api) for trade execution. It may be a good starting point to decompose and replace Alpaca with your broker. Of course you will need to forward test on a paper/demo account and adjust it for live execution.

Kind Regards, KJ

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Trade Opening Range Breaks (ORBs) Trading Strategy!
DAY TRADING OPTIONS GUIDE! https://themattdiamond.gumroad.com/l/daytradingoptionsguideFollow me on social media to connect:Twitter ...
Read more >
An Early Morning Trader Strategy: The Opening Range Breakout
There is a very popular strategy called ORB (Opening Range Breakout) which intraday traders use to attempt to profit from the day's opening ......
Read more >
MACD Trading Strategy - How to Implement Indicator settings
Take breakout trades only in the trend direction. The trend is identified by 2 EMAs. The trend is up if the 50 EMA...
Read more >
The Opening Range Breakout Trade - EminiMind
Wait for the first 15-min bar to form. · Using a buy and sell stop, place an order 1 tick above the high...
Read more >
How to Day-Trade With Keltner Channels - The Balance
The general strategy is to buy if the price breaks above the upper band or sell short if the price drops below the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found