Skip to content

Instantly share code, notes, and snippets.

View ShivamPsit's full-sized avatar

Shivam Tiwari ShivamPsit

View GitHub Profile
@ShivamPsit
ShivamPsit / Relative_Strength
Last active July 20, 2020 20:41
Stock_Relative_Strength
//@version=4
study("Relative Strength", shorttitle="RS",resolution = "")
comparativeTickerId = input("CNX500", type=input.symbol, title="Comparative Symbol")
comparativeSectorId = input("CNXIT", type=input.symbol, title="Sector Symbol")
lenght = input(50, type=input.integer, minval=1, title="Period")
showMA_1 = input(defval=true, type=input.bool, title="Nifty_RS_MA")
showMA_2 = input(defval=true, type=input.bool, title="Sector_RS_MA")
showres = input(defval=false, type=input.bool, title="Show RS")
showsecres = input(defval=false, type=input.bool, title="Show Sector RS")
lenghtMA_1 = input(5, type=input.integer, minval=1, title="Nifty_RS_MA")
@ShivamPsit
ShivamPsit / generator.py
Last active September 6, 2019 14:17
Generator in Python
# Generators don't hold entire result in the memory instead
# it yields one result at a time and
# takes less memory and time to execute
def cube_num(num):
for i in num:
yield(i)
# Create Generator by using Comprehension :
@ShivamPsit
ShivamPsit / exception_handling.py
Last active September 6, 2019 13:37
Exception_Handling_Python
# If line 4 throw error, line 5 will not execute
# and only it will throw
try:
f = open('file.txt') # If file didn't found this line will throw 'FileNotFoundError'
m = any_var # This line will throw 'NameError'
except FileNotFoundError as e:
print(e)
except NameError as e:
print(e)