Code your Technical Analysis strategy
Traders,
This is where we will be getting help from our programmers to code your technical analysis strategy. It could be as simple as moving average crossovers to anything intermediate. Mention your strategy, we will explain how to code it. Coding your technical analysis strategy is critical because only then will you be able to backtest it and take it live.
So go ahead and post you technical analysis strategy here, we will reply as soon as possible with the code and an explanation of the code itself. The idea behind doing this is that eventually as and when you see various examples on how to code strategies with an explanation, you will stop needing the help and become a strategy coder on your own.
Time to Write, Backtest and Go live on trading the smart way.
Disclaimer:
The formulas or codes that we are helping you write is our view on your query. Zerodha is not liable for the correctness of it or for any trades that you take based on it. algoZ/Nest Pulse is provided as a tool to help you trade better, make sure that you double check before taking any trade based on the signals being generated.
I want screener of those stocks of which price touches 200,50 Day EMA line & pattern finder also.
Regards,
Solanki Dhavalkumar K.
sir,
I need to access “ssl hybrid & QQE mod” indicator’ in zerodha. it is not shown in ChartIQ and as well as TradingView. pls help me
Add SSL hybrid indicator in zerodha app. immediately.
No need, if you want SSL hybrid add hull ma of 60, parabolic Sar and use MACD colums for conformation.
i have the source code how to apply and automate the trade in Zerodha?
sir,
I need to access “ssl hybrid indicator’ in zerodha. it is not shown in ChartIQ and as well as TradingView. pls help me
How do I get the current price of VWAP (the price of y axis share) and Moving Average and the current price of the stock
on 5 min chart
candle close price >vwap
supertrend buy signal
volume > 2x (20days SMA volume)
rsi > 60
OI < (20 days SMA OI)
I want coding for
ENTRY: 12 EMA Crosses 26 EMA
EXIT: 26 EMA Crosses 12 EMA in 5 Minute Chart.
I am fully confused with Streak how to create my strategy. Please help me
Bro, try 8 & 20 EMA Cross and use trendline bakeout for confirmation
If you want 12 & 24 ema entry and exit strategy same here use trendline bakeout and if you don’t know how to draw trendline use Super Trend of 10,2 OR 3,2
Bro before using these strategies plz back test it
1. the code should be able to run on pre defined watch list, or on available ATM or ATM-1, (cmp*lot size sma(RSI 14,10) and rsi around 30-40.
3 exit SLM peak-10%, updated every minute.
Sir , I want code for
Long based on following conditions.
1.bullish engulfing or morning star pattern.
2.super trend should be in uptrend.
Shorting based on following conditions:
1. Bearish engulfing or evening star.
2. Supertrend should be in downtrend
I want codes for both 15min and 5min time frame
Thanks you 😊
what did you tried?
SIR I NEED CODE FOR MY STRATIGIES
2 MOVING AVERAGE CONCEPT
20 MOVING AVERAGE AND 200 MOVING AVERAGE
BUY SCRIPT
20 MOVING AVERAGE CROSS ABOVE 200 MOVING AVERAGE
SELL SCRIPT
200 MOVING AVERAGE CROSS BELOW 20 MOVING AVERAGE
..
.
.
Can you tell me the conditions required for making high fractals and low fractals in William alligator indicator and what type of moving averages we should use to make the alligator?
need pi script for if:
my condition met and I buy at that price P, now I want to fix my SL at P-10 and target at P+20…??
or
I want to place my SL at 5% and TGT at 10%.
please create pi code for it.
Hi, Can we code in order to filter options and get alerts based on RSI? For example, I would like to get the list of ATM options based on
1. RSI crossing a Threshold for the ATM option
2. RSI crossing a threshold for the corresponding stock future.
Thanks,
Buy shares or option when the RSI goes above 60 and sell when the RSI downtrends..
i want to generate buy signal for nifty futures when RSI crosses 40 from below on 15 min charts. and sell signal when rsi crosses 60 from above.
thank you
Hey Rupali, I suggest you check out Streak.
Hello,
I am on day 1 of using trade script, and was wondering if you can help me with something I am stuck on:
The query primarily uses BB (plus ADX RSI), and tries to identify buy point using BBM and sell point using BBT. I do have a flaw with the code where it can trigger losses for events such as what we saw in March.
I think having a global variable which I can set in my Buy script and use it in Sell script can get rid of the problem.
Is it possible to set Global variables for this? or can I use my holding avg price as ref point in my sell script.
Something like this
Buy Script
SET Bottom = BBB(CLOSE, 20, 1, EXPONENTIAL)
SET Top = BBT(CLOSE, 20, 1, EXPONENTIAL)
SET Mid = BBM(CLOSE, 20, 1, EXPONENTIAL)
SET GLOBALVARIABLE = BBT(CLOSE, 20, 2, EXPONENTIAL) #this is my Global variable I want to use in Sell Script.
REF(LOW, 1) Mid
AND ADX(20) > 20
AND DIP(20) > DIN(20)
AND RSI(CLOSE, 20) > 40
Sell
SET Top14 = BBT(CLOSE, 14, 2, EXPONENTIAL)
SET Top = BBT(CLOSE, 20, 2, EXPONENTIAL)
Top14 > Top
GLOBALVARIABLE < Top #Global Variable set in Buy script OR
AVGHOLDINGPRICE = REF(Top, 1)
AND CLOSE 20
AND DIP(20) > DIN(20)
AND RSI(CLOSE, 20) > 40
Its my great pleasure that I’m writing you..
sir I want a spript that can able to place stopploss and target at specific price level..
eg: we scripted a strategy and according that if our buy order executed at 1000 and we want exit at 1050 ( wherever it will go beyond doesn’t matter).
01. I want to place my exit order at specific point after execution.
02. is threre any script which will work like BO order (Trailing SL)
example code in python when candle(close) crosses 20 SMA moving average
Dear Sir,
Can you please help me to pine coding the following strategies?
Multi Time Frame
Long:
SMA Crosses 9 & 21
Candle close above 50 EMA
RSI Divergence 0 – 30
RSI below 50
Candle close above Super Trend
Can you add support or pivot?
Short:
SMA Crosses 9 & 21
Candle close below 50 EMA
RSI Divergence 70 – 100
RSI above 50
Candle close below Super Trend
Can you add resistant or pivot?
many thanks for your help
Best post this here. A fellow forum member may be able to help.
Sir i want to sell on high of 15 min candle once 14 period RSI crosses over 70 with TSL of past 3rd 15 min candle high or 20 SMA… please guide
Sir i want to sell over 70 , RSI 14, with TSL of past 3rd 15 min candle high… please guide
Hi matti
Is it possible to perform the below mentioned strategy & can it be coded if yes, then can we use KITE API or Streak to perform the same strategy?
Need a code for the following action:
For any particular EQ script entered by the user is it possible that the system everyday should automatically place an buy or sell order for one qty or any numbers of qtys entered by the user for which it should place an buy or sell order at 10.16 AM everyday on that day’s trading session at one rupee less/more or any number of rupees entered by the user below the LOW price or (any OHLC) which was at 10.15 AM on that day’s trading session.
Please revert ASAP.
i want a supertrend + macd + rsi
Searches related to GfxTextOut( (“Current P/L : ” + WriteVal(IIf(sig == “BUY”,(C-entry),(entry-C)),2.2)), 13, y-20);; this afl what is wrong and how to repair
Please can you write a code for an alert on the crossing of sma 20 and 50.
And an alert for the crossing of the fast and slow lines of MACD . The parameters are, 12, 26, 1 and 5, 15, 1.
Best post your query here. A fellow form member may be able to help.
I need the code for,
Ehler Fisher (10) crosses Ehler Fisher Trigger (10), on a monthly time frame
Best post your query here. A fellow forum member may be able to help.
Hi Nitin,
I looking for a strategy to backtest. It is basically for Index.
We have to see the 5 mins candle for 30 Mins i.e 6 Candles and will mark high point and low pint in this 30 min. If the Next 5 min candle closes above the high mark then will buy and if the candle closes below the low point will sell the candle.
I suggest you check out Streak.
Hi Team,
I am trying to use stocastics oscillator for the scanner in pi but it is generating error on below code
SOPK(4,1,1, SIMPLE) > 80
Please suggest
Hi team,
Need a code for the following action:
Buy – When RSI crosses above 20 and square off when RSI crosses below 80
Sell – When RSI crosses below 80 and square off when RSI crosses above 20
Dear Sir,
I need Kligner Vol Oscillator script for zerodha backtest
please help
Prafulla Bhople
Best post your query here. A fellow forum member may be able to help.
Hai…
I done Script for SMA cross over…for Buy and Sell Signal. But i have to set Buy Target (0.3% from SMA Crossover Candle High Price) and Buy Stoploss (SMA Crossover Candle Low Price) and simillarly for Sell side….Is it possible…?
Hi, best post this query here. A fellow forum member may be able to help. Also, have you checked out Streak? You can create and manage your strategies a lot more easily.
Dear,
I want to backtest Nifty 50 Stocks,
for that i need your help in coding for First 15 minutes Candle’s high low breakout (e.i 9:15AM to 9:30 AM),
Please help me .
Can I use scanner for more than 1 line conditions?
Hi
Could you help me for below strategy coding
1.Latest Low Greater than 1 day ago Low
2. Latest Close Greater than 1 day ago Close
3. Latest Parabolic Sar(0.02,0.02,0.2) Less than Latest Close
4. 1 day ago Parabolic Sar(0.02,0.02,0.2)Greater than 1 day ago Close
I tried below code but, not getting proper results
OPEN > REF(LOW,1) and CLOSE> REF(CLOSE,1) AND
PSAR( 0.02,0.2) REF(CLOSE,1)
Thanks in advance
Best post your query here. A fellow forum member may be able to help.
Hi can you please provide AFL code for Ehler fisher + tigger working in Kite with Henkin anshi candle.
it will be great help.
Kind regards
Shikher
Hi Anyone?
How to code offset moving average?
i want coding for ichimoku trading system i use buy when candle breaks the cloud and tekansen and kijun sen cross ,future cloud should green in colour, lagging span should far away from cloud and price action. when these conditions met i will open my buy position in 15 min chart and exat the same opposite to sell side can you code this strategy.
Best post this here. A fellow forum member may be able to help.
HI
FOR BUYING RSI NEED TO BE MORE THEN 65 AND VOLUME MORE THEN 1000000(IN DAY)
FOR SELLING RSI NEED TO BE LESS THEN 35 AND VOLUME MORE THAN 1000000(IN DAY)
HOW TO BACK TEST THIS IN PI.
TIME FRAME–15 MINUTE CHART.
KINDLY PROVIDE CODE FOR BACK TESTING?
I have a .ex4 and .tpl file, this code is developed by one of my friend which I want to use in kite or PI. Please let me know how to do this.
Thanks in advance.
Could you provide code for hammer and inverted hammer candlestick?
Hey Shubham, best post your query here. A fellow forum member may be able to help.
Dear Sir/madam,
i am seeking and requesting a algos code for PI Zerodha Live Scanner regarding. in this cbelow conditions i requesting codes plz.
1. MACD signal crossesbelow from the macd diveg. ( basically buy call generates)
addition to
2. Intraday MTM 20-25in btwn range trending (basically oversold)
addition to
3. EMA 9 crossesabove 26 EMA for Intraday.
all above should be on 5 minutes candle chart requirents. 1st signal candle need to generate buy signal. 2nd candle Low has to be Buy order generates required.
Kindly do support to better experince thru PI zerodha!
Awaiting you support.
thnx by
Sulthan.IS
8248999618
9566933666
Hey Sulthan,
We recommend that you go through this user manual on Tradescript in order to be able to build your own back-tests and expert advisors as per your needs and requirements.
Hi! Sir, If i have to make strategy based on cande vidya crossover on Nifty can i make ?
how to transfer amount equity to commodity accounts
Hi,
The strategy is “Bollinger bands squeeze” you might have heard made by john Bollinger it uses indicator such as Bollinger bands width ,Bollinger %b and volume.
OBJECTIVES:
STEP ONE – IDENTIFY THE SQUEEZE
the entry criteria for this is Bollinger bands should squeeze you can identify the squeeze from indicator Bollinger bands width you might have to alter it a bit to identify the squeeze (on timetotrade web based platform they had a indicator name “minimum in range” and they combined it with bollinger bands width thats how they identified the squeeze )
STEP TWO – THE BREAK OF THE UPPER BANDS
The break of the upper bands could be seen in bollinger bands %b
STEP THREE – HIGHER VOLUME THEN PREVIOUS BARS EITHER ON THE BREAK OF THE UPPER/LOWER BAND OR IMMEDIATELY FOLLOWING THE BARS OF THE BREAK
The volume should be highest of the session or at least should be highest from previous few bars and above average in general in any given time frame this should be either on the break of the upper/lower band or immediately following the upper/lower bands breaks in 2 to 3 bars
THE EXIT WILL BE THE BREAK OF LOWER/UPPER BANDS AFTER THE SETUP ENTRY OR PARABOLIC SAR EXIT STRATEGY
Please let me know as soon as possible if it can be done on tradescript
thanks
Hey Rajveer. Best post this here. A fellow forum member may be able to help.
i would like to backtest vwap in bank nifty for 15 min chart so pls code me in this testing
how sell of 1% above the purchase value can be scripted please help me for this
Manish, have you checked out Streak? More information on it here
Hi Team,
I am looking forward to get the codes for McGinley Dynamic.
Regards
Hrishikesh
In need below strategy code.
If green candle’s high is greater and low is smaller than previous red candle then buy at high price of the same candle
If red candle’s high is greater and low is smaller that previous green candle the sell at low price of the same candle
Hey Ketan, best post your query here. A fellow forum member may be able to help out.
Hi,
I am new to programming, it would be great if you give me a code for the below strategy, also please let me know where do i need to execute the code in PI.
Whenever a buy/sell signal is given by a supertrend over the 5 min candle, there will be a target T1,T2 & T3, once it reaches to the T3 i should sell incase if it’s in buy signal mode and vice versa.
once the order is executed, the target should be automatically set it to the sell stoploss incase if it’s in buy mode, should set it to the buy stop loss incase if it’s in a sell mode.
please note that the stoploss would be changing frequently as the market goes on.
i need this code to be automatically check the conditions for at least 7 scripts.
Alert when 5 period EMA crosses 20 period EMA and Supertrend is on uptrend and vice a versa for sell order.
Scan 14 periods RSI on 15 minute time period chart for 1 day. Select only those stocks where RSI is stuck between 70 and 30.
Hey Nishith, I suggest you check out Streak for this.
HI,
Need a code for “scanner” to enlist me the stocks from nifty50 that have been in a range for last fifteen 1 min candles.
Alok
Hey Alok, best post your query here. A fellow forum member may be able to help.
Hi, I need a code for the following:
Buy signal Shall be generated when:
-on a 30 min chart bullish engulfing pattern is formed & RSI is below 35 (on closing basis of red candle) & volume of green candle is above simple moving average of last 30 days.
Sell singal shall be generated when:
– on a 30 mins chart bearish engulfing pattern in formed & RSI is above 65 (on closing basis of Green candle) & Volume of red candle is above simple moving average of last 30 days
Thanks in advance
Hi ,
I need a coding with combination of supertrend and SMA. can some help me please?
You are given 1 minute data of 5 stocks. There are 6 columns in each file, and each column represents this:
Column 1: Date and time
Column 2: “Open” for that particular minute
Column 3: “High” for that particular minute
Column 4: “Low” for that particular minute
Column 5: “Close” for that particular minute
Column 6: Traded volume for that particular minute
The aim of the backtest is to find the stock which gives the best result based on a trading algorithm. The data is from 22nd Feb, but you can assume the trades will begin from 23rd Feb. The algorithm is as follows:
At 9:20 am, EMA 50 should be less than VWAP
To enter a trade: EMA 50 should become greater than VWAP
The entry price is the “close” of the particular minute where EMA 50 crosses VWAP (as in point 2)
Do not enter a trade after 1:30 pm. If the conditions are not met, there can be no trades for that day
Hold the position as long as EMA 50 is greater than VWAP
To exit a trade: EMA 50 should again cross VWAP. Thus EMA 50 < VWAP. Similarly the exit price will the the "close" of that particular minute
If the condition in point 4 does not occur during the day, exit the trade at 3:15 pm. We do not carry any trades on to next day
The best stock would be the one, where the sum of profit/ loss of all trades is maximum
Is it possible to give supertrend indicator with fields Open/High/Low/Close etc?
Hi,
I have raised a doubt in the forum as informed by support desk in the month of June,2018. So far no response.
The issue about using supertrend in the charting and for coding. Can the support team update on this?
Thank you,
Raju
I want a code when price is above 100 sma. stochastics is below 20, macd positive cross over and macd line above zero
And vice versa for selling
please help me with the code
Can someone help in making this script?
On Heikin Ashi chart:-
Buy script:- 1/2 green Heikin Ashi candle + StochRSI = 0.75
Thanks in advance. Or if there is any material on how the code scripts are made, it would be wonderful as I can try to build it myself from the code library.
Hi Paras, best post your question here. A fellow forum member may be able to help.
sir,
i have written algo script which works well and yield good result same as my trading plan when back testing but when i use same script in scanner in order to get signal during trading hours it shows “your script generated error.”
here is my script:
“EMA(CLOSE,200) >EMA(EMA(CLOSE,200),50) AND
CROSSOVER(SOPK(12,7,7,WEIGHTED) , SOPD(12,7,7,WEIGHTED) AND
SOPK(12,7,7,WEIGHTED)< 30 AND
SOPD(12,7,7,WEIGHTED)<30
what should i do to resolve this problem?
thasks regards
Best get in touch with our support desk, Hilesh.
Sir,
i required donchian channel buy/sell code , buy msg show if crosses above 20 channels & sell if crosses below channel , will help please..
Hello Sir,
I like to build a code in Zerodha PI where it auto detects the supertrend signal on 1 minute candle if it is buy (green) or it is sell (red). Now if buy signal is generated I like to put a buy order and wait for next sell signal and as soon as sell signal is generated I like to put a sell order with the double the quantity I buy. for example if super trend signal is buy then purchase buy order of 100 then now when supertrend show the sell signal then sell 200 quantity now wait for next buy signal then buy 200 quantity like this.
Important note is I like to specify the script/commodity for which I like to run this code.
Looking for your positive reply.
Thanks & Regards,
Kamal Bhola
Hi sir,
please help me tried to doing code but it’s not working, below is my requirement.
For buy
I have set my RSI indicator to Periods 14, OB 70 and OS 30, I need if my RSI go higher than the last candle position(RSI) and in my candle chart, last candle goes down to previous last candle and last 10 candles is showing down trends, then buy signal generate.
For Sell
Same opposite to buy signal,
If RSI goes down and then the last candle and last candle goes up comparing to previous last candle and last 10 candles is showing up trend the sell signal generates.
I want following 2 types of alert
1. When last traded price is near(5-to 6 points below) to yesterdays high of hourly candle begining from 14.15 minutes. and
2When last traded price is near (5 to 6 points above) to yesterdays low of hourly candle begining from 14.15 minutes.
How PI scanner generate alert…only color highlighting?
or SOUND/ MAIL/ SMS ?
Hi, did you stop Pi Backtesting facility??
It’s continuously giving error.
Is it like, now backtesting should be done only on streak??
No Maddy, Pi will remain available to users.
Hi,
My Strategy: Buy Signal – Closing Price > SMA(200), RSI(2) coming from 11 (RSI2 value less than 11,waiting for it to be more than 11)
Entry – As per Pivot Point Calculator.
Trailing SL – Initial SL will be Entry Price – 3*ATR(22). For every single point move in higher direction SL will move twice. For Example. Entry Price – Rs.100, High – 110, ATR(22) – 10. So initial SL – 100 – 30 = 70. Now if the new high is 120 which is a movement of 10 points, SL will 70 + 20 = 90. Once SL exceeds high it will automatically exit at that price.
Sell Signal – Just a opposite with RSI (2) value will be 89.
Please suggest whether backtesting is possible or not.
Regards,
Anit Bose
Hey Anit. You should check out Streak. Coding and backtesting your strategy has been made very easy.
Hi Sir,
Required Script to trade in 5 mint chart at Twiggs money flow TODAY HIGH and Trade volume index TODAY HIGH.
Please do the greatfull sir.
Regards
Praveen.S
Hi,
Is it possible to have the mid-value i.e., {[(high – low)/2] + low} of the available time frames in Pi be represented as a horizontal line such that a bar is simply represented as a cross with only the high, low and mid value being displayed discarding the open and the close completely.
I want to get alerted whenever volume becomes twice the simple average volume of last 50 candles.
I want test a strategy.
EMA5 to EMA26 positive crossover – Go Long
Exit long if last close is below 15% of buy price
EMA5 to EMA26 negative crossover – Go Short
Exit short if last close is above 15% of buy price
Based on above can I take position in options?
Regards,
Ganesh
No response?
HI
HOW TO BACKTEST IN PI USING SUPER TREND STRATEGY?
You’ll have to figure out how Super Trend works and then write the script for it yourself. I suggest you check out this category on TradingQ&A.
Could you give a Code for AI where the logic is as follows;
Buy when CCI positive and PSAR is upward
STCH MTM Cross Over Supertrend
Hi,
I would like to code the following strategy.
If a stock closes up 20% compared to previous close than buy at close and exit at 50% profit or 10%loss.
Thank you.
You should check out Streak.tech. This can be done quite easily on the Streak platform.
Hi,
I would like to find out the high and low of first 30 mins, if the price crosses high then generate buy and if it crosses low generate sell.
Also exit should be some particular % of my entry price.
Can anyone help me to get the this for this?
Thank you.
I wish to buy one lot of future at a particular price say X. I want to remain long until the price rolls back by 0.50 paisa at any particular time. But want it to be bought again when it starts going up by .50 paisa again. Similarly when it goes down by .50 paisa I want it to be sold. What should be the coding for this in Buy Script, Sell script, Exit long script and Exit short script. My humble request to respond please. I am new to this auto trading.
Regards
Pl help me in back test my following Strategy for intra day futures trading:
Chart Setting:3 Minutes
Studies:
1)VWAP
2)Time series forecast(period-14,Field-Close)
Strategy1:To go long
Buy when Two Green candle sticks Start & finish in succession above the Vwap line
Exit Long Position
Exit when two Red candles finish within Time Series forecast line Downward Cusp in succession.
Strategy2:To go Short
Sell when Two Red candle sticks Start & finish in succession below the Vwap line
Exit Short Position
Exit when two Green candles finish within Time Series forecast line Upward Cusp in succession.
Amit, it’s best you post your queries here. A fellow forum member may be able to help.
I want the Opening Range Breakout ( 15 minutes) Expert Advisor ,so kindly help in this.
Best post your query here.
I am using 15 min bar for banknifty
Buy
CROSSOVER(EMA((high+Low)/2,75),EMA((high+Low)/2,200))
Exit Long
CROSSOVER(EMA((high+Low)/2,75),EMA((high+Low)/2,50))
Sell
CROSSOVER(EMA((high+Low)/2,200),EMA((high+Low)/2,75))
Exit short
CROSSOVER(EMA((high+Low)/2,50),EMA((high+Low)/2,75))
In back test no of trades are showing low
but in chart i can see the trades
Can you please help me
Best post this query here.
Hi,
My Strategy based on MACD & RSI value on 10 minutes candlestick chart.
MACD – 13,26,10
RSI – 28 period Over Bought = 70 Over Sold = 30
BUY Rules
(30 mins after market opens)
Whenever RSI value is above 65 & MACD black line crosses red line from bottom to top & Exit whenever RSI value goes below 65.10
SELL Rules
(30 mins after market opens)
Whenever RSI value is below 35 & MACD red line crosses black line from bottom to top & Exit whenever RSI value goes above 34.90
Best post your query here.
I want to create a code to meet following condition;
When the Moving average crosses over, based on candle indicator either buy or short. Once executed exit long with +10 points and stop loss -10 points.
Can this be done?
Best post this query here. A fellow forum member may be able to help you out.
Hi nithin,
I’m new to zerodha. Can you please provide me the tradescript for the below mentioned strategy:
BUY:
1) MACD ( Macd line crossing above the signal line ( 30, 15, 9))
2) RSI ( RSI 14 increasing and above 30 )
3) CCI ( CCI 31 crossing above 0 line )
SELL:
1) MACD ( Macd line crossing the below signal line ( 30, 15, 9))
2) RSI ( RSI 14 idecreasing )
3) CCI ( CCI 31 crossing below 0 line )
You can post your query here: https://tradingqna.com/c/algos-strategies-code Krishna. A fellow forum member would be able to help.
hi friends i need pie scanner script for below conditions
help me please .thanks in advance
buy when
rsi(14) crossed above 65
macd line(12,26,9) crossed above macd signal line (12,26,9)
fast stochastic (14) crossed above slow stochastic(14)
william %R(14) crossed above -30
Best post this query here: https://tradingqna.com/c/algos-strategies-code
I want to do this strategy, can you give me code of this strategy
Hybrid Strategy
Buy one lot of ESCORTS DEC 740 CE at 23
Sell one lot of ESCORTS DEC 800 CE @ 8
Mehul, best post this here: https://tradingqna.com/c/algos-strategies-code
Please code the following strategy
Time Frame 15min
BUY: If 3 candles make higher high and RSI > 50
Exit at 3.15pm or for 20 points
SELL : If 3 candles make lower low and RSI <50
EXIT at 3.15pm or 20 points.
Thank you 🙂
Best post your requirement here: https://tradingqna.com/c/algos-strategies-code
Sir i have Already posted my query on your given link , but its been 14 days and i got no replies can your team plz look into it and reply me , thanks
what if i want first 15 minute high and first 15 minute low ?? I would want a pi code for the same.please help
Hi Nithin,
How to write code for this.
When RSI 14 crosses EMA 13.. BUY only if RSI is less than 25 and cross
Vice versa for SELL.
EMA 13 should cross RSI 14 and it should be above 65
Zerodha,
I am interested in learning automating the buying and selling in Pi. I have two questions. Can you kindly answer them ?
1. I am familiar with programming but I needed a little handholding on executing simple buy/sell scripts. I had a look at tradescript.pdf but it doesn’t seem to have examples and instructions on how to use Pi to automate. Can you please point me to any tutorial ? Just for example, if I want to sell Infosys when it touches Rs.1000, how do I do it ?
2. Can I automate Pi to buy or sell based on the values of two or more stocks ? (e.g: If the difference between future and spot is > 50, sell future and buy spot)
Hi,
want code for Pi:
Buy: when SuperTrend + Heiken ashi = both are bullish (green)
Sell: when SupreTrend + HeiKen ashi = both are bearish (red)
Kalpesh, it is not possible to code Supertrend using tradescript.
Need a code for stochastic going above 80 & below 20 with the settings of %K period 28, %K slowing 3, %D period 3, MA type exponential. If possible separate codes for going above & going below 80 & 20 respectively.
Hi All,
I new to zerodha API,
Can any body give the code for the below cover order logic.
If today open price is more than the yesterday close, then SELL with trigger price (+10 point of today open price)
else today open price is lesser than the yesterday close, then BUY with trigger price (-10 point of today open price).
and this below code should be execute first minute of the market opens.
Eg:
If
Prev Close [100] Open Price [110] = SELL
Else
Prev Close [100] Open Price [90] = BUY
I have written code by seeing some web pages but missing in trigger price.
Code:
kite.order_place(tradingsymbol=‘RELIANCE’, exchange=‘NSE’, quantity=1, trigger_price=900, variety=‘CO’, transaction_type=‘BUY’, order_type=‘MARKET’, product=‘MIS’, validity=‘DAY’)
Venkat, you can post this here.
Dear sir,
I am Yashpal here I am new to algo trading I want a code for my strategy please help me
My strategy is
I want to buy or sell crude oil of current month expiry when DEMA 30, 60 crossover on four hourly chart or vice versa this is my trend I always want to stay in this trend
My stoploss is on 15 minute chart of next month expiry crude oil when DEMA 30,60 crossover and vice versa I want to hedge my position when 15 minute chart goes opposite
Sir it’s very difficult to do manual trading whole day please help me or tell me someone who can help me to write this code
Yashpal, you can post this query here.
Sir I have tried but I am not able to submit my query please help me
While back testing, I want to know in Sell script at what price last buy took place so if I am making profit I would like to sell off else I would like to keep stocks on hold.
Also in buy script I want to know if stocks are already on hold, if on hold I don’t want to buy additional. If not on hold then I would like to buy.
I want to execute above strategy when some indicator that could be MACD, Moving average crossover or whatever produces buy and sell signal.
How I would do this in back testing?
Sandeep, you cannot code such complex strategies on Tradescript.
if i want to use small case only basic version for using screeners and not a pro version which is paid why do i need to give permission for accessing my holdings or placing orders etc
Yash, these are primarily for buying smallcases. we can only access your Zerodha account when you’re logged in to check if you have sufficient funds to buy a portfolio/smallcase of stocks created from screener & we only place orders on your behalf when you give manual approval for the same. No worries here!
I want to get the ratio between Total Buyers Quantity and Total Sellers Quantity which has above 1:5 in Nifty50 stocks. Please let me know the formula for the same
Ratio (1:5) value should be a configurable .
Is there any way to get end of day technical indicators data for NSE stocks into an excel sheet in zerodha applications(PI or KITE)?
Hey Ramesh,
You can apply the desired indicator to your chart on Pi, right click on the chart>Save Chart>Save chart data to Excel. This will export the OHLCV and indicator values for each candle to an excel sheet.
Hi. I like help in coding my Ichimoku Kinko Hyo strategy. This comes with 2 filters to protect immature trade signals.
Strategy: Use only the cloud ‘s crossing of Senkou span A and Senkou span B. The trade will be placed accordingly either Buy on Bullish or Sell on Bearish ,upon the crossing of the future cloud’s crossing. From Bullish to Bearish and vice versa.
The filters 1) Price crosses above Tenkan line for Buy and Price crosses Below Tenkan line for Sell.
2) ADX the position of the +DI and -DI line. 1) +DI line Above the -DI confirms the Price Above Tenkan line and Future Cloud Bullish crosses for a Buy trade. 2)-DI line Below the +DI will confirm the Price Below the Tenkan line and Future Cloud Bearish crosses for a Sell trade.
Note: There is a chance that the action of a New trade or Closing an Existing trade could also trigger a New Opposite trade based on this strategy.
Can you post it on tradingqna.com
hi zerodha team,
i want to generate an algo which gives me buy and sell signal using renko charts on my predefined workspace.
as we all know renko charts move on price action strategy and on predefined sizes of the block …so i want to buy or sell a script after a prevailing downtrend or uptrend i.e. red boxes/blocks or a green boxes/blocks is formed on any time frame as soon as one box/block is formed green in downtrend or one box/block is formed red in uptrend ..I want to execute my trade
i hope you have understand my query..
hope to hear from you soon
regards,
Vivek Tiwari
DV4166
Vivek, can you post this on algo section on tradingqna.
Hi Sir,
I have already posted the same in tradingqna under algo section.And I am waiting for reply ..hope to hear from them soon .
todays open greater than yesterdays high
todays open lesser than yesterdays low.
please code this for scanning the stocks @9.20 am
Ask these queries on tradingqna under coding category.
Hey, i want code which can automatically start buying or selling if its comes to my strategy
my strategy..
for all charts (scripts) in Commodity.
Only using super trend indicator.
Execution on 1 hour super trend but follow supertrend for 1 day.
if 1 hour create buy single and 1 day signal also buy then Buy
if 1 hour create sell signal and 1 day signal buy then not automation and should wait until it come to our logic.
if 1 hour create sell signal and 1 day signal also sell then surely sell.
if 1 hour create sell and 1 day buy then no trade and wait until it come to our logic.
Keep stoploss and trailing stoploss.
I can edit the numbers as of stoploss and trailing stoploss accordingly myself but i want this script anyhow for my bot
Please advice and get back to me..
thanks and regards
Do u have Gannhilo Studies indicator in zerodha
No, but you should check out the over 100 indicators on Kite, one of them must be close to the logic of this one.
Hi,
Can u pls give me a AFL code for ZERODHA ATR TRAILING STOP.
Ah we dont’ have AFL for any of the indicators.
Hello
My strategy for Nifty is based on the following.
Bollinger Band buy on the bottom band and sell >=10 points higher on NIFTY futures. This is for intraday and the Band is 20,2.
I also want an RSI of 20 or below for buy signal and 50 or above for sell signal.
Can you help with a trade script which I would like to back test and then go live. I am doing paper trading for past few weeks and find this successful.
Can you add this on tradingqna in the algos section.
Please help me to write code with my below simple strategy
1. I want to calculate high and low price of 2nd candle in 15 min chart.
2. after 2nd candle if it crosses high i will buy and if it cross low i will sell.
Thanks in Advance
Devendra Verma
Can you ask this on tradingqna.com under algos section.
please code the strategy given below
buy trigger-when 5 min nifty index bar break out of the last swing high
target-when 1 min nifty index bar break out the last swing low
stop loss-trailing with last swing low of 5 min nifty index bar
sell trigger-when 5 min nifty index bar break out of the last swing low
target-when 1 min nifty index bar break out of the last swing high
stop loss-trailing with last swing high of 5 min nifty index bar
please reply sir
Can I get list of stocks for which positive crossover between 5 EMA and 26 EMA occurs.
Also if possible same for 5 EMA and 13 EMA.
Positive crossover – When 5 EMA crosses 13/26 EMA from bottom.
This is available as code here:https://zerodha.com/expert-advisors/
I am looking to backtest a strategy as follows;
Three Supertrend indicators on Index
1. 11 – 2
2. 10 – 3
3. 7 – 3
Trades, go long on option for the Index above as follows
1. Sell CE when all three indicators turn Red; Square off when a candle touches one of the indicator above.
2. Sell PE when all three indicators turn Green; Square off when a candle touches one of the indicator above.
In general any good tutorials to learn backtest coding?
Thanks
Anuraag, not possible to scrip supertrend using Pi. I’d suggest you to start learning AFL or python, you can then backtest using these languages.
Thanks for your response Nithin. Could you tell me if you know a quickest way to learn AFL and how can us it to backtest a strategy? Thanks once again
AFL, there are many amibroker dedicated communities. I guess you can google for it.
Thanks. There is a school of thought that Python is preferred language for Algo trading, read backtesting. Even zerodha provides api and libraries to access data. I understand that Ambibroker platforms require license fee and would need a data source. What is your opinion on this?
If you have a programming background, definitely python, if not AFL is much more easier to get started.
sir
is there any alerts system or scanner to know the crossover of WMA&TMA crossover(daily/hourly).If its there plz tell me how to use it
You can check out scanner available on Pi for this.Check the playlist on Pi here, there are also other videos on this on youtube.
Hello sir,
Is there super trend scanner available in zerodha pi.
Manish, It is not possible to code Supertrend in Tradescript. If you are using Amibroker you can connect it to Pi and can use Super Trend Indicator AFL, or you can use Supertrend in KITE
Dear Sir,
In Zerodha PI, scanner is a very cool feature. I created two scanners for me adding about 100 stocks in each of them and then save them. But to my surprise , when I logged in again and open the list the saved scanner, the list got changed and one of my scanner was missing in the list and few others not created by me got added and this is happening again and again. Every time I logged in, the list of saved scanner got changed and I have to create the scanners again and adding stocks to them which is a very time consuming process.
Why my scanners and list of saved scanner changed randomly every time logged in though I saved them.
Can’t I saved my scanner permanently??
Hi The below link should help you saving a scanner.
check this
Dear Akshay,
I already followed all the steps given in the link. Unfortunately, it didn’t help.
Zerodha Team,
Pls help.
I think the the scanner saved by any user is visible globally to all the other users in the saved list of scanner and they can even delete it. Hence, every time I logged in, the list of scanner gets changed and even I can delete those saved scanners.
This might be the case, I guess.
Iam completely new to AFL programming
I would like to write code for signals indicating crossing of 5, 13, and 26 EMAs in “one point”. means all EMAs equal.
If the EMAs rise upward (all EMA more than confluence value) and MACD (16, 6, 4) positive (macd>0) then buy signal. if EMAs fall downward (all EMA less than confluence value) and MACD (16, 6, 4) negative (macd<0) then sell signal.
Thank you
Hi,
You can find the TradeScript user manual under the Help menu on Pi. If you have any queries on coding you can visit this section on TradingQnA.
Hi
Kindly help me to write trade script code for below mention strategy.
In 15 minutes chart
candle closing price is high from last four candle high then give signal for buy and opposite for sell.
Thanks
Ranjeet
I want a code for supertrend (7,1)setting on intraday 5 min chart. Buy when supertrend signals and sell when supertrend shows sell. Stopploss when supertrend changes either buy to sell or vice versa
You can post it here to get better response: https://tradingqna.com/c/algos-strategies-code
Hi Nithin,
I want to back test stocks using 5 min bars.
The strategy is if a stock’s 2:00 – 2:05 PM candle OPEN or CLOSE is with in the range of End of day ie; 3:25 to 3:30 PM candle, buy signal should be given.
Can you help me to code this in trade script.
Rgds,
Aljo
Can you ask all coding queries on tradignqna.com.
Hi Sir,
I want to make following trading system
When last price is greater then closed price by 0.5%. The script should get buy. And when the script moves further 0.3% above the buy price, the script should get exit, also stop loss will be below 0.3% of the buy price.
Can you post all coding queries on tradingqna.com
Hii
Is there any course or anything to learn the programming or how to make formulas as i dont have any knowledge about coding and all
thanks
Ah no, guess you can start learning any programming language. Suggest you to try Python.
Hi Nithin,
I am trading one system on intraday, 30 min chart, 1st candle will be 9:15to9:30 . on Spot Nifty.
only if there is gap between 3:30(Pre)(High or Low) and today’s 9:30 (Low or High) conditions will traded.
Condition Buy = if crosses 9:30 high SL low of 1st candle(9-9:30)
Sell = if Crosses 9:30 Low SL High of 1st candle(9-9:30)
up to 3 pm condition will execute trade and trade will be squared off at 3:25.
Dear Sir,
I wan to get a sound alert or a scanner for Renko charts when the color of candle is changed.
Please help me out.
dear nithin sir,
i am a breakout trader. i only trade when any strong resistance or any support break with strong volume. can you pl provide code for above condition in one hourly timeframe?
Can you ask this on tradingqna, you also need to have a condition for what is strong resistance or support.
Nithin Sir,
I am looking for Script code for Alligator Indicator. Price goes above & below Alligator Indicator with different time frames. if available please provide.
Thanks for all the support.
Thanks & Regards, Sudheer
have u found code for alligator?
I want to back test following strategy. How we can do it automatically?
On every positive crossover of 5 EMA & 26 EMA, I take call option of nearest strike price to spot price of near expiry the next day @ market open. Then I check every day at 3:15 if stop loss is trigger for the premium. SL triggered if premium drops below 25 %. If stop loss not triggered till expiry then I exit option @ 3:15 on expiry day.
On every negative crossover of 5 EMA & 26 EMA, I take put option of nearest strike price to spot price of near expiry the next day @ market open. Then I check every day at 3:15 if stop loss is trigger for the premium. SL triggered if premium drops below 25 %. If stop loss not triggered till expiry then I exit option @ 3:15 on expiry day.
I want to test this strategy for last 10 years for scripts Nifty, Banknifty, Reliance, LT & ICICIBANK.
Let me know if it is possible.
Ah this will not be possible using tradescript. Maybe you can use a professional charting platform like AMibroker or if you have programming language you can check the API docs on kite.trade
Hi,
i want a simple strategy of Heikin-Ashi (AND) SMA crossover(5,10)
Heikin-Ashi
BUY:
SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC > MAXOF(REF(HAC,1), REF(HAC,2), REF(HAC,3), REF(HAC,4)) AND SOPK(14, 7, 3, SIMPLE) > SOPD(14, 7, 3, SIMPLE)
SELL:
SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC < MINOF(REF(HAC,1), REF(HAC,2), REF(HAC,3), REF(HAC,4)) AND SOPK(14, 7, 3, SIMPLE) < SOPD(14, 7, 3, SIMPLE)
AND
SMA crossover(5,10)
BUY:CROSSOVER(SMA(CLOSE, 5), SMA(CLOSE, 10))
SELL:CROSSOVER(SMA(CLOSE, 10), SMA(CLOSE, 5))
can you please help me in coding both (Heiken-Ashi) AND (SMA crossover) in a single code
HA-SMA
BUY:
SELL:
Regards
Tanveer
Hi Tanveer,
Best post all coding related queries on Trading Q&A.
Hi want to code in Pi-
Buy : When 15 EMA Crosses Above 50 EMA (buy When crossover above 200 EMA)
only buy and cover position not new sell above 200 EMA
Sell : When 15 EMA Crosses Below 50 EMA (sell Crossover when it is below 200 EMA)
only sell and cover position not new buy below 200 SMA
can you please help me in coding, I am new and not getting any support form any where.
Regards
Manoj Kumar Pingolia
Hi want to code in Pi-
sell below 20 EMA when it is below 200 MA
only sell and cover possion not new buy
buy Above 20 EMA when it is above 200 MA
only buy and cover possion not new sell
can you please help me in coding
Regards
Manoj Kumar Pingolia
i wish to know if we can use expert advisor for option trading and if so i am not able to backtest the basic scripts plz advice as i am new to expert advisor
Yes expert advisors will work on option charts as well. Check this https://zerodha.com/expert-advisors/ and also this video.
Hii ,
i want buy and sell codes for supertrend crossover for 15 min and 5 min charts , parameters – default (7,3)
Nilesh, not possible to code supertrend using tradescript.
Hi
Need code for
Buy : When 15 SMA Crosses Above 50 SMA.
Sell : When 50 SMA Crosses Below 15 SMA.
Can you help me code my strategy:
Buy if open is low than previous day close
Target: buy_price + 1%
Stoploss: buy-price – .5%
Squareoff trade at the end of the day
Short sell if open is higher than previous day close
Target: buy_price – 1%
Stoploss: buy-price + .5%
Squareoff trade at the end of the day
The above trades should happen immediately as soon as NSE opens and for all 50 stocks of NIFTY50 index.
Zerodha is providing super trading platform and I love to use Zerodha. I would be very much delighted if you can share me the script for N4 or N7 strategy buy & sell script.
sir
piz help mi STR buy&sell coode
Can you please insert ZIg in Pi-terminal as you are having many indicators in built.This will help a lot.
with thanks
Mksinha
Can I have a code for
Buy : When 5 EMA Crosses Above 17 EMA. Exit after 1% Profit
Short Sell : When 17 EMA Crosses Below 5 EMA. Exit after 1% Profit
My Code is in amibroker
how can i set in pi with scan or filter
//////////////////////////////////////////////////////
periods = Param(“Periods”,15,1,200,1);
Ksmooth = Param(“%K avg”,3,1,200,1);
Dsmooth = Param(“%D avg”,3,1,200,1);
myStochD =StochD(periods,Ksmooth,DSmooth);
myStochK =StochK(periods,Ksmooth);
myRSI = RSI(15);
Filter = Cross(EMA(C,5),EMA(C,12)) AND C>=25 AND MACD() > Signal()AND Cross(myStochK, myStochD) AND V>100000;
AddColumn(O,”Open”,1.2);
AddColumn(H,”High”,1.2);
AddColumn(L,”Low”,1.2);
AddColumn(C,”Close”,1.2);
AddColumn(V,”Volume”,1);
AddColumn(EMA(C,5),”EMA-5″,1.2);
AddColumn(EMA(C,12),”EMA-12″,1.2);
AddColumn(myStochK,”Stochastic %K”,1.2);
AddColumn(myStochD,”Stochastic %D”,1.2);
AddColumn(myRSI,”RSI”,1.2);
//////////////////////////////////////
Can you post this on tradingqna
no
ok now i posting also Tradingqna
Dear Sir,
i need a trade script for super trend . kindly help
Post your query here: http://tradingqna.com/ask
Hi,
I would like to know whether my code is correct or not.
1. Buy if Close < Lower Bollinger AND RSI Upper Bollinger and RSI > 70 (two Consecutive Green candles)
Code:
Buy: CLOSE < BBB(CLOSE, 20, 2, EXPONENTIAL) AND RSI (CLOSE, 14) CLOSE
Sell: CLOSE > BBT(CLOSE, 20, 2, EXPONENTIAL) AND RSI (CLOSE, 14) > 70 AND Ref(CLOSE, 1)< CLOSE
Ask your coding related queries on tradingqna.com
Pls help me with the code of below strategy
when price is above 200 ema in daily and hourly chart, if price crosses 20 period ema shud generate buy signal at the close of candle above 20 ema, and when price is below 200 ema sell if candle closes below 20 period ema
also help me to generate AI for pin bar candle
Can you ask these on tradingqna.com
Hi greetings, Pls provide me code for following strategy
2 continous red bars of Heiken Ashi candle, first HA candle closes below EMA 14. Than the second HA candle crosses the low of first candle. Also EMA 14 must be pointing downwards all this while. Eagerly waiting Code Nithin sir
Can you search here: http://tradingqna.com/
Nithin sir
Posted whr u asked me to post but they replied can’t be made in zerodha. .kindly help me out for different strategy
Provide me code for this strategy pls. .
Strategy to be coded-
The candle crosses the previous high or low on the chart.
i.e the candle either moves above the previous high or breaks the previous low made, and the previous high, low than replaced by new high low made, in the algo n cycle keeps happening to give signal everytime a high or low is breached. .
Seriously need this one sir. .pls
Anshuman, all coding queries are handled by a team who are not on zconnect. Do post these on tradingqna, if it can be coded they will reply back.
Hi,
Can anyone please help me with the code script for the below strategy?
Indicators used are Bollinger Band (20,2), Stochastic (5,3,3)
Long Entry condition:
1. Price should have touched the Lower Bollinger Band and closed inside the band forming a Green candle.
2. The Stochastic should be in Oversold area (Below or around 20) and starting to move up
Short Entry condition:
1. Price should have touched the Upper Bollinger Band and closed inside the band forming a Red candle.
2. The Stochastic should be in Overbought area (Above or around 80) and starting to move down
Appreciate your help in this.
HI,
buy if rsi goes below 25 in one hour chart and sell if rsi goes above 65 in 15 mins chart(I ll sell only those what i purchased below 25 rsi)
please suggest me code
hi
i need the afl for difference between open and close …..
condition is that value will be in only +value ,
exm: in crude
open close differnce (C-O) I need AFL result (C-O)
day 1 3000 3075 75 75
day 2 2990 2935 -55 55
day 3 3100 3060 -40 40
day 4 3075 3013 -62 62
day 5 2900 3025 125 125
i will use that value for add in to my finding b/s value .
thanks in advance……
regards,
[email protected]
9865220178
Post here for better response: http://tradingqna.com/ask
Hi,
Can you please help me for expert adviser script for super trend.
Code for stock goes above R3
my strategy …..
will buy if price is greater than 20 ema?
please code this
CHeck this https://zerodha.com/expert-advisors/, it has this and more.
Hi,
I want to backtest the following strategy for intraday 5 min candle timeframe. please guide me how to go about it.
Buy: When close price is above 30 SMA
Close this buy trade when current price above 1% of the buy price.
Stop loss for buy trade is 30SMA
Sell: When close price is below 30 SMA.
Close this Sell trade when current price is below 1% of the sell price.
Stop loss for sell trade is 30SMA.
Thanks in advance.
Nilesh
Nilesh, ask all your coding related queries on tradingqna.com
Please code my strategy
If a red candle RSI is more than last candle RSI:Buy signal
If a green candle RSI is less than last candle RSI: Sell signal
Can you ask coding related queries on tradingqna.com
Hii SIr ,
new to trading in pi
What is simple code for buy if MACD indicatior crossover during intraday live chart.
Is this code will automatically buy or it will just give a signal to buy.
Please explain it.
Please code my strategy for backtesting
1. Buy at 9:30 if day open = day low
target = 0.75%
stoploss = 0.5%
2. Sell at 9:30 if day open = day high
target = 0.75%
stoploss = 0.5%
Thanks in advance
Can i test this code in backtest tool or i need your scripting language to test that code.if so can you please convert my code into your one’s i’will thankfull if it does.
study(“Supertrend V1.0 – Buy or Sell Signal”, overlay = true)
Factor=input(3, minval=1,maxval = 100)
Pd=input(7, minval=1,maxval = 100)
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1] TrendDown[1] ? 1: closeTsl , “Up Arrow”, shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)
//plot(Trend==1 and Trend[1]==-1,color = linecolor, style = circles, linewidth = 3,title="Trend")
plotarrow(Trend == 1 and Trend[1] == -1 ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(Trend == -1 and Trend[1] == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)
Looking for these charts, may be it is already there and just that I don’t know as I am a newbie.
1. End of day analysis of delivery. Need a bar chart with each bar representing a day volume with break-up showing the delivered quantity.
2. Trading hours line chart that shows the MIS volume, one line each for MIS buy and MIS sell.
3. Trading hours line chart that shows the CASH volume, one line each for CASH buy and CASH sell.
4. Trading hours chart that shows the total pending volume on y-axis and price on x-axis, one line for each BUY and SELL orders.
Hmm.. none of these are available, can’t think of any vendor who offers these as well.
Thanks for the quick response. Do you know how I access live data about the executed/pending orders? Is there any feed provided by Zerodha or the exchanges?
Thanks.
Shankar, all updates happen directly on the trading platform.
I want to SET BUY_PRICE and SELL_PRICE when the following two conditions met simultaneously
i) SET BUY_PRICE = IF(CLOSE > SMA(CLOSE,50)) – But error in the code
ii) SET SELL_PRICE = IF(CLOSE < SMA(CLOSE,50)) – May be this will also show error
What is the error in that code ? How to change it ?
Thanks in advance.
Ravi
Can you ask all coding related queries on tradingqna.com
Buy Script = SMA(CLOSE,200) > CMP
Sell Script = SMA(CLOSE, 200) < CMP
I cannot Back Test. It says "both Buy & Sell scripts should be there"
Can you please correct me if I am doing something wrong here?
Can you ask all coding queries http://tradingqna.com/algos-strategies-and-code
Sir,
Please tell me the code for SMA, EMA , WMA crossover SUPPORTED BY (IF POSSIBLE ) MACD 26,13,9
SMA 26 EMA 13 WMA 9
Check this: https://zerodha.com/expert-advisors/
There is always too much difference between “Paper Trading” and “Actual Trading” and that’s why most of the new trader loose their hard earned money.
So, we use Backtest.
BUT there are 2 issues with Backtesting.
1. It’s again like “Paper Trading” but on Automated Way.
2. Every Trader is not a Programmer, so he can’t backtest his strategy.
I just have a question. Can you not provide a “DEMO TRADING” on INDIAN LIVE MARKET (Stocks, Commodities and Currency) like “MT4 / MT5” Software provides us for FOREX so that a new trader could test his strategy on LIVE MARKET.
Although it would again be somehow like “Paper Trading” but it would be more closer to “Actual Trading” psychologically.
I don’t think, you can’t do it. Each trader that opens his account at zerodha, should have a DEMO TRADING ACCOUNT too, so that he could try his strategy without loosing his capital.
may i know the code forbuy and sell using supertrend indicator to be used in Expert Advice .
Supertrend is quite complicated to be coded on tradescript.
But it is possible right?
Possible I guess but you will have to figure this out.
Sir
I have studied all MACD realtef algos and applied but the problem is the the algos gives signals when macd is above signal line. Mostly irrelevant signals cause crossover and share price increase already happened .i need the exact moment when crossover is happening…i applied the macd crossover algo from tradescript but it is generating error.
Pls sir provide me MACD crossover algo.
HI,
CAN YOU CODE THE FOLLOWING STRATEGY FOR ME.
THIS IS THE ELLIOTT WAVE OSCILLATOR WHOSE VALUE IS DISPLAYED IN THE FORM OF A HISTOGRAM.
The Elliott Oscillator, or 5/35 Oscillator, is a 35 period simple moving average of prices subtracted from a 5 period simple moving average of prices displayed as a histogram above and below a zero line.
EWO (i) = SMA(close, 5) – SMA(close, 35)
THANKS
You’ll get better response if you post your coding related question here: http://tradingqna.com/algos-strategies-and-code
Hi Nithin I have developed a screener in Ambibriker using AFL programming language which gives filter the stick which are going to balst in 2 or 4 days it has given me 60 to 100% return I have backtested it and it works fine in any scenario. It took me 3 years to develop this algo after long struggle i was successful. I want to work as partner with you. We can discuss further and I can show you demo of my algo.
Please email me at tejas_desai007 at hotmail if interested.
hi,
Need help in making small change in the following simple breakout strategy:
Buy above previous candle high & sell vice versa, but signal should be generated as soon as high or low is broken by few points (say 2 points) not at the close of the candle.
Also once one buy signal is generated then another buy signal should not be generated before any sell signal vice versa for sell.
So what changes are necessary in following code?
Buy expression: Close>REF(Close,1)
Sell expression: Close<REF(Close,1)
Hi Nithin sir,
Please provide code for :
Green candle = Price closed above EMA 13
Red candle = Price closed below EMA 13
Also guide..how to use it in PI and Kite….
Can you ask this on http://tradingqna.com/algos-strategies-and-code
Hi,
I want to know out of Nifty 50 how many stocks went above from opening price and came back to opening price.
Same way how many stocks went below from opening price and came back to it.
Can we code something to get summary of these price movements.
Not on the expert advisor on the platform. But you can fetch data to excel and try doing this on excel.
Hello Nithin,
I want a code for
1. In downtrend : at bottom Doji/Hammer and next day open Gap up.
2. In up trend : at top Doji/Inverted Hammer and next day open Gap down.
Kindly send me on mail .
Ask all your coding related queries here: http://tradingqna.com/algos-strategies-and-code
Hi Nithin,
How to set Fibonacci setting in Pi.
Thanks,
Bharath
Fib retracement levels are preset on Pi. You can’t customize it. Check out charts on kite.zerodha.com, they have more options on Fib.
Hi,
I dont have any programming experience. So i need help here.
I want a code for
1. When the previous day candle is green and IF today’s candle is red
2. Today’s candle’s OPEN and CLOSE SHOULD be within the previous day OPEN and CLOSE.
3. Then SELL. BUY at a spread of ”today’s” and “yesterday’s” candles average range.
similarly if
1. previous candle is red and IF today’s candle is green
2. today’s candle’s OPEN and CLOSE should be within the previous day OPEN and CLOSE.
3. Then BUY. SELL at a spread of ”today’s” and “yesterday’s” candles average range.
can you post this on tradingqna.com
What is the script to find Average True Range? Like I want to write a script to find ATR for 100 candles.
Can you ask all coding queries on http://tradingqna.com/algos-strategies-and-code
Sir,
Pl suggest code for the following two scenarios.
1) MFI (money flow index) gives positive divergence and crosses 40
2) If bar opens below lower bollinger band and manages to close 1% above lower bollinger band
Thanking you,
Regards
NS
Can you post all coding queries on http://tradingqna.com/algos-strategies-and-code
sir what would be the code for 14 d rsi + 5 day sma for both going long and short.
Check for codes here: https://zerodha.com/expert-advisors/. Also any coding query can be posted on http://tradingqna.com/
I have three requests to make.
1) please add Supertrend indicator in Pi.
2) Please add Range bar chart for volatility.
3) please Add ADX/DMS indicator too…
please update all this in Pi….
We’ve passed on your requests to our developers.
I want to scanner who scan the stock & future stocks who’s Open=High (generating sell signal) and also Open=Low (generating Buy Signal)
could you plz make this possible
Thanks in advance
It’d be better if you post coding related queries on tradingqna.com
Hi Nitin,
Required your help to create code for below strategy
When there is crossover of 10 and 20 EMA there should be buy or sell of the stock
And it should match with ADX cross over. In simple way it will be like when there is cross over of EMA buy or sell only when there is crossover in ADX.
Dear Sir,
I want to make custom indicator for my PI, so is that possible???
Hello.
I recently opened account with Zerodha. How can I use algo referring the Renko chart ? When I tried to backtest all the results are with candlestick chart.
Thanks with Regards
Shrikant
You will have to code the renko within your strategy.
Sorry for asking a seemingly obvious question, but I couldn’t figure it out.
I recently opened an account in Zerodha. I see lot of documentation about algoZ. But what is missing is, where is this available? Is it an online tool, or do I need to download some software for this?
Thanks
pleae make a formula …
buy when 9 mnt sma cross over to 20 mnt sma+stoch d% cross over k%.this is called golden cross over.
sell when 20 sma cross down 9 sma and stoch k% cross down d%.this is called dead cross over.
thanking you.
can you post this on tradingqna.com under coding section.
Hi,
How to code the below strategy:
Buy and Sell: based on the crossover of ‘Ehlers Fisher transform indicator’?
Please advise.
Regards,
Thulasee
Can you ask all coding related queries on tradingqna.com
Hi,
I need to know, is there any tutorial which explains how to use tradescript to create alerts. And how can we create our own codes.
No tutorial as such, but check this: https://zerodha.com/expert-advisors/. Also when you login to Pi, under help you can see a user manual. You can also check this: http://tradingqna.com/algos-strategies-and-code
Hi,
Do you provide any sort API which I can use to write my own system to interact with trading applications? Basically what I am trying to achieve is algo trading with bit more complexities like looking at the NIFTY chart and then deciding to create position in Futures.
Regards
Dear Nithin,
Currently the bracket order screen takes only limit buy/sell orders. Could you please update to take also the market, SL and SL-M orders (during the first buy/sell)? This will be extremely useful and without this, it is a serious handicap and probably many other Zerodha traders feel the same way.
Since you already have this in place in the normal buy/sell orders (F1/ F2), it should not be too difficult to activate this feature also for the bracket orders.
Regards.
You can place a market order by:
a. Entering a higher price than what it’s trading at if its a Buy BO
b. Entering a lower price than what it’s trading at if its a Sell BO
Bracket order is a vendor developed product, so it’d be difficult to make changes to the inherent nature of the order for it to include SL & Sl-M entry types. Nonetheless, we’ll co-ordinate and see what best we can do.
I think you got it wrong 🙂
For a buy order the limit price is the price at which / below which the stock will be bought. So, even if I enter a higher price, the stock will still be bought at the CMP if the CMP is lower than or equal to the limit price.
Same thing applies for sell order.
I want to buy only when the price reaches a particular value, at which my “buy-setup conditions” are fulfilled, and not at a lower price / higher price. This is currently not possible with the bracket order of Zerodha. I have to use the normal buy order (F1), but then I lose the advantages offered by the bracket order.
With all humility, I don’t understand why it is difficult to incorporate this change. Bracket order is an extension of the normal buy / sell order, with additional features added. You already have the M / L / SL / SL-M options in a normal order. That means, the necessary macros / subroutines are already present in the software. You only have to activate that part of the programming loop in the bracket order function. Your software vendor should be able to do it in 1 day max. !!
Come on Zerodha !! You can do it !! This is an opportunity to add one more feather in your cap.
:), yep on our list of things to do. The issue with bracket order is that exchange considers this an algo, and doing anything on it is really really tough.
I want to backtest this strategy
TimeFrame: 15 min
15min candle should close above/below the ATP of yesterday.
Then, initiate the trade on the Low/High of that candle and stop loss is Low/High of the candle.
After 15mins candle touches ATP, sell/buy as per below:
SHORT- If the touching candle CLOSES below ATP (RED), then SELL below LOW of the touching candle
with candle high as SL.
LONG – If the touching candle CLOSES above ATP (GREEN), then BUY above HIGH of the touching candle
with candle low as SL
Please help
Ask all coding related queries on tradingqna.com
Dear Nithin,
I am a new trader with Zerodha. I request an answer for the following query.
How are the “buy price” and “sell price” denoted as functions in TradeScript?
For eg.: I want to back test the following algorithm.
My buy expression is:
CLOSE>EMA(CLOSE,7) AND
EMA(CLOSE,7)>EMA(CLOSE,21)*1.001
RSI(CLOSE,14)<40
My sell expression is:
Buy price + 0.5% of buy price.
How do I code my sell expression?
Thanks in advance!
Can you post all coding queries on tradingqna.com
Hi Nithin
I Need A ALGO Code For Pi Expert Advisors & ALGO Logic
Buy Above Putt in our Any % of Recent Low on 5 M Chart
Sell Below Putt in our Any % of Recent High on 5 M Chart
Percentage calculation Training From Recent High Low on Live Market Price
Generate Buy/Sell Signals ON PI ALGO Code Pleas Send Code For This Logic
By RAJESH J
Can you post coding queries on tradingqna.com
Sir
How to get mobile trading app login and pwd
Use the same ID and password that you would use for web/exe platform of Zerodha.
Sir, I want this strategy.
Intraday Chart
5 min=1 Candle
Moveing Avg = 20 ema, 50 ema, 100 ema
MACD = (11), (50-100)
Stochastic = 3, (%D), 100(%K)
Moving Avg
> When price candle goes above or below 100 EMA is a sure & long term Buy or Sell Signal
> 20 & 50 EMA can be used as support or resistance level
MACD
> Buy or sell potion should be taken nearer or while crossing “0” line, which should be carried for relatively medium term (1-2 days) when MACD goes above or below “0” line for decent profit/
> Positive crossover in positive zone is 100% buy signal & vice versa.
Stochastic
> Above 50 Fresh buy
> Above 80 Buy hold
> Below 80 Buy Exit
> Below 50 fresh short sell
> Below 230 sell hold
>Above 20 sell Exit
Can you put up all coding queries on tradingqna.com
to sir mai kaise janunga ki kaunsa signal true hai jaise backtest me show karta hai
The variation will be very small, but we will soon give in backtesting an option to choose if it is close of candle or during.
trend buster
CROSSOVER(CLOSE,REF(HHV(30),1))
CROSSOVER(REF(LLV(30),1),CLOSE)
plz tell me what is wronge with me
Please ask all your coding related queries here: http://tradingqna.com
see
in pi backtest result and live result are different in same timeframe. what should i do?
In EA, 2 sell signals can get generated simultaneously but in Backtest, a buy signal is followed by a sell signal and vice versa. So if 2 sell signals get generated on EA, Backtest will show only the first sell signal and hence you see the difference.
HELLO NITIN SIR, GD EVENING
I WANT TO MAKE SIMPLE SCANNER STRATEGY FOR STOCHASTIC OSCILLATOR FOR PI SOFTWARE.
BUY = STOCHASTIC OSCILLATOR(%K) CROSSES ABOVE STOCHASTIC OSCILLATOR(%D) BELOW 20 LEVEL.
SELL= STOCHASTIC OSCILLATOR(%K) CROSSES BELOW STOCHASTIC OSCILLATOR(%D) ABOVE 80 LEVEL.
FOR 5 MINUTE TIMEFRAME.
THIS STRATEGY APPLY IN DAILY CHART AND GENERATE A BUY SIGNAL AND IN 5 MINUTE CHART EVERY BUY SIGNAL GENERATE IN SAME STRATEGY , IF IS IT POSSIBLE SCANNER READ THIS TYPE OF STOCK?
Can you post all coding queries here: http://tradingqna.com/algos-strategies-and-code
I need a simple strategy to find overnight gaps for past 7 days, up or down where my conditions would be as follows.
up gaps:
today Low > Previous day high
today volume > 1.5 times Previous day volume
down gaps:
today high 1.5 times Previous day volume
Can you make a code for this?
sir i wish to create an alert in pi when-a new 10 bar low is made ,when a new 10 bar high is made intraday ,
timeframe 15 minutes charts plz guide me
how to code this and create a scanner for this
thanks
Can you ask all coding related queries here: http://tradingqna.com/
Hi,
Greetings, Is it possible to execute SELL/CLOSE option position based on Total price?.
Example:
I bought 100 option of CE8000 for Rs.X, if my current position TOTAL AMOUNT(Ex: Rs. Y) reaches certain amount, it need to execute SELL order at market price.
It would be help full if u send back-testing steps. Thanks for your time.
Thanks
Hi, currently not possible to set SL based on total amount in the account. Check this post for backtesting.
Hi Nitiin,
Please help me code this,
buy only when sma close 10 crosses ema 30 from below and price is trading above sma 200
sell only when sma 10 dips below ema 30 and price is trading below sma 200
Thanks
Search for moving average strategy here: https://zerodha.com/expert-advisors/, you can reply EMA by SMA for simple moving average instead of exponential.
I tried formulating one, but couldn’t manage the 2nd condition of the cross happening above and sma 200
Hello Team Zerodha, I hold account da6251. I wanted a script to be made on my strategy. Crossover of 5-period exponential moving average and 20 period moving average on candle stick chart of 3 minutes. I find it great for trading in crudeoil, I want to backtest my strategy.
For example, in the picture attached below trader gets into trade sell when 5 period is below 20 period and buy when 5 period is above 20 period. I hope you’ll help me out.
Thanks!
Moving average crossover is already coded here: https://zerodha.com/expert-advisors/. You just have to change the numbers
Hi, I’ve been trying the following script:
Sell Script:
SET MA1 = ExponentialMovingAverage(CLOSE, 20)
SET MA2 = ExponentialMovingAverage(CLOSE, 05)
CROSSOVER(MA1, MA2) = TRUE
Exit Short:
SET MA1 = ExponentialMovingAverage(CLOSE, 20)
SET MA2 = ExponentialMovingAverage(CLOSE, 05)
CROSSOVER(MA2, MA1) = TRUE
However, while back testing, it says : “No results. Make sure at least Buy & Sell signals are typed in”
I’m unable to identify the error in the script. Would appreciate help in this regard.
Thank you
can i get the coding done for generating buying signal when 20 days ema crosing 20 days sma ?
We have a bunch of pre-coded strategies here: https://zerodha.com/expert-advisors/. If you have any other queries, u can ask here: http://tradingqna.com/
[…] Code your Technical Analysis strategy | Z-Connect by Zerodha – Traders, This is where we will be getting help from our programmers to code your technical analysis strategy. It could be as simple as moving average crossovers to … […]
let me know, How to take last four RSI values fr checking >= or <= condition with current RSI value ( 2min interval)
And also want to take the current value of MACD & EMA values from MACD chart and K, D & J values from KDJ indicator?
Can you ask all coding related queries here: http://tradingqna.com/algos-strategies-and-code
Dear Nithin,
I have few queries below.
1. In all the EA’s opposite signal serves to close the position. But, how to generate signal for closing the Buy position (which is not the correct point to short the script only profit booking point) and sell (to open a new sell trade) separately and vice versa by meeting required criteria. I hope you got my intension.
2. Can we get different colour of buy, sell signal for different EAs.
3. Can we get signals from 2 different EAs at a time in live market.
1. You will have to run two EA’s then, a Buy EA and another one Sell EA simultaneously on the same strategy.
2. hmm.. not possible currently.
3. Yes, you can get from as many EA’s as possible.
Hi Nitin,
I have just started with intra-day trading. i do trading on basis of total buy quantity vs total sell quantity.
I want to know if we can generate the signal on basis of quantity i.e. buying is more than selling then buy signal and vice versa.
NOt possible, the market depth window doesn’t really get captured on tradescript.
I want to do intraday trading in options with a 30 minute Heikin Ashi candle stick chart and RSI raising above 30. So can U please set a Scan and Alert and write the code for the same.If you can mail it to my mail Id ,i will be much obliged
Hari, can you ask all your coding queries here: http://tradingqna.com/algos-strategies-and-code
Sir how can we code for a buy on haikin ashi chart above 36 day EMA and sell below 36 day EMA on HA char while using 5 min.timeframe intrady .I tried using the script provided by Expert adviser ,but it shows HAC error while back-testing.
Can you ask all coding related queries on tradingqna.com
CAN WE CODE MULTITIMEFRAME STRATEGIES IN pi.
Simple :
1 hour chart c>sma 200
and
5 minute chart c<sma200
Please inform.Thanks.
hi
can I code bollinger bandwidth in the algos.
i.e. if bollinger bandwidth is narrow then cross over of 10 & 20 EMA gives me Sell signal and vice-versa.
Yep, you can. Check this: https://zerodha.com/expert-advisors/, has sample strategies. If you need help with the code, ask on tradingqna.com
Hi,
I have 2 queries.
1) When are u going to start full automation on pi? Need it on urgent basis
2) I need to backtest scrips/indices for 3-5 years? How can i do that
Regards
1. We will be releasing Pi bridge + very soon. If you are a programmer it will be quite simple. You can pull all info from trade updates to funds to third party program, and fire orders from there using sockets.
2. You will have to buy it from a data vendor. Try asking neotradeanalytics.com. Mention your zerodha client ID, they will give u a discount.
Please help me to write my strategy
I want to get a buy signal only when the price is above 50 sma and the candle close above the 75% of its todays low. for example the price is above 50 sma. Todays low is 95 and high is 102. I want to get a buy signal if the candle close above 100.25
Similarly I want to get a sell signal only when the price is below 50 sma and the candle close below the 74% of its todays high. For example the price is below 50 sma. Todays low is 95 and high is 102. I want to get a sell signal if the candle close below 96.75
Can you ask all coding queries here: http://tradingqna.com/
Nithinji , friday when i tried to place BO in petronet . order was rejected as client not enabled on product , then called customer care , they activated BO , after that also when placed order was rejected says “margin exceeded ,required margin 3 lakhs something and have only 2 lakhs something” like that, but i had enough margin in my a/c besides my other trades when i calculated in bo calculator it comes around 7000 , but for the same order i put SL and TSl for 95 paise , then only i saw in below 1 rupee SL or TSL cant put order.? does that order rejected becuase of that Sl. tsl?
does minimum would be 1 re or 1.5 % ? and also one more query say if i place 4 lots at the time of placing BO and can modify in between to sell 2 lots for some gain and hold the remaing for EOD?Thanks in advance
Yes, if you’re placing a Trailing SL order, min trailing value = 1 or 20 ticks.
All BO’s get squared off. You can’t carry forward BO positions.
Thanks sir.
Nitin Sir can you please let me know code for below given strategy.
buy when stock breaks high after 10.00 am ( high should be from 9.30 to 10.00am)
sell when stock breaks low after 10.00am (low should be from 9.30 to 10.00 am)
Do ask all your coding queries on http://tradingqna.com/algos-strategies-and-code
Hello Nitin ,
I would like to code the following.
the input to the code will be the prices from cash or spot mkt . like Nifty cash price to be considered to take the trade . but trade to be taken on nifty futures . Is this possible ? Thanks
Same query I have cash price to consider trade and order should be taken in options
HI,
I need a code of following stretegy :
this is to apply in EOD chart
Buy : buy at todays high if ( ( yesterdays high > todays high) and (yesterday low todays high) and (yesterday low < todays low) )
sell : EOD (using MIS type)
Check this section Nikhil: http://tradingqna.com/algos-strategies-and-code or here https://zerodha.com/expert-advisors/. if u don’t see it, u can ask the question on tradingqna
Sir,
I didn’t get any code from these sites
http://zerodha.com/expert-advisors/
http://tradingqna.com/algos-strategies-and-code
Please send code for automatic buy and sell signals for above EMA cross overs.
Thank you
Narayana, do ask your questions on coding directly on tradingqna.
Sir
Thank you for your reply, and
I need code for automatic buy and sell signals for above EMA cross overs
Sir
I need a code for the following condition.
Buy: whenEMA5 line crosses EMA10 from below.
Sell: whenEMA10 line crosses EMA5 from below.
For above code how to generate buy and sell ARROW symbols.
Thanks in advance.
Can you check here:https://zerodha.com/expert-advisors/ or else ask here http://tradingqna.com/algos-strategies-and-code
Dear Zerodha,
i got the Amibroker software
the formulas AFLs
but as i am a new user i don’t know how to use the AFL files
plz guide me what i have to do in setting if there is
i pick the afl files in auto analysis but not working
plz reply i got afl files but dont know how to use i can not use it
Subhash, can you ask all AFL related queries here:http://tradingqna.com/algos-strategies-and-code
its a request to send code code for following:-
buy signal = when ema 10 crossing ema 20 above side and price candle on five minute time frame close above or at ema 10.
sell signal = when ema 10 crossing ema 20 down side and price candle on five minute time frame closes at or below ema 10.
My strategy is EoD strategy
When 14 period ADX is above 35.
BUY:- +DI above -DI and Today Fast STOCK %K must close under 40% (Period for %K is 8) ,We will buy tomorrow one tick above today’s high.
Sell:–DI above +DI and Today Fast STOC %K is close above 60% We will sell short tomorrow (Day two),one tick below today’s low.
Hi Team,
Need your help in coding for a VSTOP indicator, below is the code. Can you please help in converting it to Code that can be used in PI software.
study(“Volatility Stop”, shorttitle=”VStop”, overlay=true)
length = input(20)
mult = input(2)
atr_ = atr(length)
max1 = max(nz(max_[1]), close)
min1 = min(nz(min_[1]), close)
is_uptrend_prev = nz(is_uptrend[1], true)
stop = is_uptrend_prev ? max1 – mult * atr_ : min1 + mult * atr_
vstop_prev = nz(vstop[1])
vstop1 = is_uptrend_prev ? max(vstop_prev, stop) : min(vstop_prev, stop)
is_uptrend = close – vstop1 >= 0
is_trend_changed = is_uptrend != is_uptrend_prev
max_ = is_trend_changed ? close : max1
min_ = is_trend_changed ? close : min1
vstop = is_trend_changed ? is_uptrend ? max_ – mult * atr_ : min_ + mult * atr_ : vstop1
plot(vstop, color = is_uptrend ? green : red, style=cross, linewidth=2)
Guru, indicators can’t be still coded on Pi. You can code expert advisors which will give you buy/sell signals based on the code. Guess you have already asked on tradingqna, will ask someone to check this out.
Thanks Nithin
Also, could you pls guide what beginners can read to learn the basic strategies, so that building upon them becomes easier. That is besides this very informative blog, which I am slowly reading, and the chapter on Trading System Techniques in Tradescript manual. Thanks.
We will very soon include a module on Trading systems/strategies on Varsity, check this: http://zerodha.com/varsity/
I am backtesting simple strategies as a beginner, and the biggest problem I face is being whipsawed out in non-trending markets. Trend indicator like ADX are too late to respond and by then moves are over and I am stagnated again into sideways market. Please suggest some strategy/indicator to stay out of sideways market, and yet not lose the beginning of good moves.
Please help me by coding this strategy
Buy Level = L+[ 0.5 * (H-L)]
Buy Stoploss = L+[ 0.1 * (H-L)]
Buy Target = L+[ 1.0 * (H-L)]
Sell Level = H-[ 0.5 * (H-L)]
Sell Stoploss = H-[ 0.1 * (H-L)]
Sell Target = H-[ 1.0 * (H-L)]
Where
H = Highest of Previous Day High and Current Day High
L = Lowest of Previous Day Low and Current Day Low
If any filter can be provided reduce the number of trades per day to 2 or 3
Regards
Renjith
Renjith, can u ask all coding queries here: http://tradingqna.com/algos-strategies-and-code
what is best stratergy for trading nifty future 1 hour time period
Hi NIthin,
This is my stragery, every sell signal and Exit Short works fine, its just that i am not getting any buy Signals although when I checked it on the Chart it should have given many buy signals.
Please help me, TradingQandA though being a great website is very slow, Whereas your replies are brisk. Please tell me what is wrong with this code here on this page itself. I wrote the strategy myself yet something seems to be wrong with it.
BUY Signal – WWS(CLOSE,5) > WWS(CLOSE,8) > EMA(CLOSE,40) > SMA(CLOSE,75) AND MACDSIGNAL (13, 26, 9, EXPONENTIAL) > 0 AND AND DIP(14)>25 ADX(14) >28
SELL Signal – WWS(CLOSE,5) < WWS(CLOSE,8) < EMA(CLOSE,40) < SMA(CLOSE,75) AND MACDSIGNAL (13, 26, 9, EXPONENTIAL) 25 AND ADX(14) >28
Exit Long – MACD(13, 26, 9, EXPONENTIAL) > MACDSIGNAL (13, 26, 9, EXPONENTIAL) AND CLOSE < EMA(CLOSE,40) OR CLOSE < OPEN AND REF (CLOSE, 1) < REF(OPEN, 1) AND REF(CLOSE, 2) < REF(OPEN, 1)
Exit Short – MACD(13, 26, 9, EXPONENTIAL) EMA(CLOSE,40) OR CLOSE > OPEN AND REF(CLOSE, 1) > REF(OPEN, 1) AND REF(CLOSE, 2) > REF(OPEN, 2)
Please help me out, My script is almost done just a bit of correction from your end will do wonders.
Again, Buy and Exit Long are not giving any signals.
The above one had a few errors, if corrected them still the problem persists.
Buy – WWS(CLOSE,5) > WWS(CLOSE,8) > EMA(CLOSE,40) > SMA(CLOSE,75) AND MACDSIGNAL (13, 26, 9, EXPONENTIAL) 25 AND ADX(14) >28
SELL – WWS(CLOSE,5) < WWS(CLOSE,8) < EMA(CLOSE,40) < SMA(CLOSE,75) AND MACDSIGNAL (13, 26, 9, EXPONENTIAL) 25 AND ADX(14) >28
Exit Long – MACD(13, 26, 9, EXPONENTIAL) > MACDSIGNAL (13, 26, 9, EXPONENTIAL) AND CLOSE < EMA(CLOSE,40) OR CLOSE < OPEN AND REF (CLOSE, 1) < REF(OPEN, 1) AND REF(CLOSE, 2) < REF(OPEN, 1)
Exit Short – MACD(13, 26, 9, EXPONENTIAL) EMA(CLOSE,40) OR CLOSE > OPEN AND REF(CLOSE, 1) > REF(OPEN, 1) AND REF(CLOSE, 2) > REF(OPEN, 2)
Please look at this one.
Hi Nithin, I have posted the requirements on tradingq&a please ask someone to answer it
http://tradingqna.com/15458/need-buy-sell-script-for-pi-based-on-the-following
Thank you
Will get someone to reply, cheers. I was answering coding queries here, but have stopped now as the length of this post has gone too long, and it is not easy for others with similar queries to refer to.
Nithin,
What i mean is i want to backtest the above code i.e Qudara strategy on Pi Backtest.
I am a newbie and i dont really now anything about backtesting hence, i request you to type in the Buy,Sell,Exit long, Exit Short for the above script so that i can impute your wirtings on the Backtest tab and get it working.
You can check out this link – http://www.trader-guide.com/quadra-safe-trading-strategy/
This is what i am hoping to get as a backtesting script.
Thank You. 😀
Basically I want it to Buy when Wells Moving Avg WWMA – 5,8 and 13 crosses over EMA 50 and all the above crosses EMA 125. Plus MACD crosses 0 Positive.
and sell when WWMA = 5,8 and 13 crosses below the EMA 50 which crosses the EMA 125 and MACD crosses 0 Negative.
and if possible,
Exit Long – if 5th candle closes below 4th Candle Close in conjunction
Exit Short- if 5th Candle closes above 4th Candle High
This is my first script pattern, please do share your opinion if i am doing something wrong.
Thank you so much for your brisk replies.
And also what if I confirm it by ADX Above 25 and +Di above 25 in case of buy signal
And sell signal when ADX above 25 and -Di above 25 in case of sell signal .
P.S – both buy and sell signal consisting of the WWMA EMA And Macd crossovers as per the settings given above.
Will this technique work..
Thank you Nithin.
Hey Bose, what I meant was if you can ask your coding/scripting related queries on tradingqna, check this link: http://tradingqna.com/. Will get someone to answer back. http://tradingqna.com/algos-strategies-and-code
Hi Nithin can you help me out with this, i need the Pi script for this code,
/****************************/
/* */
/* Quadra Trading System */
/* Version 1.35 */
/* (22 December 2012) */
/* */
/****************************/
SetChartOptions(0, chartShowDates | chartWrapTitle);
/**********************/
/* */
/* Define Wilder’s MA */
/* */
/**********************/
function WilderMA(Field, Period)
{
X[0] = Field[0];
for(i = 1; i < BarCount; i++)
{
X[i] = Field[i]/Period + X[i – 1] * (Period – 1)/Period;
}
return X;
}
/**********************/
/* */
/* Define EMA */
/* */
/**********************/
function MyEMA(Field, Period)
{
Y[0] = Field[0];
for(i = 1; i O;
Red = C = C[i – 1]) Green[i] = 1;
if(Red[i – 1] AND C[i] <= C[i – 1]) Red[i] = 1;
}
}
/********************/
/* */
/* COMPUTE SL */
/* */
/********************/
PrevHi = H;
PrevLo = L;
SLBuy = Null;
SLShort = Null;
GUp = GapUp();
GDn = GapDown();
for(i = 2; i = L[i – 1] AND L[i – 1] <= L[i])
{
PrevLo[i] = L[i – 1];
}
PrevHi[i] = PrevHi[i – 1];
if(H[i – 2] = H[i])
{
PrevHi[i] = H[i – 1];
}
}
/********************/
/* */
/* BUY/SELL */
/* */
/********************/
Buy = (A1 > A2 AND A2 > A3);
Sell =(A1 < A2 AND A2 < A3);
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);
Bought = Flip(Buy, Sell);
Sold = Flip(Sell, Buy);
for(i = 1; i
{
SLShort[i] = Min(PrevHi[i], PrevHi[i – 1]) + 0.1;
if(GDn[i]) SLShort[i] = L[i – 1] + 0.1;
if(Sell[i]) break;
}
for(i = 1; i
{
SLBuy[i] = Max(PrevLo[i], PrevLo[i – 1]) – 0.1;
if(GUp[i]) SLBuy[i] = H[i – 1] – 0.1;
if(Buy[i]) break;
}
for(i = 1; i SLShort[i – 1]) SLShort[i] = SLShort[i – 1];
}
Marker1 = Buy * shapeUpArrow + Sell * shapeDownArrow;
MarkerColor = IIf(Buy, colorBrightGreen, colorYellow);
Marker1Dist = IIf(Buy, 0.995 * L, 1.005 * H);
/***********************/
/* */
/* SHOW/HIDE Option */
/* */
/***********************/
Arrows = ParamToggle(“Show Arrows”, “NO|YES”, True);
ShowTSL= ParamToggle(“Show TSL Line”, “NO|YES”);
_N(Title = EncodeColor(colorLightGrey) + “QUADRA EOD TRADING SYSTEM Concept by Savant Garde\n”
+ EncodeColor(colorYellow) + “Implementation by Anant Navale; AFL Version 1.35\n\n”
+ EncodeColor(colorPink) + StrFormat(“{{NAME}}({{INTERVAL}}), {{DATE}} : {{OHLCX}}, Vol=%1.0f\n{{VALUES}}\n”, V)
+ EncodeColor(colorBrightGreen) + WriteIf(Green, ” Green Candle”, “”)
+ EncodeColor(colorRed) + WriteIf(Red, ” RedCandle\n\n”, “\n\n”)
+ EncodeColor(colorWhite) + WriteIf(Buy, “Buy Above ” + (H + 0.1), “”)
+ WriteIf(Sell, “Sell Below ” + (L – 0.1), “”)
+ WriteIf(Buy, ” StopLoss = ” + SLBuy, “”) + WriteIf(Sell, ” StopLoss = ” + SLShort, “”));
if(Status(“action”) == actionIndicator)
{
/****************/
/* */
/* ALERT OUTPUT */
/* */
/****************/
TxtX = Param(“Text Left”, 800, 0, 1000, 10);
TxtY = Param(“Text Top”, 50, 1, 650, 10);
GfxSelectFont(“Tahoma”, 14, 700 );
GfxSetBkMode(1);
if(LastValue(Buy) OR SelectedValue(Buy))
{
GfxSetTextColor(colorBrightGreen);
GfxTextOut(“BUY Triggered”, TxtX, TxtY);
Say(“Buy Triggered”);
}
else if(LastValue(Sell) OR SelectedValue(Sell))
{
GfxSetTextColor(colorGold);
GfxTextOut(“SELL Triggered”, TxtX, TxtY);
Say(“Sell Triggered”);
}
else
{
GfxSetTextColor(colorBlack);
GfxTextOut(“”, TxtX, TxtY);
}
Plot(A4, “EMA50”, colorLightGrey, styleLine | styleThick);
Plot(A3, “Wilder MA1”, colorRed, styleLine);
Plot(A2, “Wilder MA2”, colorLightOrange, styleLine);
Plot(A1, “Wilder MA3”, colorBrightGreen, styleLine);
if(ShowTSL)
{
Plot(SLBuy, “SL for Buy”, colorLightBlue, styleDots);
Plot(SLShort, “SL for Short”, colorGold, styleDots);
}
Plot(C, “”, IIf(Green, colorGreen, IIf(Red, colorRed, colorGrey50)), styleCandle);
if(Arrows)
{
PlotShapes(Marker1, MarkerColor, 0, MArker1Dist);
}
}
if(Status(“action”) == actionExplore)
{
Filter = Buy OR Sell;
SetOption(“NoDefaultColumns”, True);
AddTextColumn(Name(), “SYMBOL”);
AddColumn(DateTime(), “DATE”, formatDateTime);
AddColumn(IIf(Buy, 66, 83), “TRIGGER”, formatChar, colorWhite, IIf(Buy, colorGreen, colorRed));
AddColumn(IIf(Buy, H + 0.1, L – 0.1), “TRIG PRICE”, 1.2);
AddColumn(IIf(Buy, SLBuy, SLShort), “Stop Loss”, 1.2);
AddColumn(C, “Last Close”, 1.2);
}
Bose, can you put up all your tradescript queries here: http://tradingqna.com/algos-strategies-and-code
Hi Nithin, I’ll be really great flu if you could show me the correct pi backtest codes here itself.
🙂
I am really bad at coding, easier for me to forward tradignqna links.
I am new to pi but I am not able to code my strategy I want to do intraday in nifty options. My strategy is to buy call/put 4 lots of nifty option in 1 min chart when EMA 5 crosses EMA 15 and sell it when reverse so how to write code in new alerts section in pi. there are four sections buy script,sell script,exit long script,exit short script but I dont know how to code it.
Hi ,
I have started using PI and it is really Good. I wanted to know if there is any way to generate a alert after nifty makes a upward or a downward movement of more than 10 points from the closing price of the previous candle on a one minute intraday chart. Also is it possible to view two candlestick charts on the same page like the index chart and the stock chart.
CT, you can’t really have a code for 10 points from closing price. You can code in terms of technical analysis only. Have you seen this post on how you can arrange the screen? http://zerodha.com/z-connect/tradezerodha/pi-tradezerodha/charting-pi
hi i’m new to pi trading platform and my query’s are
1. i have some afl strategy’s of amibroker and can they be directly used in the pi trading platform by just copy and pasting which are in afl formats.
2. if i make a strategy in pi software, can that be used in amibroker directly by copy pasting in the formula wizard.
thank you
1. No Manoj, you will have to recode them using tradescript. If you are using Ami, you can use the Pi bridge to fire alerts directly from Ami using the bridge. Check this.
2. No, the programming language is different in Pi and Ami.
[…] Code your Technical Analysis strategy – Z-Connect by Zerodha – Traders, This is where we will be getting help from our programmers to code your technical analysis strategy. It could be as simple as moving average… […]
1. How do I use Pi to place a simple price alert. Like Bhel touched a price of 230.
2. Similarly how do i create alert for price touching a EMA on particular timeframe. Like Bhel has touched 34 EMA on 60 min chart
how to view bid/ask lines in ami broker charts or pi charts not the ltp line
Hi,
had posted the query for coding a EA, which can be used to scan scripts in tradingqna.
Strategy 1 : Give signal when,
(a) Ehler Fisher transform reverses from top ie Trigger value becomes greater than signal value, AND
(b) Elder bear power > 0, AND
(c) Elder bear power > Elder Bull power
Strategy 2 : Give signal when,
(a) Ehler Fisher transform reverses from bottom ie Trigger value becomes less than signal value, AND
(b) Elder Bull power > 0, AND
(c) Elder Bull power > Elder Bear power
Also, how to use the above strategies for scanning the selected scripts for a particular timeframe in Pi
The feedback recd was that, it is not possible to code the following strategy in Pi. Am not able to understand that why cant an EA be created with indicators available in Pi. In fact, I wanted to try the strategy as mentioned above and also a strategy with only elements (a) & (b) in the strategies mentioned above being met and evaluate the results.
Await feedback pl.
Ashish, I think I posted the answer already, preset codes for Elder is not available. If you can give the logic of elder bear power, that can be coded.
Nithin, am not sure what is being referred to by preset codes not available.
In the strategy logic, had made reference to “Elder Ray Bull Power” , “Elder Ray Bear Power”, which is amongst the set of TA indicators available in Pi. The strategy is a combination of reversal of Ehler Fisher transform & checking for supporting values of Elder Ray Bear / Bull power indicator.
Yes Ashish, this is available as an indicator on Pi, but there is no tradescript code for it as such. For example there is EMA which is a preset code for Exponential moving average, similar to that there is preset code for Elder. You will have to build this code yourself. But I am checking it out with our team, will keep you posted.
Noted. Did not understand the technicals but got the logic of your explanation. If possible, pl do inform.
Thanks
Hi Sir,
I am trying to write a strategy in PI software with following condition.
1. Buy when Nifty 2 min. candle goes below bollinger band and closes within bollinger band boundary.
2. Sell when Nifty 2 min. candle goes above bollinger band and closes within bollinger band boundary.
I am attaching the 2 min. chart highlighting the signal points I am expecting.
I tried using the example in the book but it does not work properly. Thanks.
Can you ask all your coding related queries here: http://tradingqna.com/algos-strategies-and-code
i want a code like this.
can i get help to code this
identify the high and low from 9.15 am till 10 am
whenever the same high is reached from 10.01 am to 3 pm do a SL Long and exit 0.75 paisa above the entry price. Same with low but SL short and exit 0.75 paisa lower than the entry price.
thanks
Prakash, you can’t really run a time based strategy like this on Tradescript.
this is good. but which strategies do give good success rate? there are so many strategies out there for intraday stock or intraday stock futures
thanks!
Hi,
I need a code for Heikin Ashi Smoothened with a input parameters of 2-2-3-2
BUY SIGNAL : When body of the colour changes Green (after 1st candle confirmation).
SELL SIGNAL: When body of the colour changes RED. (after 1st candle confirmation).
At the same time, Reversal order should takes place by sqaring-off previous positions.
Thank you,
Do post this query under the algo section in tradingqna.com
Hi Nithin,
I need some sample code for Bank Nifty (Future)
I didnt get answer in Q&A for the strategy
Hi Nitin,
I have a Strategy to code on buy for Crudeoil
Buy
Crossover(EMA(Close,50),EMA(CLOSE,5))
Sell
Crossover(EMA(Close,50),EMA(CLOSE,5))
Buy Exit
I want it to be above last crossover of the my buy signal
Sell Exit
I want it to be above last crossover of the my sell signal
And also want to avoid Flat cross over any indicatiors to club with RSI or CCI which avoids flat entry or exit.
Why I want the buy exit & sell exit is due to it opens new sell which is like & buy & sell order closed missed opportunity. This has to be in 5 Min Chart
Will get someone to answer on Tradingqna
Hi Nitin sir
How to Create Expert Advisor
hi Nitin sir
Stochastic Oscillator :
Buy:
%K periods=21
%K slow=11
%D periods=3
Sell:
%K periods=5
%K slow=9
%D periods=9
Can you post this on Tradingqna.com
sir plz tell me how to code following stragety
buy when all ema 5,7,10,14,21 converge and cross over price. and vice versa for sell
Hi Nitin,
I have a Strategy to code on buy for Crudeoil
Buy
Crossover(EMA(Close,50),EMA(CLOSE,5))
Sell
Crossover(EMA(Close,50),EMA(CLOSE,5))
Buy Exit
I want it to be above last crossover of the my buy signal
Sell Exit
I want it to be above last crossover of the my sell signal
And also want to avoid Flat cross over any indicatiors to club with RSI or CCI which avoids flat entry or exit.
Why I want the buy exit & sell exit is due to it opens new sell which is like & buy & sell order closed missed opportunity. This has to be in 5 Min Chart
Ravi, do post all your trading queries here: http://tradingqna.com/ in the algo section. Also tag your question as tradescript, if you want this on tradescript.
Hi Nitin,
In PI Go live to tested strategies are not getting executed even if i say go live it gives just an alert no execution no pop up.
My client id DR0875.
Resolve it quickly.
Ravi, once you go live, the alerts get posted in the generated alerts window. You can see the generated alerts window in the main alerts menu.
Hi Nithin,
Is it better to use buy exit for buy calls instead of sell in the back test?
Buy -> Buy exit OR Buy -> Sell
For a same logic, same script, same time period, I got different back test results, for the above two scenarios, that’s why asking you.
1. Kindly clarify the difference between these two — How the system treats these two.
2. How the system evaluate the Trend inbuilt function — clarity is not there. Even the market is in trend, this function didn’t catch it. Since market trend is subjective (few points or few 10s of point etc) and Trend function is inbuilt, I couldn’t understand how it finds whether the market is up/down trend. I referred the user manual in Pi as well the links you shared — They are saying what this function does and they didn’t say how. Kindly clarify.
Regards
AMS
Regards
AMS
Buy Expression:
Hi Nithin,
I have Copy Pasted exactly the Same in PI to back test for Bank Nifty But Does Not Gives me any Result ,
MACD(26,12,9,EXPONENTIAL)>MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI(Close,10)>30 AND REF(RSI(Close,10), 1)<30
Buy exit: 0
Sell Expression:
MACD(26,12,9,EXPONENTIAL)<MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI (CLOSE,10) 70
Sell exit: 0
Have answered here.
Hi Nitesh,
Looks like sell expression is having some probs.
“RSI (CLOSE,10) 70” There is no condition at all like less than or greater than…
It may be like this
RSI (CLOSE,10) < 70
Regards
AMS
what is the code for single candle divergence?
[…] programming language used on pi is called tradescript, and this post has around 300+ queries answered and the manual, should help you get […]
hi nitin ,
I just want to compare prices of some script from nifty at 9:30 and want to get alert from the software it self. I need alert about script whose open price is equal to high or low price of that script for the day upto 9:30. Can you pls provide the code for the same.
my query is, when we do ema 3,7 cross over coding and run replay of candles, the signals are placed in previous candles, i need at the candle when its conformed.
Need a screener with the following parameters:
Indicator: Slow Stoch, 39 + EMA 34
Condition: Screen for stock for which Slow Stoch 39 moving from under to over 50 and from over 50 to under 50. Also plot 34 EMA.
Assuming you want a buy for Stoch 3,9- you can use below code-
Buy- SOPK(9, 3, 9, SIMPLE) > 50
Sell- SOPK(9, 3, 9, SIMPLE) < 50
also not clear about second part of your query
I wanted to ask a query related to coding, hence tried to register myself on Trading QnA, however it is giving me the attached error…Am i doing anything wrong Sir?
Should work, can you try again.
The website is working fine now..Thanks for the swift action 🙂
Hi Nitin,
Hope you fine.
Please send a code of below formula for 5 min chart.
For BUY : 26th Nov close is 8500 and 27th Nov close is 8555 (means two positive candle) and MACD (11,50,100) is crossing over zero line and stochastic (3,100) is greater than 50
For SELL : 26th Nov close is 8500 and 27th Nov close is 8450 and MACD (11,50,100) is crossing below zero line and stochastic (3,100) is less than 50
Please send as earliest as possible on [email protected]
Thanks
chetan
Chetan, taking all coding queries on http://tradingqna.com/, use the category as algos.
Hi Nithin
Can i backtest few strategies on the current trading platform
The service is stopping on NEST, but a much more advance version is available here.
[…] Code your Technical Analysis strategyZ-Connect by Zerodha … – Traders, This is where we will be getting help from our programmers to code your technical analysis strategy. It could be as simple as moving average… […]
no reply yet ?
i m waiting sir………..
Radhey, we will be taking all coding queries only on http://tradingqna.com/, we are also getting some consultants on board to help code strategies. You will have to give sometime for this. In the meantime, do post the query on tradingqna, and also be very specific in terms of your query.
I specified it more :-
Buy = 1. close or touch below bb
2. rsi above 20 or 30
3. ema 3/13 crossover
4. L3 or H4 of advance camrilla
5. volume above ave of 8 period of time
Sell = vice versa
1. above or touch above bb
2. rsi above 80 or 70
3. ema 3/13 crossover
4. H3 or L4 of advance camrilla
5. volume above ave of 8 period of time
pls tell how to beck test it in nest trader..
please post coding related queries in tradingna in algos category
radhey
regarding the query on the 20th july 2014
dear sir,
I DONT KNOW CODING OF MY STRATEGY IS POSSIBLE OR NOT……….IF POSSIBLE
pls code my strategy which IS giveN below :
BUY : – crossover 2 sma and 5 tma((5 days trigular or pivot point average) + rsi line crossed 2nd time 30 toword upside + stoc above 20 line (on 2nd time crossing toward upside just like “hook’ upward) + special candlesticks pattern (higher closing to high of doji , hammer candle OR two bar reversal OR 50 % retracement of benchmark candle ) and…+ L3 OR R4 ……..[addING …ADVANCE CAMARILLA LEVEL ALSO……AS SUPPORT AND RESISTANT RATHER THAN PIVOT POINTS] + INCREASED VOLUME ALSO (IT SHD B ABOVE AVE OF LAST 8 PERIOD OF GIVEN TIME )
SELL :- JUST VICE VERSA
crossover 2 sma and 5 tma((5 days trigular or pivot point average) + rsi line BELOW 70 toword DOWNside + stoc BELOW 80 line (on 2nd time crossing toward DOWNside just like “hook’ DOWNward) + special candlesticks pattern (LOWER closing to LOW of doji , hammer candle OR two bar reversal OR 50 % retracement of benchmark candle ) and…+ R3 OR L4 ……..[addING …ADVANCE CAMARILLA LEVEL ALSO……AS SUPPORT AND RESISTANT RATHER THAN PIVOT POINTS] + INCREASED VOLUME ALSO (IT SHD B ABOVE AVE OF LAST 8 PERIOD OF GIVEN TIME )
I WOULD B VERY OBLIGED TO U IF ABOVE MENTIONED STRATEGY CONVERTED INTO CODES
THANKS
YOURS FAITHFULLY
RADHEY
¶
R
21 Jul 2014 at 10:07 AM
radhey
if specific candle pattern is not possible right now , pls code rest of strategy of mine…………ma crossover + stch+ rsi+ camrilla
¶
Reply
21 Jul 2014 at 10:10 AM
radhey
and + vol also
¶
Kindly code this strategy for me : This is strategy to buy/sell based on Camarilla Equation Levels: Buy When the price goes below L3 Level and then closes above it. Keeping L4 as Stop Loss and H1 as Target. SELL when price goes above H3 and closes below it keeping H4 as Stop Loss and L1 as Target. To calculate these levels use the following formula : To calculate Camarilla Pivot points all you need is previous trading day’s high low and close value. Below are the equations for calculation various levels.
C = Previous day close
H = Previous day high
L = Previous day low
H4 = [0.55*(H-L)] + C
H3 = [0.275*(H-L)] + C
H2 = [0.183*(H-L)] + C
H1 = [0.0916*(H-L)] + C
L1 = C – [0.0916*(H-L)]
L2 = C – [0.183*(H-L)]
L3 = C – [0.275*(H-L)]
L4 = C – [0.55*(H-L)]
We’ve just gotten word from our strategy coders and they’ve said that unfortunately this cannot be coded on algoZ.
Hanan
kindly code this
BUY When-
CLOSE C – (0.275*(H-L)
WHERE C, H, and L are PREVIOUS DAY CLOSE, HIGH AND LOW RESPECTIVELY.
I tried using DHIGH(2) for the previous day high but keeps giving error in code
pl help me to code
1)buy when ema 5 cross ema 14 and move up and
when directional index (ADX) 30 above and RSI above 59
2))exit when price goes up and reach value equal to (plus of) muliple 4 of true range or minus of multiple 2 of true range or rsi reach 80 or adx reach 20 or ema 5 cross ema 14 and goes down
3) 1)sell when ema 5 cross ema 14 and move down and
when directional index (ADX) 30 above and RSI below 41
4) )exit when price goes down and reach value equal to ( minus of) multiple 4 of true range or plus of multiple 2 of true range or rsi reach 20 or adx reach 20 or ema 5 cross ema 14 and goes up
We’ve just managed to get some answers from our strategy coders so here they are:
1. EMA, ADX, RSI:
Buy:
(Ema(close, 5) > Ema(Close, 14)) and (Ref(Ema(Close, 5)), 1) > (Ref(Ema(Close, 14)), 1) and (ADX(14) > 30) and (RSI(Close, 14) >59)
Exit:
TR = Current High less the current Low – please relate this and define your logic.
Modify the code of rsi, adx and ema for rest of your logic.
You would have to use the Nest Pulse guide to get more detailed instructions on coding your strategy.
Hi,
Can you tell me the code for Buying when Full Stochastic (15,5,5) %k >%D and MACD (12,26,9)> MACD Signal.
I tried using this(SOPK(15, 5, 5, SIMPLE) > SOPD(15, 5, 5, SIMPLE) and (MACDSignal(12, 26, 9, EXPONENTIAL)) > (MACD(12, 26, 9, EXPONENTIAL)))
But it did not work and similarly for sell (SOPK(15, 5, 5, SIMPLE) < SOPD(15, 5, 5, SIMPLE) and (MACDSignal(12, 26, 9, EXPONENTIAL)) < (MACD(12, 26, 9, EXPONENTIAL)))
((SOPK(15, 5, 5, SIMPLE)) > (SOPD(15, 5, 5, SIMPLE))) and (MACDSignal(12, 26, 9, EXPONENTIAL) > MACD(12, 26, 9, EXPONENTIAL))
Please reverse the code for sell, please send the screenshot if generates errors.
Hi Nitin I have commented twice to you about zerodha q not working. But no reply from u and u r customer care told me that problem resolved but as of now not yet. Even the site is not getting opened. REally frustrating for me. My ticket no #443569. KIndly resolve this issue….
Om, we have replied back on that ticket saying it is fixed. It seems to be working, can you check. Also it is best, if you ask these questions on your support ticket directly on [email protected].
hi Nitin,
There is a strategy which works superbly in 1 min Chart. It would be grateful if I can get the code.
Stochastic momentum Index :
Default Values:
%K periods=13
%K smooth=25
%K Dbl smooth=2
%D periods=9
MA type=Exponential
%D MA type=Exponential
Strategy:
Buy: When %K cuts %D upwards
Sell: Vice versa
even if it is little bit difficult to code, it is really worth to spend time on this.
Regards
Saranya.
Can you ask all coding related queries on http://tradingqna.com/ , do tag the language in which you want the code, AFL or tradescript.
Done.
Hi Nitin
I need code for back testing in Pi one upon SLOW-stochastic and FIRST-Stochastic when %k goes up and crosses 35 I want buy to BUY and when %d come down and breach 79 i want to sell and vice versa
another about
CAMARILLA i will enter the OHLC of my desired stock for any time frame and i need camarilla for both backtesting aswell as exper advice
Thanks in advance
Is it possible to code strategy based on Heiken Ashi calculations, HAOpen, HAHigh, HALow and HAClose and their moving average?
We can give it a shot, can you let me know the strategy.
Hello.
Nithin sir.
i wanted to code wen close first candle on any time fram for example 5min
first candle close at 6000 and second close above then its buy signel and if close below then sell
and it reapet when ever crossing above and below the price
thanx
br
tirumal
Buy:
(Ref(Close, 1) = 6000) and ((Ref(close, 1)) < close) Sell: (Ref(Close, 1) = 6000) and ((Ref(close, 1)) > close)
sir i mean every day first candle 5min or 15 min close what ever price is i need buy above and sell below on that price only
Dear Nitin,
what would be the code to get the high of the first three bars of the day, note these should be the first three bars of the day starting at 9:15 only, not any previous three bars incase time has elasped.
Pravin, this would not be possible presently. Do wait for a bit until our new platform is out.
Hello Nithin,
I want to be able to identify stocks based on the below criteria:
1. EMA crossover: 5EMA > 10EMA > 20EMA
2. 20-period Bollinger bands expansion where: current day’s(Upper band – Lower Band) > previous day’s(Upper band – Lower Band)
3. 12-26-9 MACD Histoogram where: current MACD > 0 and previous MACD <= 0
Also, I want only alerts to be generated, not actual trades.
Can you please let me know how to do these?
Thanks,
Siddharth
Sidharth, you need scanners for this and this is not available presently. Our new platform Pi will have this functionality.
When is Pi going to be launched?
Over 500 people testing it out, hopefully soon.
Dear Nitin,
what would be the code to get the high of the first three bars of the day, note these should be the first three bars of the day starting at 9:15 only not the previous three bars for any given time frame.
Nithin,
Where can I get a complete reference documentation of the Scripting language used?
Are you using the same in the new platform ?
There is a problem with the script entry form – The text boxes should be provided with Horizontal and vertical scrollbars (2) pressing “enter” button should actually go to the next line. Now it is doing something else.
Hope you can take care of the above.
Check this section.. Yes the new platform will have the same scripting language along with a bridge to AFL/Ninja/Python/C#.
Making a note of what you just commented.
Hi Nithin,
I tried coding a few strategy.
Here is the code
SET BLOW1 = BBB(CLOSE, 14, 2, SIMPLE)
SET BLOW2 = BLOW1 * 0.15 / 100
SET BLOW3 = BLOW2 * 1
SET BLOW4 = BLOW1 – BLOW3
SET M1 = MACD(13, 26, 9, SIMPLE)
SET MS1= MACDSIGNAL(13, 26, 9, SIMPLE)
(CLOSE MS1)
AND RSI(CLOSE,14) <30)
The problem is It just ignores the conditions 2nd and 3rd and executes the code on the first condition only ( in this case close MS1)
AND CLOSE<=BLOW4
AND RSI(CLOSE,14) ms1) ignoring the other 2
what could be the issue and how can this resolved?
suresh
Hello Mr. Nithin, How can I add to my strategy a code that is associate with the average volume of the first four candles, of the last five days??
Like, BUY if the volume is above the (average of the first 04 candles) of the (last five days)??
Thank you very much
I WROTE MY STRATEGY AND DOING THE BACKTEST. WHILE DOING SO, THE NEST SYSTEM GOES DOWN AND IT HAPPENS AGAIN AND AGAIN. I AM ALSO WRITING DOWN MY ALGO TO MAKE SURE THERE IS NOTHING WRONG IN WRITING. ————BUY EXPRESSION———-CLOSE>SMA(CLOSE,20) AND
(MAXOF(REF (HIGH, 4), REF (HIGH, 1))) CLOSE AND
CLOSE<SMA(CLOSE,20)
CROSSOVER ((SMA (SOPD (14, 3, 3, SIMPLE), 9)), (SOPD (14, 3, 3, SIMPLE)))————————PLEASE HELP….. SATYA
COULD YOU PLEASE POST HERE SOME SAMPLE CODES USING MACD HISTOGRAM–SO THAT I CAN USE IT IN MY STATERGY– I DID NOT GET ANY THING ON MACD HISTOGRAM CODING ANY WHERE. BASICALLY I WANT THE CODING FOR:
AT THE CLOSE OF THE CURRENT MACD HISTOGRAM BAR, IF IT IS INCREASED/DECREASED BY CERTAIN % IN COMPARISION TO ITS PREVIOUS BAR.
can we code to get alert at certain angles of the upper or lower bolinger band. for example i want alerts at 45 degree of upper bolinger band——————if yes, then please give one sample codde.
HI
CAN ANY BODY JUST REPLY ME QUICKLY ON THE FOLLOWING POINTS.
1. IN THE SCRIPTING LANGUAGE USED IN PI , I THINK IT IS NOT CASE AND SPACE SESITIVE—IS IT TRUE?
2. (crossover(EMA(CLOSE,3),EMA(CLOSE,5)) AND (crossover(EMA(CLOSE,5),EMA(CLOSE,3))————-IS THERE ANY LOGICAL DIFFERENCE BETWEEN THE TWO EXPRESSION AND IF YES—WHAT IS THAT?
—
Thanks & Regards
Santosh Padhy
1. It’s not case sensitive.
2. (crossover(EMA(CLOSE,3),EMA(CLOSE,5))) AND (crossover(EMA(CLOSE,5),EMA(CLOSE,3))) – in the first one if Ema of 3 bars crosses ema of 5 bars. Second defines if ema of 5 crosses ema of 3.
1.is it space sensitive?
2. so does it mean that
(crossover(EMA(CLOSE,3),EMA(CLOSE,5)))—means ema 3 cross ema 5 from below to up
(crossover(EMA(CLOSE,5),EMA(CLOSE,3))) —means that ema 3 cross ema 5 from up to below
1. Yes space sensitive
2. Yes
Hello Nithin, I have question based on following scenario which i have practically tested. After introducing the bracket order, trades are automatically getting (target)square off or stopped out (stop-loss) but signals are not getting generated properly. I have Buy and Sell expression in script but Buy Exit and Sell exit is 0. So once Buy alert is generated (Assuming I acted on it as Bracket order and that order completed with target Sell) on next script is waiting to generate the ONLY Sell signal and so on . In short ideally, If script sees consecutive BUY or SELL signals, it should be acted upon.
Ashish, how are you using bracket orders on algoZ/pulse?
I have Bracket Order enabled to put order based on automated signal generation.
Buy EITHER when price and small ema 25,OR ema,2,and ema,25 (both) make a crossover above 200 sma
Sell EITHER when price and small ema,25 OR ema2,and ema,25(both) make a crossover below 200 sma.
Pls code this 4 me………..
Buy:
View
(close > ema(close, 200) and ema(close, 25) > ema(close, 200)) or (ema(close, 2) > ema(close, 200) and ema(close, 25)