can any one please help to create indicator name CPR with pivot level weekly in hourly chart. (only support 1&2 and resistance 1&2 value needed)
Please Help
@Tradehull_Imran
Hi @Shaurya_Kamdar ,
The timeframe 12
is not supported by dhan currently, Supported timeframes are :
- ‘1’ for 1-minute candles
- ‘5’ for 5-minute candles
- ‘15’ for 15-minute candles
- ‘25’ for 25-minute candles
- ‘60’ for 60-minute candles
- ‘DAY’ for daily candles
Refer the below code.
historical_data = tsl.get_historical_data('ACC', 'NSE', '1')
Hi @Qaisar ,
In this case itseems orderbook[script_name]['traded']
value remains to be None, Ensure orderbook
is initialized as a dictionary before accessing it.
if orderbook[script_name]['traded'] is not None:
if orderbook[script_name]['traded'] == "YES":
This code okay to start…
see below blog to explore volume profile in depth
Hi @saurabha213 ,
We have not written sell side as of now.
Hi @s_nandi ,
use below link to get weekly candles
and make similar code as below to get CPR
def calculate_levels(high, low, close):
range_hl = (high - low) * 1.1
R4 = range_hl / 2 + close
R3 = range_hl / 4 + close
R2 = range_hl / 6 + close
R1 = range_hl / 12 + close
S1 = close - range_hl / 12
S2 = close - range_hl / 6
S3 = close - range_hl / 4
S4 = close - range_hl / 2
return {
'R4': R4, 'R3': R3, 'R2': R2, 'R1': R1,
'S1': S1, 'S2': S2, 'S3': S3, 'S4': S4
}
Example usage
high = 150
low = 140
close = 145
levels = calculate_levels(high, low, close)
print(levels)
@Tradehull_Imran noted Imran Sir, thank you.
@Tradehull_Imran Hi Imran Sir, if you could jot down a few algo steps for selling basis of your expertise in the market and knowledge of the algo setup you taught us, it will be really helpful. e.g. something similar to the steps you had jotted during creation of the Mini RoboCop script, it was really helpful. I can then try to convert these into .py code at my end. Thanks!
import sqn_lib
*** ModuleNotFoundError: No module named ‘sqn_lib’
session 2 installation is not safe for download due to malware so can i install in my pc
The error message ModuleNotFoundError: No module named ‘sqn_lib’ indicates that Python cannot find a module named sqn_lib.
Here are some steps you can take to resolve this issue:
Install the Module: If sqn_lib is a third-party library.
pip install sqn_lib
@Tradehull_Imran @RahulDeshpande
Is there any issue today?
I am not able to fetch any data from Dhan API.
example code
import pdb
import time
import datetime
import traceback
from Dhan_Tradehull_V2 import Tradehull
import pandas as pd
from pprint import pprint
import talib
---------------for dhan login ----------------
client_code = “1102773623”
token_id = “code”
tsl = Tradehull(client_code,token_id)
ltp2 = tsl.get_ltp_data(names=“ACC”)
ltp3 = tsl.get_ltp_data(names=“NIFTY”)
pdb.set_trace()
error:
(Pdb) ltp2
{}
(Pdb) ltp3
{}
yes, there is a problem getting LTP data for scripts
This could be because of market closed on weekend.
Your code looks correct to me.
Try to check it when market is open.
sqn_lib is not a Python library; it’s a file provided by Imran Ali. Copy these codes and save a.py file at the same location as your main code, then import sqn.
# -------------------------------------------------------------------------------------------
# sqn_lib Function
# -------------------------------------------------------------------------------------------
def market_type(num):
if num > 1.47:
return "very_bullish"
if 0.75 < num < 1.46:
return "bullish"
if 0 < num < 0.74:
return "neutral"
if -0.7 < num < 0:
return "bearish"
if num <= -0.7:
return "very_bearish"
def sqn(df, period):
df['pnl_sqn'] = ((df['close'] - df['open']) / df['open'])*100
df['average_pnl'] = df['pnl_sqn'].rolling(period).mean()
df['average_std'] = df['pnl_sqn'].rolling(period).std()
name = 'sqn'
df[name] = (math.sqrt(period)*df['average_pnl'])/df['average_std']
df = df.drop(columns=['pnl_sqn', 'average_pnl', 'average_std'], inplace=True)
return df
script_LTP = tsl.get_ltp_data(names=script_name)[script_name]
*** KeyError: 'ABB'
for 2 days there is a problem getting LTP data for any script, no problem in historical data just the LTP data giving error