Skip to content

Instantly share code, notes, and snippets.

Avatar

Shivam Tiwari ShivamPsit

View GitHub Profile
@ShivamPsit
ShivamPsit / Relative_Strength
Last active Jul 20, 2020
Stock_Relative_Strength
View 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 Sep 6, 2019
Generator in Python
View generator.py
# 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 Sep 6, 2019
Exception_Handling_Python
View exception_handling.py
# 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)