Posts

Install ngrok on linux in 3 steps

ngrok is a globally distributed reverse proxy fronting your web services running in any cloud or private network , or your machine .     In easy steps install ngrok on linux machine, download ngrok using below command: wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz  unzip this using below command: unzip  ngrok-v3-stable-linux-amd64.tgz  run ngrok as below: ./ngrok http 5000 enjoy.

Pine script for Intraday backtesting Previous Day high and Previous Day Low Breakout strategy

In this article, I will try to explain the backtesting of range breakout strategy using Pine Script.   Intraday range breakout strategy is a well known concept among trading community. We will test previous day range breakout, as soon as underlying script crosses previous day high we will initate buy and opposite conditions for sell (if script goes below previous day low, we will sell it). We will keep fixed stop loss which is configurable.   // © ObserveNifty //@version=4 strategy("Previous Day High and Low Breakout Strategy", overlay=true, calc_on_every_tick=true) D_High = security(syminfo.tickerid, 'D', high[1]) D_Low = security(syminfo.tickerid, 'D', low[1]) D_Close = security(syminfo.tickerid, 'D', close[1]) D_Open = security(syminfo.tickerid, 'D', open[1]) // Go Long - if prev day high is broken // Go Short - if prev day low is broken plot(timeframe.isintraday ? D_High : na, title="Daily High", style=plot.style_line, color=...

Pinescript Code for Hilega Milega

Image
  Strategy and image Credit: NK@StockTalk //@version=3 // © ObserveNifty study("Hilega Milega Strategy by @ObserveNifty", overlay=true) //length_RSI = input(9) priceRSI = close rsi = rsi(priceRSI, 9) wma_rsi = wma(rsi, 21) ema_rsi = ema(rsi, 3) vwap_close = vwap(close) // Deternine if we are currently LONG isLong = false isLong := nz(isLong[1], false) // Determine if we are currently SHORT isShort = false isShort := nz(isShort[1], false) // buytrigger = not isLong and crossover(vrsi14,50) and crossover(vrsi5,70) buytrigger = not isLong and wma_rsi < ema_rsi and wma_rsi > 50 and close > vwap_close plotshape(buytrigger, title="Buy Signal Generated", text="Buy", textcolor=white, style=shape.labeldown, location=location.abovebar, color=red, transp=0, size=size.tiny) buyExit = isLong and (wma_rsi > ema_rsi or wma_rsi <= 50 or close < vwap_close) plotshape(buyExit, title="Exit Buy", text="Exit Buy", textcolor=wh...

Heroku deploy web appliaction

 When deploying a python flask web application I got an error that at=error code=H14 desc=”No web processes running” method=GET path=”/” host=xxx.herokuapp.com request_id=xxx fwd=”xxx.xx.xx.x" dyno= connect= service= status=503 bytes= Solution: Check if you have Procfile in your project root folder and if present check if you have web: <command> present to start your application. The above solution solved my problem.

Sending message to Telegram Group, User or Bot using Python

In Programming world, most of the time while automating a system/tasks you need to send completion or timely notification about the status. Now a days the easiest way of notification is WhatsApp or Telegram as our SMS and email boxes are mostly flooded with spams. In this article we will try to explain about telegram automation using simple Python script. Install json and telegram package using pip package manager: pip install json pip install python-telegram-bot read token of your telegram bot and chat_id from json file telegram_credentials.json call notify_(message) function from the point in your script where you need to send notification and pass token and chat_id to it. import json import telegram def notify_(message): t_bot = telegram.Bot(token=token) t_bot.sendMessage(chat_id=chat_id, text=message) with open('./telegram_credentials.json', 'r') as keys_file: k = json.load(keys_file) token = k['telegram_token'] chat_id...

Golden Crossover with MA strategy

Most of the fundamental investors believe in Buy and Hold strategy, but I think most of the retail fundament investors doesn't know when to exit. Also in most cases they get trapped when there is a sudden deterioration in the fundaments. So, for such investors, I believe below is a very good strategy and may save from huge draw-down. This strategy is purely for long term or positional investors. It is combination of two different strategies which are famous among swing or positional traders namely golden crossover (50/200) and 200 moving average. Strategy:  Open stock on a daily time frame chart, draw moving average indicators for 50 and 200 on the chart, these MA indicators will draw 50 days and 200 days moving average of stock. Now for buying the stock you need to see below two conditions: Stock should trade above 200 moving average line. Shorter moving average line should be above longer duration moving average, that means 50 ma line should be above 200 ma line. Similarly f...

Read and print column names of Pandas dataframe

In your development and dealing with huge datasets you may need to read column names of data. Python has very powerful library called as pandas for data processing, pandas have very popular data structure named as Dataframe. There are many ways to get column names of dataframe in pandas library we below: import pandas as pd df = pd.DataFrame({'column1': [2, 4, 8, 0], 'column2': [6, 0, 0, 0], 'column3': [10, 2, 1, 8], 'column4': [14, 5, 32, 68]}) # print Dataframe print(df) # Column names as list print(list(df.columns)) # Column names print(df.columns.values) # iterating the columns for column in df.columns: print(column, end=' ') # using end argument to print all column values in single line. print() # Using toList() function print(df.columns.values.tolist()) Happy coding.