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.
Please provide the coding for the below conditions for AI trading in Zerodha Kite
Instrument – Nifty50 INDEX
Time frame – 15 min
Indicator – RSI – Length 14, Middle line – 50 (Upperlimit and Lower limit – Not required)
Capital – 5000 Indian Rupees
Trade to be executed only one time in a day.
When Market opens No action required for the first 15 minutes (ie., 9:15 AM to 9:30 AM)
After 11:30 (Closing of 11:15Am candle) – No trade to be executed for that day.
Entry Condition
If any one candle (from 9:45 AM to 11:30AM ie., second candle to 8th candle in 15m time frame) crosses Above 53 of RSI AND the Closing of that candle should be above the High of 1st candle (9:15AM) then Buy the ATM of Nifty 50 CE of Same Week Expiry (on Wednesday and Thursday Buy Next week Expiry ATM of Nifty 50 CE ).
OR
If any one candle (from 9:45 AM to 11:30AM ie., second candle to 8th candle in 15m time frame) crosses Below 47 RSI AND closing of that candle should be the Low of 1st candle (9:15AM) then Buy the ATM of Nifty 50 PE of Same Week Expiry (on Wednesday and Thursday Buy Next week Expiry ATM of Nifty 50 PE ).
Exit Condition
Once the Entry is made either in PE or CE as per the Entry condition then from the Entry candle in Options (CE or PE) the below to be checked and perform Exit.
If the current candle close is lower than the Previous Candle Low then Exit (OR) Exit at the close at 3:15PM (Closing of the 3:00PM candle).
No Trade condition
If any candle from second candle to 11:30 AM (Closing of 11:15AM) candle doesn’t cross RSI above 53 AND not closing above the High of 1st Candle (9:15AM) then no Trade to be executed.
If any candle from second candle to 11:30 AM (Closing of 11:15AM) candle doesn’t cross RSI below 47 AND not closing below the low of 1st Candle (9:15AM) then no Trade to be executed.
On the Holidays of the Stock Market or half day working day – No trade to be performed.
i want to create algo on Fibonacci pivot points but when i’m calculation Support 3 (S3) and Resistance 3 (R3) using below formula i’m not getting the exact value which i will see in your trading platform chart.
R3 = PP + (1*(HIGHprev – LOWprev))
S3 = PP – (1*(HIGHprev – LOWprev))
Could you please suggest what is the exact formula to calculate R3 & S3
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:
(close > ema(close, 200) and ema(close, 25) > ema(close, 200)) or (ema(close, 2) > ema(close, 200) and ema(close, 25)
How can we code the following ,PLS GIVE ME CORRECT CODE.
BUY WHEN PRICE OR EMA 2 AND EMA,25 (both).CROSSOVER SMA 200
SELL WHEN PRICE OR EMA 2 AND EMA 25(both) CROSSOVER SMA200–The question is sometimes the EMA ,25 make a crossover above 200 sma,the price and 5EMA will be below 200SMA and viceversa,pls clarify.
Hallo Nithin
For NEST PULSE ALGOS CODE SMA EMA MACD STOCHASTICE INDICATORS
ON CROSS OVER BUY SELL SIGNAL IMMEDIATE CANDILE WITH OUT ON CANDLE COMLPETION How To Convert
Rajesh, it will be possible only on candle completion.
Hallo Nithin How To Convert This Stochastics
periods = Param( “Periods”, 10, 1, 200, 1 );
Ksmooth = Param( “%K avg”, 3, 1, 200, 1 );
Dsmooth = Param( “%D avg”, 3, 1, 200, 1 );
Ks = StochK( periods , Ksmooth);
KsDs = StochD( periods , Ksmooth, DSmooth );
Buy = Cross(Ks,KsDs);
Sell = Cross(KsDs,Ks);
Short = Sell;
Cover = Buy;
For NEST PULSE ALGOS CODE
ON CROSS OVER IMMEDIATE CANDILE WITH OUT ON CANDLE COMLPETION
periods = Param( “Periods”, 10, 1, 200, 1 );
Ksmooth = Param( “%K avg”, 3, 1, 200, 1 );
Dsmooth = Param( “%D avg”, 3, 1, 200, 1 );
Ks = StochK( periods , Ksmooth);
KsDs = StochD( periods , Ksmooth, DSmooth );
Buy = Cross(Ks,KsDs);
Sell = Cross(KsDs,Ks);
Short = Sell;
Cover = Buy;
For NEST PULSE ALGOS CODE
ON CROSS OVER IMMEDIATE CANDILE WITH OUT ON CANDLE COMLPETION
Can I USE This code strategy CROSS OVER IMMEDIATE CANDILE WITH OUT ON CANDLE COMLPETION NO ZERODHA PI ?
I have BB(2 SD) , MACD (26,12,9), SSTO(14,3) formula. I need to code the following idea into AlgoZ. Please guide.
BB(2 SD) , MACD (26,12,9), SSTO(14,3) formula
BUY ALERT:
if Lower BB(CLOSE,50) > any CLOSE in last 9 periods
AND MACD(26,12,9) histogram > 0
AND D%*1.05CLOSE
OR D%*1.05>K%
OR MACD(26,12,9) histogram < 0
Few logics need more information:
BB(2 SD)
SSTO
(BBB(CLOSE, 20, 2, EXPONENTIAL) > Close)
Considered current close/ ltp.
MACD Histogram: (((MACD(12, 26, 9, SIMPLE)) – (MACDSignal(12, 26, 9, SIMPLE))) > 0)
(SOPK(9, 3, 9, SIMPLE) > ((SOPD(9, 3, 9, SIMPLE)) * 1.05))
D%*1.05CLOSE – Modified this a bit
(SOPK(9, 3, 9, SIMPLE) < ((SOPD(9, 3, 9, SIMPLE)) * 1.05)) MACD Histogram: (((MACD(12, 26, 9, SIMPLE)) – (MACDSignal(12, 26, 9, SIMPLE))) < 0) Please use AND, OR to club indicators.
Thank you Mr. Nithin for reply.
I want to calculate BB(with 2 standard deviations) and Slow Stoch with 14 periods and smoothing of 3 periods. My idea is when BBB gets penetrated in any of the preceding 9 periods (can be modified a bit) and then when MACD histogram gets above zero, a buy signal shall be generated. For sell signal it will be the opposite.
Mr. Nithin;
While back testing above Algoz,I am getting “undefined function” error. In second Algo with Ref function, I am getting “Argument of function “REF” not optional” error. How can I address this??
Mr. Nithin,
I have applied the formula in the engine to run. I have encountered an issue of invalid “REF” argument, I am re-writing the formula for your review. —— buy alert —BBB(CLOSE,50,2,SIMPLE)*0.98>CLOSE AND (((MACD(12,26,9,SIMPLE))-(MACDSIGNAL(12,26,9,SIMPLE))>0 AND SOPK(14,3,4,SIMPLE)>SOPD(14,3,4,SIMPLE) AND REF(SOPK(14,3,4,SIMPLE),2)>30 —–Sell Exit —–CLOSE*0.98>BBT(CLOSE,50,2,SIMPLE) OR CLOSE<SMA(CLOSE,50) AND SOPK(14,3,4,SIMPLE)REF(SOPD(14,3,4,SIMPLE),2) AND SOPD(14,3,4,SIMPLE)<70 ———-buy exit and sell alert will be "0"——– please guide.
Dear Nitin
I am using PSAR. Once the PSAR signal is there, it should check next 5 candles and if the close is max of the 5 candles after PSAR signals , it should give a buy signal. Please help me to write the code
(Ref(PSAR(CLOSE, 0.02, 0.2)), 6) and (MAXOF(REF(close, 1), REF(close, 2), REF(close, 3), REF(close, 4), REF(close, 5))) > close
do backtest before going live.
@Nitin Ji,
Thank You.
Julius does this strategy work?
My previous Messages having type err
If possible please give me the coding to backtest this
BUY Rule : 1 Point > Highest Price of Last 20 Candles
SELL Rule : 1 Point < Lowest Price of Last 20 Candles
Buy Exit : 1 Point Highest Price of Last 10 candles
(MAXOF(REF(LOW, 1), REF(LOW, 2), REF(LOW, 3), REF(LOW, 4), REF(LOW, 5), REF(LOW, 6), REF(LOW, 7))) > close
Need to extend this till 10 or 20 based on the requirement.
Already saw the Video of Pi. Eagerly waiting for same. However about the current issue, I do have snapshot of Tata Motors where is largest loss is shown as 7757.7. And if you examine the backtest results, latest long signal is given on 6th Sep (Saturday) at 8306.2. I can share the same if needed.
can you send this out as an email to [email protected]
Hello Nithin, Am facing problems with backtesting of my Strategies. It gives pretty inaccurate results more probably because it considers closing/opening value of the Stock/ Futures as 0. I often get results where in largest Profit/Loss in Nifty is 8000+ which we know is not possible. I tried applying different strategies and on different stocks. But the results are same not always but more then often. This is making me wonder about the accuracy of the backtest results. Is it technical error only on my end or is known issue with Nest Trader? How accurate are the backtest results as per your knowledge?
Shouldn’t happen Aquif, but let me have this checked. Also we are about to launch Pi which can do a lot more in terms of scripting. Check it out.
BUY Rule : Close > Highest Price of Last 20 Candles
SELL Rule : Close < Lowest Price of Last 20 Candles
Buy Exit : Close < Lowest Price of Last 10 candles
Sell Exit : Close < Highest Price of Last 10 candles
If possible Provide Script for this conditions.
Thanks in Advance.
Sir, Can I get code to backtest donchian channel/Turtle system?
BUY Rule : Close > Highest Price of Last 20 Candles
SELL Rule : Close < Lowest Price of Last 20 Candles
Buy Exit : Close Highest Price of Last 10 candles
Dear Sir can U Suggest Low Whipsaw Positional Stragedy?
Hello Nithin Sir _ZigZag
BUY
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) 0, 1, Null),1);
SELL
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1, Null),1);
How To code my strategy:
Hello Nithin,What is the code for creating a backtesting based on RSI,Suppose for Reliance I want to do backtesting based on RSI such that It should give buy signal when RSI is less than 30 and Sell Signal when RSI is >70. Can you please suggest me the coding for this strategy
Deepak, this is already coded in the queries above. You can search by RSI
Please Help to code my strategy:
Buy Signal:
Condition 1: Previous Candle Close > 34 Ema
Condition 2: Previous Candle Close > PSAR
Condition 3: Initiate buy 2 points higher than highest high of last 7 candles
Buy Exit Signal : MACD (12,9,26) Negative crossover at close (Avg Period 12 EMA, Short Period 9 EMA, Long Period 26 EMA)
For Sale: Exact opposite of buy
Buy:
Ref(close, 1) > ema(close, 34)
Ref(close, 1) > (PSAR(CLOSE, 0.02, 0.2))
(Close + 2) = (MAXOF(REF(HIGH, 1), REF(HIGH, 2), REF(HIGH, 3), REF(HIGH, 4), REF(HIGH, 5), REF(HIGH, 6), REF(HIGH, 7)))
Buy Exit:
Negative crossover at close – please provide more details.
Sell:
Ref(close, 1) < ema(close, 34) Ref(close, 1) < (PSAR(CLOSE, 0.02, 0.2)) (Close - 2) = (MAXOF(REF(HIGH, 1), REF(HIGH, 2), REF(HIGH, 3), REF(HIGH, 4), REF(HIGH, 5), REF(HIGH, 6), REF(HIGH, 7)))
When enter and backest, it does not generate any signal
Can you send an email to [email protected], he will check if you are enabled for this or not.
For Closing the trade, MACD short period line crosses long period line
Hi Coding team,
Could you please help me out to code the below?
Thank you in advance.
Rajendra
Zerodha Client
Generate sell signal if all the below conditions are met.
1. When RSI (14) is at 80
2. When 15 min candle is above top bollinger band (20,2) EMA
3. When Fast MACD line is far above the slow/Signal MACD line (26,12,9)
Hi Nithin/Coding team
Could you please help me out to code the below?
Thank you in advance.
Rajendra
Zerodha Client
Generate sell signal if all the below conditions are met.
1. When RSI (14) is at 80
2. When 15 min candle is above top bollinger band (20,2) EMA
3. When Fast MACD line is far above the slow/Signal MACD line (26,12,9)
Exit Sell
1. When RSI (14) is at 75
2. When 15 min candle is below top bollinger band (20,2) EMA
Hello Nithin, I need a strategy that don’t buy if the target is beyond the max of the day, like I have a target of 100 points but i avoid the entrance if the maximum of the day is less than 100 points of the entrance, at 5 minutes.
You have to be a little more clear about this, Can you clearly define when you want to enter and when you want to exit?
Sure Nithin sorry about that. I already have a strategy… and I just need only to add in my strategy a condition to prevent entry if the target is above the high of the day (IF BUY) or below the minimum of the day (IF SELL). My strategy is at 5 minutes candles.
HighestHighValue(Periods). HHV(Periods)
HIGH = HHV(21)
LOW = LLV(21)
How can I change the 21 periods to all the periods of the intraday 5 minutes candle?
HHV:
((MAXOF(REF(HIGH, 2), REF(HIGH, 3))) > CLOSE)
To find out hhv or llv, Maxof and Minof can be used. To consider the candles, use Ref 1, ref 2 and so on ……
· How can I change the 21: Ref 1 … Ref 21 needs to be used, current candle will be ignored.
tv sreelatha rs 3414
helo sir,
i wish to have if you develop a algo base system based on the following details,
1) period (variable)
2) when the 5 EMA line goes up a certain value (variable, which i must be able to change) units from the crossing of 5 and 14 ema, BUY immediately AND EXIT AT THE END OF THE PERIOD.)(close of the candle)
3) when the 5 EMA line goes down a certain value (variable)from the crossing of 5 and 14 EMA line, SELL immediately AND EXIT AT THE END OF THE PERIOD.(close of the candle)
Sreelatha, this is a simple moving average crossover strategy, has been mentioned a bunch of times above.
thanks for the guidence
can you give the code for exit at a certain candle(Variable) once we enter the trade,no addtional conditions like macd etc
Exit also has to be a code.
Dear Nithin,
I use EMA 15 and EMA 25.
I have written Strategy 1/ Script 1 as follows :
Buy Expression : CROSSOVER(EMA(CLOSE, 15), EMA(CLOSE, 25))
Sell Expression : CROSSOVER(EMA(CLOSE, 25), EMA(CLOSE, 15))
Strategy 2 / Script 2 is as follows :
Buy Expression : EMA(CLOSE,15) > EMA(CLOSE,25)
Sell Expression : EMA(CLOSE,15) < EMA(CLOSE,25)
I was surprised to see both giving different results
when backetsted (on any Symbol / Instrument).
IF Both Code means same and are correct
why it gives different results ?
Pl. Help
Thanks in Advance
———————————-
Also suggest Buy and Sell Expression
for following :
Buy When Green Candle Breaks / Crosses EMA 20 and PSAR is below EMA20
Sell When Red Candle Breaks / Crosses EMA 20 and PSAR is above EMA20
Thanks in Advance
1. Both shoul work in the same way. Can you send an email to [email protected], he will try reinstalling the pulse dll.
2. Buy When Green Candle Breaks / Crosses EMA 20 and PSAR is below EMA20
Sell When Red Candle Breaks / Crosses EMA 20 and PSAR is above EMA20
– (Close > open) and (close > ema(Close, 20)) and (Ema(close, 20) > (PSAR(CLOSE, 0.02, 0.2)))
– (Close < open) and (close > ema(Close, 20)) and (Ema(close, 20) < (PSAR(CLOSE, 0.02, 0.2)))
Dear Zerodha / Nithin,
I have recently opened account with zerodha.
ID : RK0827
Can u pl. add SuperTrend Indicator ?
How can I save Layout in ZTrader.
Kamlesh, supertrend can’t be added on ZT, but wait for a few days we are launching our new platform “Pi” which will have advanced coding/backtesting strategies.
i have idea
in zerodha ADX IN 15 MIN AND AVERAGE PERIOD IS 1 THEN HOW TO PLACE BUY NAD SELL IN ALGOZ
Can someone please share successfull back tested strategies for Equity day trading?
ok thanks Nithin
Hi,
Is it possible to write a code in Nest pulse to check if there is any stock/s trading above 200 dma?
Regards
Rajendra
There are no scanners presently on NEST
You are doin a nice work.thanks.please can you help me code this:
CCi(20,close) crosses above zero line,open buy and when cci(14,close) crosses below zero line,open sell.
when cci(20,typical price) crosses above zero line,close sell.when cci(20,typical price) opens below zero line,close buy.
Hi Nithin,
Sorry for the long read. Please read carefully 🙂
My algo is like this..
Buy:some expression
Buy exit:0
Sell:some expression
Sell exit:0
So the algo generates alternate buy and sell signals
alone.
Once a buy signal occurs, and pressing “act on call”,
a buy order would be placed right.
After some time, a sell signal occurs.
Now, as per algo logic, two sell orders should be
placed.
1)A sell order which closes the current position.
2)A second sell order to initiate a short position.
Here are my questions:
1)Will two such sell orders be placed if I take my
algo live?
2)On backtesting, I get results mentioning total no.
of trades etc etc…does this include the 2 orders
being placed for every successive signal/call?
1. You will have to place the 2 sell orders separately.
2. Yes the results are based assuming that you will exit and enter a fresh short when the sell indicator is shown.
1)You mean I have to manually enter one of the sell orders?
2) Got it ! 🙂
1. Yes, You will get 2 sell alerts, and you will have to enter this separately.
if specific candle pattern is not possible right now , pls code rest of strategy of mine…………ma crossover + stch+ rsi+ camrilla
and + vol also
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
Don’t think it is possible in the way u have written, will need a lot more specifics for this. What I’d suggest is to run through basic codes and examples in this page, and then give it a shot yourself. If you are having trouble then, you can post your queries here.
Nithin,
Error message is “BackTest Script Error:Error:Scripts generated no trades” and it occurs when I backtested.
Hi Nithin,
Could you please code the below strategy?
Please let me know in case of additional information is required.
Thank you in advance.
Buy strategy
When RSI (14) is at 28 coming from lower levels and candle rising from lower levels of the bottom bollinger band (20,2)
Buy exit
When the RSI (14) is at 33 and close of the candle at above the bottom bollinger band (20,2)
Regards
Rajendra
((Ref(Rsi(close, 14), 1)) < 28) and ((Rsi(close, 14)) = 28) (Rsi(close, 14) = 33) and ((BBB(CLOSE, 20, 2, EXPONENTIAL)) < close)
Hi Nithin,
I am unable to run the above given script due to error.
I think it is due to the below missing information.
“It is for 15 min candle”.
Regards
Rajendra
Can someone from coding team help me out in coding the above strategy?
Can you put up sequence of the error?
The error occurs when taken live or back tested?
dear Nithin, kindly help me with this to put in algoz :- UPTREND RULES:
Stochastic %D (14,3) > 50
RSI (7) > 50
MACD > Zero Line > Signal Line (9 period)
DOWNTREND RULES:
Stochastic D (14, 3) < 50
RSI (7) < 50
MACD < Zero Line < Signal Line (9 period)
Also if u can suggest a great for buy exit and sell exit
and when going live there is an option call stoploss in % , the stoploss % is suppose buy stock of rs 545 and keep stop of 1% then the stop loss will get triggered at 539.60? irrespective of the quantity i have bought? or stop loss is based on 1 % total value of holdings?
sorry typing errors correction -this simple strategy can u code for me, I am also zerodha client
BUY-when RSI(14) goes below 30 and rises above 35 then buy with stoploss of RSI(14) 60
SELL-when RSI(14) goes above 70 and then comes to 65
SELL STOPLOSS- RSI(14)>75
SELL EXIT-RSI(14)<40
Hey newbie, this is already coded, can you do a ctrl+F and search for RSI, you will see all codes that involve RSI
hi,
I have a strategy ready with me. What do I put in my code so that NEST plugin catches my buy/sell and short/cover orders and how do i put it in my code?
Can u please forward my mail to stratagy coder of your team:
I have 2 strategies, both are very simple but as a novoice, I can’t code it:
1) Based on 5SMA System:
SAR = Mean value of Previous 4 Days Close
Buy if 5 Min Candle Close Price goes above SAR value from below (Entry with 5 Lots)
Sell if 5 Min Candle Close Price goes Below SAR Value from above (Entry with 5 Lots)
Target : 50 Points from SAR value (for 2 Lots)
75 Points from SAR value (for 1 Lot)
100 Points from SAR value (for 1 Lot)
Till Sell Signal Arise (Fore 1 Lot)
SL @ 25 Points from SAR Value in Opposite direction
2) Based on 3 day High Low Strategy (Breakout Strategy)
Buy if 5 Min Candle Close Price goes above High of Previous 3 Days, SL @ Lowest of the low of 2 Days
Sell if 5 Min Candle Close Price goes below low of Previous 3 Days, SL @ Highestt of the High of 2 Days
Targets: 50 Points from Entry
Manas,
The targets can’t be kept as number of points, it has to be a strategy itself. Can you define that?
Ok, I will work on it. But if possible, give me code for buy and sell signals and if possible stoploss , will work on strategy to close the trade.
Buy Exit signal in Strategy 1 is Close in 5 min Candle is Below 5EMA and vice a versa for sell exit signal.
Hi Nitin,
Saw ur video on young turks..which brought me to this website.. theres some awesome stuff on ur website..I am a active trader can you tell us few algos that gives consistent results?
Thanks Rohit, hmm.. presently we are just helping people code if there is any strategy, we are soon launching an initiative that will also including sharing backtested strategies.
Hi Nithin,
great effort by you and your team.
want to code a strategy for bollinger bands volatility breakout in conjunction with MACD Crossover.
Settings:
Bollinger Bands : 20, 2
MACD : 12, 26,9 EMA period
The upper band and lower band tighten around the price.
When the bands expand and break up on the upper band with MACD signal line crossing up then BUY.
Similarly when the bands breakdown on the lower band with MACD signal line crossing below then Sell.
Stop Loss : low of the previous candle.
Exit : when the price falls when long and rises when short by 5 points of the last close.
Thanks.
(CLOSE > BBT(CLOSE, 20, 2, EXPONENTIAL))
(CLOSE > BBB(CLOSE, 20, 2, EXPONENTIAL))
(MACDSignal(13, 26, 9, EXPONENTIAL))
(MACD(13, 26, 9, EXPONENTIAL))
The upper band and lower band tighten around the price.
· Please define this more.
Buy:
(BBT(CLOSE, 20, 2, EXPONENTIAL)) > (BBB(CLOSE, 20, 2, EXPONENTIAL)) and (MACDSignal(13, 26, 9, EXPONENTIAL)) > (MACD(13, 26, 9, EXPONENTIAL))
Sell:
(BBT(CLOSE, 20, 2, EXPONENTIAL)) < (BBB(CLOSE, 20, 2, EXPONENTIAL)) and (MACDSignal(13, 26, 9, EXPONENTIAL)) < (MACD(13, 26, 9, EXPONENTIAL)) Sl: (Close = Ref(Low, 1)) Exit: (Close + 5) > (Ref(Close, 1))
· The stop loss cannot be exactly define in expression window, instead, cover order can be used when going live.
· Sell logic is not clear to code. Please elaborate more.
HI Nithin, Is there any limit on scripts you can go live, I mean I am planning to implement my strategy on all futures script is it possible…..?????
It would have to do with your system’s computational speed, but in the present system you can’t really take more than 5 to 6 charts live at one time and hence can’t run strategies on more than 6 scrips at a time. Our new platform Pi will give you a lot more flexibility here, we should be launching this soon.
what is additional cost involved to trade using AlgoZ (apart from account opening with zerodha)
It is free of cost
hi sir,
how to fully automate my trades and what are the required approvals ?
Sruthi, explained here: zerodha.com/z-connect/charting-coding-and-backtesting/automation/automating-trades-getting-started
Hello Nithin,
Would like to know how to set up the Greek Market Watch settings in Nest Trader?
The Market Watch Greek settings can be setup by the following method:
1. Press Ctrl + P and go to Preferences > Market Watch. Select the tick box which says “Greeks in Market Watch”
2. Right click on any Option scrip and choose Option Greeks > Make Greek Settings.
3. Set it up and choose Reflect to All.
This works inconsistently and I’d rather you use the Option Calculator to calculate Greeks.
Hi.
There is something terribly wrong with the backtesting engine.
I have the following rule for buy
set T = close-open
set solid = if(T>0,T,-T)
set shadow = high – low
set color = if(T>0,1,-1)
shadow>5*solid AND REf(color,1)=-1 AND REF(SOLID,1)>3*SOLID AND RSI(CLOSE,9)50
Please suggest some solution urgently as it is impossible to trade based on such faulty system.
Hi,
For backtesting purpose , I am not sure when exactly the buy signal gets triggered based on a condition.
to elaborate lets say I have a strategy buy when ‘close>open’. This signal will be true at any day end. So will the buy signal come at next day’s open.
I ask this becoz I can see a backtest result where long positions are being made at close price of a day
on the same line,
lets say I have a strategy where I buy if previous day is doji, the day before that is not a doji and a red bar
set T = close-open
set solid = if(T>0,T,-T)
set shadow = high – low
set color = if(T>0,1,-1)
shadow>5*solid AND REf(color,1)=-1 AND REF(SOLID,1)>3*SOLID
Does the code above serves the purpose?
Hello Nithin,
I know that my question will be general, but which strategy in your opnion are good for DAYTRADE, and which are the best signs for entree and exit.
Hi, When i write a code having 2 conditions, trade gets executed only by the 1st condition.
Eg. Buy : Crossover (SMA(Close,5),(Close,20)) AND Crossover (SOPK(14,3,3),SOPD(14,3,3))
Backtest results show trade done only for the 1st condition. whatever code i use for the 2nd part, it just gets ignored.
Plz help. I simply need SMA Crossover with Stochastic confirmations. Thanks
((Sma(Close, 5)) > (Sma(Close, 20))) and ((SOPK(14, 3, 3, SIMPLE)) > (SOPD(14, 3, 3, SIMPLE))) , can you try this
Hello Nithin,
Just one query..Why can’t Zerodha provide simulated trading for Equity/ Futures & Options. This facility is not provided by none of the broking firms in India, but its provided by most of the foreign broking firms. I would like to bring to your notice to introduce this facility so that it will be of great use for all the traders both beginners and experts to practice their trading skills in real time markets. This will enable them to learn from their errs and thus leading them to professional traders.Even though the NSE has come up with NSE pathshala with its simulated environment but its has a junk of errs which i don’t recommend to anybody at all. Just would love to get an ans from Nithin.
Yep, on the list of things to be done at Zerodha.
Is it possible to code this one?
Enter Long when 3 EMA goes above 15 High EMA
Enter Short when 3 EMA goes below 15 low EMA
Long: (Ema(Close, 3)) > (Ema(High, 15))
Short:(Ema(Close, 3)) < (Ema(Low, 15))
LONG RULE: CANDLE CLOSING BASIS 12 EMA SHOULD CROSSOVER ABOVE 34 EMA, RSI > 50, STOCHA > 50
SHORT RULE: CANDLE CLOSING BASIS 12 EMA SHOULD CROSSOVER BELOW 34 EMA, RSI < 50, STOCHA < 50
Long:
(Ema(Close, 12)) > (Ema(Close, 34)) and ((RSI(Close, 14)) > (50))
Short: (Ema(Close, 12)) < (Ema(Close, 34)) and ((RSI(Close, 14)) < (50)) Stochastic Oscillator: to the above you can use an "AND" to add SOPK(9, 3, 9, SIMPLE) > 80 OR SOPD(9, 3, 9, SIMPLE) > 80
Hi, how do I code for the following strategy for Bank Nifty? (or for that matter Nifty or any equity / future)
– Buy if it crosses high of the previous day.
– Sell if it goes below low of the previous day.
– Assume an average range of 2% daily, have a stop loss of 0.16*2% around 40 points for both buy and sell.
– Target of 150 points for intra day for square off or at stop loss or at rate at closing for the day.
I have it in an excel sheet. Can mail it to you if needed if it helps to code the same.
Long: DHigh(2) < Close Sell: DLow(2) > Close
Here you will have to keep SL or target as a technical analysis condition, you can’t say Buy + points or Sell+ points
Hi
Range charts are very popular in the west.
We do not seem to be focussing on it.
Request you to put some views on the same for the benefit of all from the point of coding and testing and other benefits if any in comparison to other chart types.
Can we code our strategies here in range ?
Thanks
Chintamani
Hi Nithin,
I am trying to code this strategy, but i don’t know what part of it is wrong. Can you please find the mistake,
It is for Bullish markets:-
Buy- The price must be greater than 50 EMA, new crossover of 3 EMA over 5 EMA.
Buy Exit- Crossover of 3 EMA under 5 EMA.
Code:-
Buy-CLOSE>EMA(Close,50) AND CROSSOVER(EMA(CLOSE, 3),EMA(CLOSE, 5))
Buy Exit-CROSSOVER(EMA(CLOSE, 5), EMA(CLOSE, 3))
Sell-0
Sell Exit-0
Thanks
Buy:
(CLOSE > (EMA(Close,50))) AND CROSSOVER(EMA(CLOSE, 3),EMA(CLOSE, 5))
Sell:
CROSSOVER(EMA(CLOSE, 5), EMA(CLOSE, 3))
Hello Nithin,
I have developed strategies as Expert Advisors in MT4(meta trader) for forex markets .Will zerodha in the future support multiple terminals like other international brokers provide and if so will you consider metatrader 4. Zerodha’s platform is great when compared with other Indian terminals, but I am not getting the flexibility as I get in MT4.
We hopefully will surprise you on it very soon…
hi nitin
could you program my strategy
Buy=EMA(C,13)>EMA(EMA(C,13),9) AND Cross (C,Peak(C,2,1));
BuyHi Could you help me code this strategy for intra stock trade?
1) 5 Min EMA slopes upwards
2) MACD gives a bullish crossover
3) 5 EMA should be abve 20 EMA line
4) 5 min candle closes above 20 EMA line
5) Stochastics between 20 and 80 [%K Period 5, %K Slowing 3, %D Period 3]
6) Stochastics %K Crosses above %D
7) Target 20 points, SL 10 points , TSL 10 points
8) Close Trade if Stochastics %K Crosses below %D
Sell
1) 5 Min EMA slopes downwards
2) MACD gives a bearish crossover
3) 5 EMA should be below 20 EMA line
4) 5 min candle closes below 20 EMA line
5) Stochastics between 20 and 80 [%K Period 5, %K Slowing 3, %D Period 3]
6) Stochastics %K Crosses below %D
7) Target 20 points, SL 10 points , TSL 10 points
8) Close Trade if Stochastics %K Crosses above %D
Can you define what is slopes upwards/downwards? can you also tell how many candle MACD?
all 5 minute candles.
I don’t have the technical knowledge to explain slope. What I meant was if the slope is +ve it is upwards and -ve for downwards.
If my query is still not clear, then modify it such that 5 min candle > 20 min EMA instead of Slope upward
And where i mentioned downward, put 5 min EMA<20 min EMA
Buy:
1) 5 Min EMA slopes upwards
(Trend(Ema(close, 14))) = up
2) MACD gives a bullish crossover
((Trend(MACDSignal(13, 26, 9, SIMPLE))) = up) and ((Trend(MACD(13, 26, 9, SIMPLE))) = Up)
3) 5 EMA should be abve 20 EMA line
Ema(close, 5) > Ema(Close, 20)
4) 5 min candle closes above 20 EMA line
Close > Ema(Close, 20)
5) Stochastics between 20 and 80 [%K Period 5, %K Slowing 3, %D Period 3]
SOPK(9, 3, 9, SIMPLE) > 80 OR SOPD(9, 3, 9, SIMPLE) > 80
– Please modify accordingly.
6) Stochastics %K Crosses above %D
(SOPK(9, 3, 9, SIMPLE)) > (SOPD(9, 3, 9, SIMPLE))
7) Target 20 points, SL 10 points , TSL 10 points
– Please check If you have bracket order feature.
8) Close Trade if Stochastics %K Crosses below %D
(SOPK(9, 3, 9, SIMPLE)) < (SOPD(9, 3, 9, SIMPLE)) Sell: Please modify the above one based on the sell logic. Backtest and analyze before going live
I want a code for Trading NF in BO
Buy
1) 5 Min EMA slopes upwards
2) MACD gives a bullish crossover
3) 5 EMA should be abve 20 EMA line
4) 5 min candle closes above 20 EMA line
5) Stochastics between 20 and 80 [%K Period 5, %K Slowing 3, %D Period 3]
6) Stochastics %K Crosses above %D
7) Target 20 points, SL 10 points , TSL 10 points
8) Close Trade if Stochastics %K Crosses below %D
Sell
1) 5 Min EMA slopes downwards
2) MACD gives a bearish crossover
3) 5 EMA should be below 20 EMA line
4) 5 min candle closes below 20 EMA line
5) Stochastics between 20 and 80 [%K Period 5, %K Slowing 3, %D Period 3]
6) Stochastics %K Crosses below %D
7) Target 20 points, SL 10 points , TSL 10 points
8) Close Trade if Stochastics %K Crosses above %D
Can we use algoZ for trading NF in Bracket order?
Not presently
I m desirous to code my strategy……how to do that pls help
Do post your strategy here, we will code that for you.
I understand pivot as the center point, for coding pivot high is: the previous candle(n-1) is higher than the present candle(n) then we check if (n-2)candle is higher than (n-1)candle, likewise we keep on checking until we get a condition where the (n-3) is higher than (n-4) candle then the high of the n-3 candles high is considered as our pivot high.
can you publish function signature of all the indicators available in algoz?
Hi Nithin,
How should I write the code to generate a buy signal when previous pivot high is taken out by present price.(not previous candle, I want for previous pivot high).
Can you define how you calculate the pivot high
Hello Zerodha,
I have problems with the backtesting. My buy expression and buy exit expression both have two conditions.
When backtesting I see only the first condition is satisfied in the triggered orders.
My Buy expression is:
SET SMA25 = SMA(CLOSE, 25)
SET SMA50 = SMA(CLOSE, 50)
SET C1 = CLOSE > SMA25
SET C2 = SMA25 < SMA50
C1 AND C2
My Buy-Exit expression is:
SET SMA25 = SMA(CLOSE, 25)
SET SMA50 = SMA(CLOSE, 50)
SET C1 = CLOSE SMA50
C1 AND C2
If I interchange the conditions (i.e. C2 AND C1) then only C2 is satisfied in the resulted orders.
I tried with other conditions (OR, XOR). The second condition is not at all used.
Is the backtesting broken? I have not tested in LIVE. Will LIVE also have the same problems?
BTW; I am running ZT 3.11 and Nest plugin 2.8.
Thanks,
Kars.
Correction:
My Buy expression is:
SET SMA25 = SMA(CLOSE, 25)
SET SMA50 = SMA(CLOSE, 50)
SET C1 = CLOSE > SMA50
SET C2 = SMA25 < SMA50
C1 AND C2
My Buy-Exit expression is:
SET SMA25 = SMA(CLOSE, 25)
SET SMA50 = SMA(CLOSE, 50)
SET C1 = CLOSE SMA50
C1 AND C2
CRAP!!!
I removed zt and nest-plus installs completly. Then installed only the 3.11 zerodha trader and not the plugin. Now the backtest is fine.
If the backtest had time limits, square off at 3.20, and if it tested both shorting and buy exiting at the same candle, I will be really, really happy.
The software we (retail traders) got stuck with in india seems to be deliberately designed to play psychological games and push us to lose money. 🙁 Good thing is, with Zerodha, we are getting much better… 🙂
Thanks,
Kars.
Hi,
I am also facing similar issues with backtesting. It is omitting certain conditions.
I read your suggestions and need some clarification.
If i uninstall both ZT and the Nest Pulse plugin and the reinstall ZT will I get the plugin options . If not , then how will we write the strategies.
You should be able to get it, can you shoot an email to [email protected], he will help you out with this.
Thank You Nithin will do so.
Hello Nithin,
Do you help coding for the Amibroker? In that case i have some idea which need to be coded.
With Regards,
K.S.Joseph.
94972-82865
Joseph,
You can speak to the guys at Global Data feeds, they might help you out.
Cheers,
Joseph, You can put your query here : http://tradingqna.com/ there are a bunch of guys on the forum who know how to code using AFL.
Cheers,
Hi Nitin,
Can we code this thing for Buy condition.
Buy if cloe is > Close at 9:45am
i will be very greatful if i can get the code for this.
thanking u in advance.
Rohit,
Presently this won’t be possible as there is no time function, but our new platform should allow you to do it.
Hello Nithin,
I have been using your NestTrader trading platform for over 3 months. Since I’m not able to open 3 ID’s live account at the same time in the NestTrader only one of the account i open through your Z5 web trading portal. While using the Z5 i have noticed the following big errors which i would kindly like to share with you all.
1. Live spot rate of Nifty and Sensex are totally incorrect.
2. Not able to save the Market Watch Settings.
3. A facility should be added to increase the font size of the market watch. Right now the alphabets are very small which keep strain on the eyes.
I hope you will look to the above issue and get it solved at the earliest.
Thanking You,
With Regards,
K.S.Joseph
94972-82865.
Varun
Try this:
BUY:rsi(close,14)>80 AND (MACD(13, 26, 9,EXPONENTIAL) > MACDSignal(13,26, 9, EXPONENTIAL))
Buy exit alert : (MACD(13, 26, 9,EXPONENTIAL) < MACDSignal(13,26, 9, EXPONENTIAL))
I have tested it , and it works.
Hi milind
In algoz to access previous bars we use ref(vector,period) and the periods are positive unlike amibroker.
For cci you also have to mention type of moving average cci(periods,MAtype)
So your code will be
buy : CLOSE>REF(SMA(HIGH,6),4) AND CCI(35,simple)>35
sell : CLOSE<REF(SMA(LOW,6),4) AND CCI(35,simple)<35
I have backtested the strategy and my observation is that AND operation is not happening (intentionally taken high RSI to check the backtest) :
Buy alert : (MACD(13, 26, 9,EXPONENTIAL) > MACDSignal(13,26, 9, EXPONENTIAL)) AND (Rsi(Close, 14) > 80)
Buy exit alert : (MACD(13, 26, 9,EXPONENTIAL) < MACDSignal(13,26, 9, EXPONENTIAL))
Please let me know, if anything wrong with expression ???
displaced moving average indicator is there in nesttrader ?
No
I have written code for buy and sell
buy : CLOSE>REF(SMA(HIGH,6),-4) AND CCI(35)>35
sell : CLOSE<REF(SMA(LOW,6),-4) AND CCI(35)<35
is this code correct in nesttrader language ?
I have written code for buy and sell
buy : CLOSE>REF(SMA(HIGH,6),-4) AND CCI(35)>35
sell : CLOSE35
is this code correct in nesttrader language ?
I have backtested the strategy and my observation is that AND operation is not happening (intentionally taken high RSI to check the backtest) :
Buy alert : (MACD(13, 26, 9,EXPONENTIAL) > MACDSignal(13,26, 9, EXPONENTIAL)) AND (Rsi(Close, 14) > 80)
Buy exit alert : (MACD(13, 26, 9,EXPONENTIAL) < MACDSignal(13,26, 9, EXPONENTIAL))
Please let me know, if anything wrong with expression ???
hi soumyajit
You need to confirm whether you want crossover or greater, because both functions work differently. I think you want to use crossover. To understand this further you can go to the following link:
http://tradingqna.com/293/difference-between-crossover-functions-automated-trading
So using crossover this is how your strategy will be:
BUY: crossover(EMA(CLOSE,5),SMA(CLOSE,10))
SELL: crossover(SMA(CLOSE,10),EMA(CLOSE,5))
Hi Nithin,
I have been facing some problems in the ZT alogz.
I have coded a strategy
BUY: EMA(CLOSE,5)>SMA(CLOSE,10)
SELL: EMA(CLOSE,5)<SMA(CLOSE,10)
I have back tested it and it works fine. But while running it live today i found false calls generated. I have set the interval at 5 mins and i was following the chart, i found that there was no crossover but still a call was generated. And in another case there was a crossover and no calls have been generated.
Nithin ,
I need the back test result for nifty fut i min data for the code given below.
pls provide the software for backtesting my code.
### PDC=PREVIOUS DAY’S CLOSE
SET PDC=REF(CLOSE,-1)
BUY CLOSE>PDC
SET BP=CLOSE
SELL EXIT CLOSE-BP>30
SELL CLOSE<BP
SELL CLOSE 30
BUY EXIT 0
SELL EXIT 0
thanks
v.periasamy
Nithinji,
greetings for the day.
Could you pls provide the coding for the 2 simple strategies stated below on a one minute candle.
I intend to use it in calls/puts intraday trades.
Would also be very grateful if you could advice – of course without any risk and responsibility at your end – for any suitable modification(s)/addition to this strategy:
Strategy-1:
Buy: if the upward trending RSI has crossed the 50 level AND the upward trending price-ROC is above zero
level
Sell: RSI is reversing OR the price-ROC is reversing.
Strategy-2:
Buy: when the upward trending 5 period EMA crosses the 15 period EMA.
Sell : when the downward trending 5 period EMA crosses the 15 period EMA.
thanks in advance,
Shailender .
Buy signal:
Trend(RSI(close,14))=up and crossover(rsi(close,14),50) and
Trend(PROC(close,14))=UP and PROC(close,14)>0
Sell Signal:
# Assuming that by reversing the user means trend is down.
Trend(RSI(close,14))=Down or Trend(PROC(close,14))=Down
Strategy 2
Buy:
Trend(ema(close,5))=up and crossover(ema(close,5),ema(close,15))
Sell:
Trend(ema(close,5))=Down and crossover(ema(close,15),ema(close,5))
arti
Nithin ,
i have new account user id- DA1727, activated on 27-mar-14,i am subscribed to omnesys
for NEST Pulse,with different id. i want to login as DA1727 but when i try to login as DA1727 with my ZT password for nest plus in ZT, it refuses by saying that invalid login or password.
1 i need to write some custom script in NEST Pulse, how to get in.
2 i have some code in VB.net , can i subscribe for pulse API from somewhere
thanks
Arti,
The cost of automating through API is pretty restrictive, check this
I’d suggest you to see if it is possible on Pulse, will get someone on our tech team to call you up regarding the login issue. Check this section
Our new trading platform that we are working on, has advance coding/backtesting capability.
Hello Nithin can you get this for me
Entry for Long:
Note down previous day’s High price and after market opens today, wait for the price to breakout yesterday’s high and when broken check if Today’s Open = Today’s Low at that time, if Yes go long with Stop loss as today’s Low price.
Entry for Short
Note down previous day’s Low price and after market opens today, wait for the price to breakdown yesterday’s low and when broken check if Today’s Open = Today’s High at that time, if Yes go Short with Stop loss as today’s High price.
Ravi,
Presently it won’t be possible to code yesterday’s high into the strategy, but it should be possible in our new platform.
Cheers,
Thanks for the reply Nithin
Dear Nithin Kamath,
I’m a new client (RS:2849) who have been trying to learn the features in the Nest Trader for about three weeks. But during the process of my study I found lot’s of features which are provided by some international brokers are not there in the Nest Trader software which is provided by Omnesys. If this features can be included in the new trading software then I can really assure this is going to be the fantastic software which we can get in India. The following are the features which I’m just listing below:-
1. Click based market execution order. This helps the trader in entering into the trade more faster at the price foreseen by him. Order placing using the keyboard takes more time and has now become outdated.
2. Java based charting software which contains tick by tick, 1M, 15M, 1H, 4H & Day, Weekly & Monthly charts ( M-> Minutes & H-> Hour)
3. Tools such as Cursor, Crosshair, Vertical Line, Horizontal Line & Trend Line can be included.
4. Various types of charts such as Line, OHLC, Candle sticks etc can be put in the tools list so that the user can view the graph as per his requirement within a milli second.
5. Including a concept called Expert Advisors and Strategy Tester. This is the same concept like Algo Z in the Nest Trader. This facility is now there in the Metatrader software .
The thing which is coming to my mind is why can’t Zerodha have a tie up with the Metatrader or Amibroker. Since now most of the international brokers are giving this Meta Trader software free for their clients so that they can take better decisions when it comes to live trading. If the trading software is professional its generally a win win situation for the Broking institutions like Zerodha and even for the client too since you get high volume trading with better accuracy.
Right now the trading software which is provided but the Omnesys people are not up to the mark. It’s not a professional software for the trading community as a whole. Even there is a problem the Omnesys guys are very slow in responding its seems like they are running a government institution.
Anyway there is still scope for huge improvement. I hope Nithin Kamath and his team of professionals will take this note and bring in with a new professional trading software which will be the benchmark trading software so that everyone can lookup to you guys thus bringing in a new young class of professionals into trading.
So all the best to you and to your team.
With Regards,
K.S.JOSEPH
94972-82865.
Thanks Joseph, our beta of the new trading platform should be in the next couple of months, and hopefully will have all that you are looking for.
Cheers,
when will you launch your new platform for trading,?
It will take longer, we are stuck in getting the various features approved.
HI nithin,
my ac is activated but installation is in progress. Can i run algoz in MCX market.? what is the best moving averg script in Nifty F&O.? can you please tell me the best 3 code for algos trading i will work on back test results. can you please help me out.
Regrads
Sharan
Sharan,
Presently, this doesn’t work on MCX. There are a bunch of strategies on this blog post, you can backtest and see how it works. The thing about strategies is, it has to constantly evolve, so it is best if you learn it yourself.
Hi Nithin,
By when will the next version be released that will allow 10 months data for intraday and historical for backtest?
Until it is released is there a way that we can get the backtesting done for larger period?
Apart from 10 months data for intraday, do you plan to introduce any paid feature wherein users of AlgoZ can access the entire data without any limitation?
Yes Kam,
The new platform will come with advanced backtesting features, and an ability to be able to backtest on intraday data for upto 4 years. This will be all available for free. 🙂
Cheers,
Hi,
can we set the open intrest of call as C1,c2,c3….and OI of Put as P1,P2… for a series of Strike Price and do the math for C and P Series of values…? Please suggest
Need this in ALGOS
Thanks.
Jain
Jain,
The data that you can access using algoZ on the chart would be just price and volume, you cannot access Open interest.
hi
can we use supertrend indicator !
The present version you cannot
hi zerodha
I want to fully automate my trading using nest pulse dealer for that i need dealer id can you please tell me what are the requirements to get dealer id and is there any requirement of funds in trading account please help me
thank you
Hi Nithin,
I just want to know whether the following strategy can be coded or not
I want to place SL buy above the high of 11:00 AM 30-Min bar and SL sell below the low of 11:00 AM 30-Min bar, when Long or Short entered the pending SL order should become Stop Loss for the executed order. Take profit is optional if no take profit mentioned the order should get closed at 3:29 PM.
Please let me know whether the above strategy can be coded and if yes, please guide me on coding it since I do not possess sound coding knolwedge
Amthang, This will be not possible atleast in the present version because there is no way to code time into a strategy.
Thank you so much for your prompt reply Mr. Nitin. I appreciate spending your valuable time. Keep up the good work.
Cheers
Hi Nithin, I need one help i have Amibroker software and signaling code. the same code i would like to add to Zerodha ZT is it possible.? and also i dont know the code what is it. but it giving good signals as well as Stop Loss.
2. What is the difference between Amibroker and Zerodha ZT software, both are giving signals na..?
Sharan,
1. Depends on the complexity of the code, algoZ on ZT can’t presently handle complex codes. But you will have to tell us what it is to be able to code.
2. Yes in terms of signals ami and ZT are similar, but ami is much more advanced. We should be launching our new platform in the next 2 months, which along with being able to trade, would also be able to match ami in terms of charting and coding.
Thank you nithin. present ZT can we put auto SL with respect to the order generation.? is it possible all 3 items(buy, target and sl) make it auto mode.?
Presently not possible, but we should have some good news for you on this by next week.
Cheers,
Thank you, I applied Zerodha trading Ac.may be account get activated next week.
If you lunch next week that is ggod news for me. Thank you once again.
Hi, Just wanted to verify – What data does the chart show as 1 year historical data for any future contract ?
For NIFTY14MARFUT contract I can see historical data starting from Feb2013, time at which this contract did not exist.
Does it pull out data from all near term contracts for any given month to show this data ?
Aditya,
Historical charts for futures are usually smoothed to make it look like a continuous chart. So for example at the end of Nifty FEB futures, it will automatically merge into Nifty Mar Futures. Hopefully I didn’t confuse you too much.
Hi Nithin, Thanks for the reply. No that’s how one would expect it to be.
Just wanted to be sure as I have just started testing the waters in the world of algo trading 🙂
Hello Nithin Kamath,
Based of the 5 min chart I want to
Buy: When LAST>EMA(CLOSE,14) AND MACD > -3.60 and SELL: When LAST<EMA(CLOSE,14) AND MACD < 14.48
Please do help me in figuring the correct code.
With Regards,
K.S.Joseph
Joseph,
The code would be
Buy: Last>EMA(Close,14) AND MACDSignal(13, 26, 9, SIMPLE)>-3.60
Sell: Last
But what ensures 5 Min TF in this case? I mean, if somebody wants to use same strategy on some odd TF say 71 min TF, how this difference in TF reflected while coding?
Regards,
Mak_T
Mak,
The code remains the same irrespective of the time frame. When you are backtesting if you backtest on 5 minTF it backtests based on that, and if you backtest on 10 min TF it adapts automatically. Similarly when you go live on a strategy, you get alerts based on what time frame you take the strategy live on.
Hope this clarifies
Hi Nithin Kamathji,
my zerodha id is DD0566
crossBuy=Cross(StochK(17,9),StochD(17,9,3));
crossSell=Cross(StochD(17,9,3),StochK(17,9));
Best regards,
DEVIS MODI
Buy: SOPK(17, 9, 3, SIMPLE) > SOPD(17, 9, 3, SIMPLE)
Sell: SOPK(17, 9, 3, SIMPLE) < SOPD(17, 9, 3, SIMPLE)
_SECTION_BEGIN(“GUPPY’S G M M A”);
SetBarsRequired(100000,0);
SetChartOptions(0,chartShowArrows|chartShowDates);
MaxGraph = 12;
//==========Bar count= ==CNBONDRE=========================================================
PlotText(” C= “+LastValue(C),BarCount,LastValue(C),42);
numBars = BarsSince(DateNum()!=Ref(DateNum(),-1))+1;
PlotText(“\n BARS = “+LastValue(numBars),BarCount,LastValue(C),16);
//numBars = BarsSince(DateNum()!=Ref(DateNum(),-1))+1;
//PlotText(“\n VOL=”+LastValue(Volume),BarCount,LastValue(Volume),37);
StyleList= ParamList(“Chart Style”, “Candle,Bar”);
style =IIf(StyleList== “Candle”,styleCandle, styleBar);
GreenBar = IIf(C > O, True, False);
RedBar = IIf(C < O, True, False);
BarColor = IIf(GreenBar, colorGreen, IIf(RedBar, colorRed, colorGrey50));
PlotOHLC(O, H, L, C, "", BarColor, style );
//TimeFrameSet( inWeekly );// weekly // Daily
Q = Param( "% Change", 2, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = (( Z Ref(Z, -2)) AND (Peak(Z, Q, 1) > Peak(Z, Q, 2)));
LH = ((Z Ref(Z, -2)) AND (Peak(Z, Q, 1) Ref(Z, -1) AND Ref(Z, -1) Trough(Z, Q, 2)));
LL = ((Z > Ref(Z, -1) AND Ref(Z, -1) < Ref(Z, -2)) AND (Trough(Z, Q, 1) < Trough(Z, Q, 2)));
GraphXSpace = 10;
dist = 0.5 * ATR(20);
for ( i = 0; i EMA(C,30) AND EMA(C,3)>EMA(C,15) AND StochK()>Ref(StochK(),-1) AND StochK()>StochD() AND StochD()<80);
Sell= HH OR LH OR (Cross(EMA(C,60),EMA(C,15) )AND StochD()<30)OR(Cross( EMA(a,3), C ) AND EMA(a,15)< EMA(C,30) AND EMA(C,3)<EMA(C,15) AND StochK()<Ref(StochK(),-1) AND StochK()<StochD() AND StochD()C,colorDarkRed, colorBrightGreen ) );
Plot( C, “Price”, IIf( O>C,colorRed, colorGreen ), styleCandle );
HaClose =EMA((O+H+L+C)/4,3);
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
_SECTION_BEGIN(“Resistance”);
supres=ParamToggle(“Sup_Res”,”No|Yes”,1);
if(supres)
{
Prd1=Param(“Res_Period1”,2,0,200,1);
test = TEMA ( High , Prd1 ) ;
PK = test > Ref(test,-1) AND Ref(test,1) < High;//Peak
PKV0 = ValueWhen(PK,haHigh,0);//PeakValue0
PKV1 = ValueWhen(PK,haHigh,1);//PeakValue1
PKV2 = ValueWhen(PK,haHigh,2);//PeakValue2
MPK = PKV2 PKV0 ;//MajorPeak
MPKV = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,1); //MajorPeakValue
MPKD = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),1); //MajorPeakDate
SD = IIf(DateNum() < LastValue(MPKD,lastmode = True ), Null, LastValue(MPKV,Lastmode = True));//SelectedDate
Plot(SD, "Resist1", colorRed,ParamStyle("ResStyle1",styleLine|styleNoTitle,maskAll));
MPKV2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,2); //MajorPeakValue
MPKD2 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),2); //MajorPeakDate
SD2 = IIf(DateNum() < LastValue(MPKD2,lastmode = True ), Null, LastValue(MPKV2,Lastmode = True));//SelectedDate
Plot(SD2, "Resist2", colorRed,ParamStyle("ResStyle2",styleLine|styleNoTitle,maskAll));
MPKV3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,3); //MajorPeakValue
MPKD3 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),3); //MajorPeakDate
SD3 = IIf(DateNum() < LastValue(MPKD3,lastmode = True ), Null, LastValue(MPKV3,Lastmode = True));//SelectedDate
Plot(SD3, "Resist3", colorRed,ParamStyle("ResStyle3",styleLine|styleNoTitle,maskAll));
MPKV4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, PKV1,4); //MajorPeakValue
MPKD4 = ValueWhen(Ref(MPK,-1) == 0 AND MPK == 1, DateNum(),4); //MajorPeakDate
SD4 = IIf(DateNum() Ref(L,-1) AND Ref(L,1) Low AND test2 SPV1 AND SPV1 < SPV0 ;//MajorPeak
MSPV = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,1);
MSPD = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),1);
SD = IIf(DateNum() < LastValue(MSPD,lastmode = True ), Null, LastValue(MSPV,Lastmode = True));
Plot(SD,"Support1", colorBlue,ParamStyle("SupportLine1",styleLine|styleNoTitle,maskAll));
MSPV2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,2);
MSPD2 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),2);
SD2 = IIf(DateNum() < LastValue(MSPD2,lastmode = True ), Null, LastValue(MSPV2,Lastmode = True));
Plot(SD2,"Support2", colorBlue,ParamStyle("SupportLine2",styleLine|styleNoTitle,maskAll));
MSPV3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,3);
MSPD3 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),3);
SD3 = IIf(DateNum() < LastValue(MSPD3,lastmode = True ), Null, LastValue(MSPV3,Lastmode = True));
Plot(SD3,"Support3", colorBlue,ParamStyle("SupportLine3",styleLine|styleNoTitle,maskAll));
MSPV4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, SPV1,4);
MSPD4 = ValueWhen(Ref(MSP,-1) == 0 AND MSP == 1, DateNum(),4);
SD4 = IIf(DateNum() < LastValue(MSPD4,lastmode = True ), Null, LastValue(MSPV4,Lastmode = True));
Plot(SD4,"Support4", colorBlue,ParamStyle("SupportLine4",styleLine|styleNoTitle,maskAll));
}
_SECTION_END();
Sir please coding my id DD0566
???
Hello Nitin,
I am just new to trading and was just trying to learn and create strategies. The idea of my strategy is just
Buying the scrip when all the conditions are satisfied: When the CMP (Current Market Price) > EMA.(Period 14) + MACD upward cross + RSI should be above 65. Now just check my formula
BUY = CMP>EMA(CLOSE,14) AND MACD(26,13,9,EXPONENTIAL)>MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI(CLOSE,14)<35
SELL = CMP<EMA(CLOSE,14) AND MACD(26,13,9,EXPONENTIAL)65
BUY EXIT = 0, SELL EXIT = 0
Just see if this is the right code which i have written or if not please advice me the correct code
CMP (Current Market Price) > EMA.(Period 14) + MACD upward cross + RSI should be above 65. Now just check my formula
Buy: (Last > Ema(Close, 14)) and (Rsi(Close, 14) > 35) and MACD(26,13,9,EXPONENTIAL) > MACDSIGNAL(26,12,9,EXPONENTIAL)
Sell: (Last < Ema(Close, 14)) and (Rsi(Close, 14) > 65)
NITIN ,
KINDLY HELP/PROVIDE ME SURE SHOT STRATIGY FOR INTRADAY TRADING IN NIFTY & BANK NIFTY FUTURES. PLZ OBLIGE ME.
PRADEEP KUMAR SARIN (AUTPKS) ZERODHA UP
Pradeep,
Unfortunately there is nothing like a sure shot strategy in trading the markets. Markets are dynamic, and strategies have to keep evolving.
NITIN ,
KINDLY HELP/PROVIDE ME SURE SHOT STRATIGY FOR INTRADAY TRADING IN NIFTY & BANK NIFTY FUTURES. PLZ OBLIGE ME.
PRADEEP KUMAR SARIN (AUTPKS) ZERODHA UP
respected sirji yesterday i got your mail for ema -cci coding srategy thanx for your mail ..but i want to additinal add for some coding ema-cci so please help …below additional add so please make coding thanx in adavace
WAITING FOR YOUR VALUABLE REPLY …THANX
Setup
1). Timeframe : 5min chart
2). EMA : 110 period
3). CCI : 14 days
Why EMA 110? To be frank no idea but when tested proved with results to guage the TREND!
RULE
BUY / GO LONG CONDITION
a). The 5 min candle should be cut and close above 110 EMA.
b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the High price of the candle that cut and closed above 110 EMA
ADDITIONAL ADD::
1. increased the filter from 0.1% to 0.15%
2. trading starts only after the 8th candle for the day
3. CCI has to be more than 115
4. last trade should be the 3 o clock candle . No trades after that
5. Trading decision is taken with 3 candles . First candle is the one which has crossed over the 110 period MA with atleast a diffference of 0.5 from the 110 EMA . Also tail/head shadow should not be more than 2 times the body of the candle . Color doesn’t matter. you place an order which is 0.15% more/less than the high /low of the first candle ( cross over candle ) . If it doesn’t get executed , we wait for the first 3 minutes of the next candle ,if not the order is cancelled .
6. If the cross over candle is a doji i change the sl to 7.5
LT gave relatively poor results . All banking stocks and Maruti give good results if he rules are followed
SELL / GO SHORT CONDITION
a). The 5 min candle should cut and close below 110 EMA.
b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the Low price of the candle that cut and closed below 110 EMA.
ADDITIONAL
CANDLE CLOSING BELOW SMA(26)
EXIT : Rs.10/- min
SL : Rs.10/- (as I want to keep RR as 1:1)
Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
PLEASE HELP NITIN JI FOR SOME ALTER CODING ADDITIONAL ADD THANX IN ADVANCE
PLEASE HANAN JI LOOK THIS AND MAKE A CODE THANX IN ADAVANCE
hi ,
I need to code this strategy
buy condition
5ema (close)cross 13ema(close) from below and stoch (8,3,4,exponential) bullish crossover but 20
sell exit
stoch bullish crossover
Vishal, we’re very lucky to have received the code from our developers quickly today. Please backtest it before you apply.
Codes on the logic:
(Ref(Ema(Close, 5), 1) < Ref(Ema(Close, 3), 1)) and (Ema(Close, 5) > Ema(Close, 3)) and SOPK(8, 3, 4, SIMPLE) > 20 and SOPD(8, 3, 4, SIMPLE) > 20
Also try using RSI. Sample: Rsi(Close, 14) > 30 – bullish and Rsi(Close, 14) < 70 bearish.
hi ,
I need to code this strategy
buy condition
5ema (close)cross 13ema(close) from below and stoch (8,3,4,exponential) bullish crossover but 20
sell exit
stoch bullish crossover
respected sirji yesterday i got your mail for ema -cci coding srategy thanx for your mail ..but i want to additinal add for some coding ema-cci so please help …below additional add so please make coding thanx in adavace
WAITING FOR YOUR VALUABLE REPLY …THANX
Setup
1). Timeframe : 5min chart
2). EMA : 110 period
3). CCI : 14 days
Why EMA 110? To be frank no idea but when tested proved with results to guage the TREND!
RULE
BUY / GO LONG CONDITION
a). The 5 min candle should be cut and close above 110 EMA.
b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the High price of the candle that cut and closed above 110 EMA
ADDITIONAL ADD::
1. increased the filter from 0.1% to 0.15%
2. trading starts only after the 8th candle for the day
3. CCI has to be more than 115
4. last trade should be the 3 o clock candle . No trades after that
5. Trading decision is taken with 3 candles . First candle is the one which has crossed over the 110 period MA with atleast a diffference of 0.5 from the 110 EMA . Also tail/head shadow should not be more than 2 times the body of the candle . Color doesn’t matter. you place an order which is 0.15% more/less than the high /low of the first candle ( cross over candle ) . If it doesn’t get executed , we wait for the first 3 minutes of the next candle ,if not the order is cancelled .
6. If the cross over candle is a doji i change the sl to 7.5
LT gave relatively poor results . All banking stocks and Maruti give good results if he rules are followed
SELL / GO SHORT CONDITION
a). The 5 min candle should cut and close below 110 EMA.
b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the Low price of the candle that cut and closed below 110 EMA.
ADDITIONAL
CANDLE CLOSING BELOW SMA(26)
EXIT : Rs.10/- min
SL : Rs.10/- (as I want to keep RR as 1:1)
Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
PLEASE HELP NITIN JI FOR SOME ALTER CODING ADDITIONAL ADD THANX IN ADVANCE
THANX NITIN JI
This strategy can be applied to any timeframe and to any security. There are no guarantees implied with this strategy and losses can and may occur. This strategy is presented for educational purposes only. Online Trading Academy, its affiliates and Brandon Wendell cannot be held liable for any losses that you may have while employing this strategy in any markets.
Long Strategy
1. Place the 8EMA and 89EMA on your chart
2. When price and the 8EMA cross above the 89EMA you are establishing an uptrend in your timeframe
3. This trade will work best if the larger timeframe is also in a bullish trend
a. Trading on 5 min, use 30 min
b. Trading on 15 min, use hourly
c. Trading on 30 or 60 min, use daily
d. Trading on daily, use weekly
4. Look to buy when price retests an up-sloping 89EMA for the first time only
a. Price should also be testing a fresh demand level, trade is less likely to work without demand
b. The 8EMA cannot cross the 89EMA
c. Price can cross the 89EMA but cannot break demand
d. Additional confirmation from an oversold CCI, Stochastic or RSI
5. Place your stop below demand or 1 x ATR below the 89EMA
6. Target is the next supply level
This strategy can be applied to any timeframe and to any security.
Short Strategy
1. Place the 8EMA and 89EMA on your chart
2. When price and the 8EMA cross below the 89EMA you are
establishing an downtrend in your timeframe
3. This trade will work best if the larger timeframe is also in a bearish trend
a. Trading on 5 min, use 30 min
b. Trading on 15 min, use hourly
c. Trading on 30 or 60 min, use daily
d. Trading on daily, use weekly
4. Look to sell short when price retests an down-sloping 89EMA for the first time only
a. Price should also be testing a fresh supply level, trade is less likely to work without supply
b. The 8EMA cannot cross the 89EMA
c. Price can cross the 89EMA but cannot break supply
d. Additional confirmation from and overbought CCI, Stochastic or RSI
5. Place your stop above supply or 1 x ATR above the 89EMA
6. Target is the next demand level
DEAR SIRJI PLEASE MAKE ME CODING THANX
AlgoZ works on intraday basis and considers the strategy based on today’s condition. Demand factor is not included in pulse. Trend logic code: Trend(sma(close, 14)) = up
Hello Nitin
How are you ? Hope you are doing good.
I am here again to clear some of my doubts i hope you can do that.
1) if i have 50 stocks in my market watch and i want to apply EA to all 50 Stock at a time , how can i do that ?
2) how can i generate a EA for a stocking have more buyers then sellers ?
I asked this to support team but they were not able to find any solution for this, kindly please you tell me the answer for this.
Waiting for your reply
Thank you
Keep smiling 😉
Hey Piyush,
1. To apply an EA, you need to have a chart opened. So to apply EA’s on 50 stocks, you need 50 charts to be opened, which is currently not possible. You can currently apply EA for upto 8 stocks by opening 8 different charts. But you can have multiple EA’s applied on every chart.
2. There is no way to capture total number of buyers/sellers in the tradescript code.
Setup
1). Timeframe : 5min chart
2). EMA : 110 period
3). CCI : 14 days
Why EMA 110? To be frank no idea but when tested proved with results to guage the TREND!
RULE
BUY / GO LONG CONDITION
a). The 5 min candle should be cut and close above 110 EMA.
b). CCI should be > 100. We consider CCI reading only for ENTRY not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the High price of the candle that cut and closed above 110 EMA
SELL / GO SHORT CONDITION
a). The 5 min candle should cut and close below 110 EMA.
b). CCI should be < -100. We consider CCI reading only for ENTRY and not for EXIT. This CCI will act as a FILTER to avoid false Traps
c). A entry at 0.10% of the Low price of the candle that cut and closed below 110 EMA.
EXIT : Rs.10/- min
SL : Rs.10/- (as I want to keep RR as 1:1)
Recommended Scrips : MARUTI, AXISBANK, LT, TCS, ICICIBANK & SBI
PLEASE NITINJI HELP ABOVE FOR CODING THANX
Buy : (Ref(Close, 1) < Ref(Ema(Close, 110), 1)) and (Close > Ema(Close, 110)) and (CCI(12, SIMPLE) > 100) and (High*1.01 > Ema(Close, 110))
Sell: (Ref(Close, 1) > Ref(Ema(Close, 110), 1)) and (Close < Ema(Close, 110)) and (CCI(12, SIMPLE) < - 100) and (Low*1.01 > Ema(Close, 110))
Make sure to backtest these once,
When you take the strategy live, you have an option to set interval as 5mins and evaluate as tick.
Exit condition can’t be Rs10/min, exit has to be a strategy itself, because the code won’t capture the buying/selling price.
Hello sir i have one strategy please code it.
interval: daily
Buy:
current price > 2 WMA (formula (previous day close + 2 * curret price)/3)
and cross of Macd(1,30) and Macd Signal (1,30,2)
Exit Buy:
current price > 2 WMA (formula (previous day close + 2 * curret price)/3)
and cross of Macd(1,30) and Macd Signal (1,30,2)
Sell: current price > 2 WMA (formula (previous day close + 2 * curret price)/3)
and cross of Macd(1,30) and Macd Signal (1,30,2)
Exit Sell :
current price > 2 WMA (formula (previous day close + 2 * curret price)/3)
and cross of Macd(1,30) and Macd Signal (1,30,2)
Govindaraju, we’ve just received information from our developers that this cannot be coded on algoZ due to the complexity of the strategy. I believe even the developer has spoken to you.
Hi,
Could you please let me know if this can be coded.
Step 1:
Buy 1 share at current market price (ex: buy 1 at 100.00)
If 4 points gain then close position if not go to step 2
Step 2:
if 2 points loss then buy 2 more shares at 98.00, this step continues whenever there is a 2 points loss and the order quantity doubles for every level it goes down (ex: buy 2 at 98, buy 4 at 96, buy 8 at 94..)
Exit:
Close all the positions whenever the point goes up 4 points from the last bought level (let’s say the current price is 96 then it has to close all positions if the point reaches 100), and continue to step 1.
Thanks,
Here are the details.
Step 1:
Buy 1 share at current market price (ex: buy 1 at 100.00)
If 4 points gain then close position if not go to step 2
Step 2:
if 2 points loss then buy 2 more shares at 98.00, this step continues whenever there is a 2 points loss and the order quantity doubles for every level it goes down (ex: buy 2 at 98, buy 4 at 96, buy 8 at 94..)
Exit:
Close all the positions whenever the point goes up 4 points from the last bought level (let’s say the current price is 96 then it has to close all positions if the point reaches 100), and continue to step 1.
-> Nest Pulse allows LIMIT order only.
-> Nest Pulse will not capture the buy/sell price. When the cover order/sl is used, then it calculates based on the buy/sell trigger price. So the 2nd point can be defined using this. Here you are specifying based on the trigger price %age.
-> To have stop and reversal, use your logic in buy alert expression and sell alert expression fields. Split is not possible through pulse, instead you can have different exit strategies.
-> Call us on 0824-6612266 to discuss the logic.
Hi Zerodha,
I am not sure if this query can be put here. But i would find no other place to put it either. 🙁 So here’s the query –
Whenever i try to see the historical charts i get this Error Msg –
— Request: nexus_db_vwap, Process: Nexus_VWAP , Error: Request Unknown. Please contact Administrator..
Hi,
Can you code strategy for below
Resistance(R1) = (2×P)−L
R2 = P+H−L
R3 = H+2×(P−L)
Support(S1) = (2×P)−H
S2 = P−H+L
S3 = L−2×(H−P)
P is pivot and based on this
Buy: When above R1
Buy exit: 50% at R2 and rest at R3
Sell: when below S1
Sell exit: 50% below S2 and rest at S3
Thank you.
What about above cant U respond with a line
Hey Chethan, my bad, don’t know how this got missed.
Set P = ((High + low + Close) / 3)
Set R1 = ((2*P) – Low)
Set R2 = ((P + H) – Low)
Set R3 = (High + (2*(P – Low)))
Set S1 = (2*P) – (High)
Set S2 = P – (High – Low)
Set S3 = Low – (2*(High – P))
Buy:P > R1
Sell: P > S1
Exit points are not clear, is that the qnty you are referring? If yes, that wont be possible since there is only one option to provide the quantity that works on both entry or exit.
– When you have act on alert, please enter the qnty manually to go ahead with the logic.
– Please backtest the strategies to assess the performance before you go live.
I have created a new Strategy. But when ever i executed it is giving error message Error: Scripts generated no trades.
So for testing i have given LAST > OPEN. in buy condition. But still it is giving the same error?
I have tested in different time frames. Still getting error?
Also tested other inbuilt strategy also.giving the same issues.
Please help.
Can you send your client ID and same query to [email protected], one of us will get in touch.
Hi Team,
Can you please help with the
Buy Expression for:
When the stock closes above its 3 month high candle
Thanks,
Mahesh
I am new to algo coding but here is what i need , I am looking for breakout trades where once a stock satisfies all these 3 conditions.
Buy:
1) Stock which has closed above its 3 month price.
and
2) Volume 1X > previous day
and
3) Closing above the upper Bollinger Band (20, 0)
Sell:
Close < 3 Day SMA
Similarly i would like to know for 1st attempt close above 52 week high
Thanks,
Mahesh
I want to code the following logic for Amibroker:
Chart 1 min candle chart intraday
Indicator 21 Simple Moving Average
Profit target 21 points
Stop Loss 9 points
Trailing stop loss Once the position is in profit by 13 points, 9 points trailing stop loss.
Buy
When a candle closes above the 21 SMA, buy when the peak price of this candle is breached by 3 points.
If the successive candles high is less than 3 points, the entry point is when the price breaches the highest of the precedding candles since signal, by 3 points.
Sell
At profit target of 21 points or a trailing stop loss of 9 points once the profit is 13 points
Or exit when the signal is reversed.
Re entry
Once position is closed re-enter if the trend continues and the prices breaches the high of a candle when position was closed by 3 points.
Short
When a candle closes below the 21 SMA, short when the low of this candle is breached by 3 points.
If the successive candles low is less than 3 points, the entry point is when the price breaches the lowest of the precedding candles since signal, by 3 points.
Cover
At profit target of 21 points or a trailing stop loss of 9 points once the profit is 13 points
Or exit when the signal is reversed.
Once position is closed re-enter if the trend continues and the prices breaches the low of a candle when position was closed by 3 points.
Hi, here’s your answer.
Here are the Algo Z codes based on client’s logic:
Indicator 21 Simple Moving Average.
– Sma(Close, 21)
Profit target 21 points
– Pulse/ AlgoZ doesn’t capture the buy/sell price to define 21 points from buy/sell.
Stop Loss 9 points
– You can use cover order feature of Pulse/ AlgoZ. It calculates based on the buy/sell trigger price. it is defined in terms of %age.
Trailing stop loss Once the position is in profit by 13 points, 9 points trailing stop loss.
Please check if you have bracket order role, if yes, then you can define and profit booking as well as sl.
Buy:
When a candle closes above the 21 SMA, buy when the peak price of this candle is breached by 3 points.
– Close > Sma(close, 21)
– (Ref(High, 1) + 3) < Close * This point is not so clear. - (Ref(High, 1) + 3) < Close. This compares the previous bar's high with the current one. If the successive candles high is less than 3 points, the entry point is when the price breaches the highest of the preceding candles since signal, by 3 points. - Pulse/ AlgoZ doesn't capture the buy/sell price. (CLOSE > (MAXOF(REF (HIGH, 1), REF (HIGH, 2))))
* Compares with the current/close.
Sell:
At profit target of 21 points or a trailing stop loss of 9 points once the profit is 13 points.
– Please check if you have bracket order role, if yes, then you can define and profit booking as well as sl.
Or exit when the signal is reversed.
– Close < Sma(close, 21) - (Ref(High, 1) + 3) > Close
Re entry
Once position is closed re-enter if the trend continues and the prices breaches the high of a candle when position was closed by 3 points.
– Pulse/ AlgoZ doesn’t capture the buy/sell price.
(CLOSE > (MAXOF(REF (HIGH, 1), REF (HIGH, 2))))
* Compares with the current/close.
Short:
When a candle closes below the 21 SMA, short when the low of this candle is breached by 3 points.
– Close , Sma(close, 21)
– (Ref(High, 1) + 3) < Close * This point is not so clear. - (Ref(High, 1) + 3) < Close. This compares the previous bar's high with the current one. If the successive candles low is less than 3 points, the entry point is when the price breaches the lowest of the precedding candles since signal, by 3 points. - Pulse/ AlgoZ doesn't capture the buy/sell price. - (Ref(Low, 1) + 3) < Close Cover At profit target of 21 points or a trailing stop loss of 9 points once the profit is 13 points Or exit when the signal is reversed. Once position is closed re-enter if the trend continues and the prices breaches the low of a candle when position was closed by 3 points. - Please check if you have bracket order role, if yes, then you can define and profit booking as well as sl. * Please back test the strategies before applying live to assess the performance. Please revert to us in case you need further assistance.
Indicators:
Bollinger Band
EMA Period
Buy Condition:
1. When previous Bar[low]Touches the Lower Bollinger Band
2. AND Current bar open above the Lower Bollinger Band
3. AND Current Bar Open above Close of Previous bar
4. AND Finally Current bar price should be 2 to 3 pips less than EMA
Exit Long Conditions:
1. Exit the long position when current bar touches the EMA.
Stop Loss:
1. Low of the previous bar + 2 pips (i.e. the previous bar when we bought)
Can you please create a strategy for me based on these inputs. Let me know if need any more inputs.
Is below code is correct?
SET PBarLow = REF[LOW,1]
SET CBarOpen = REF[OPEN,0]
SET PBarClose = REF[CLOSE,1]
SET EMA = EMA(CLOSE,15)
PBarLow = BBB(CLOSE, 20, 2, EXPONENTIAL) AND
CBarOpen >= PBarClose AND
CBarOpen = EMA
Stop Loss:
LAST <= PBarLow *.999
Updated Code
SET PBarLow = REF[LOW,1]
SET CBarOpen = REF[OPEN,0]
SET PBarClose = REF[CLOSE,1]
SET EMA = EMA(CLOSE,15)
PBarLow = BBB(CLOSE, 20, 2, EXPONENTIAL) AND
CBarOpen >= PBarClose AND
CBarOpen = EMA
Stop Loss:
LAST <= PBarLow *.999
Is this is Correct? Can u plz check it?
No its not working…error….undefined variable REF[LOW,1]
please give me code for this…
Buy : prime number oscillator 7
i tried following but its not working
Buy : PNO(CLOSE)7
When you enter a strategy code, you need to also enter the exit expression. If you don’t enter exit or sell expression, you need to enter at least 0 there. That should make your strategy work.
Hi,
i need a code for the below AFL, will that be possible?
_SECTION_BEGIN(“Price”);
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat(“{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, “Close”, ParamColor(“Color”, colorBlack ), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN(“camarilla levels”);
//—- pivot points
DayH = TimeFrameGetPrice(“H”, inDaily, -1); // yesterdays high
DayL = TimeFrameGetPrice(“L”, inDaily, -1); // low
DayC = TimeFrameGetPrice(“C”, inDaily, -1); // close
DayO = TimeFrameGetPrice(“O”, inDaily); // current day open
// camarilla pivots
if ( True )
{
R = DayH – DayL; // range
PP = (DayH + DayL + DayO + DayO) / 4 ;
R4 = (R * 1.1/2)+DayC;
R3 = (R * 1.1/4)+DayC;
S3 = DayC-(R * 1.1/4);
S4 = DayC- (R * 1.1/2);
}
Plot(R4, “”,colorGreen,styleDots+styleNoLine);
Plot(S4, “”,colorDarkBlue,styleDots+styleNoLine);
Plot(R3, “R3”,colorRed,styleDots+styleNoLine);
Plot(S3, “S3”,colorDarkBlue,styleDots+styleNoLine);
Plot(PP, “”,colorYellow,styleLine);
//—-
Title = Name()+” Camarilla”+Date()+ EncodeColor(colorRed)+ ” R3 “+WriteVal(R3,1.2)+EncodeColor(colorGreen)+ ” S3 “+ WriteVal(S3,1.2)+”\n”+EncodeColor(colorGreen)+” Long Breakout above “+WriteVal(R4,1.2)+”\n”+EncodeColor(colorRed)+” Short breakout below “+WriteVal(S4,1.2)
+”\n”+EncodeColor(colorGreen)+” If Rangebound buy close to “+ WriteVal(S3,1.2)+
“\n”+EncodeColor(colorRed)+” If Rangebound short close to “+ WriteVal(R3,1.2);
Filter=1;
AddColumn(C,”cmp”,1.2);
AddColumn(R3,”R3″,1.2);
AddColumn(R4,”R4″,1.2);
AddColumn(S3,”S3″,1.2);
AddColumn(S4,”S4″,1.2);
_SECTION_END();
——————————————————————————————————–
//—- pivot points
DayH = TimeFrameGetPrice(“H”, inDaily, -1); // yesterdays high
DayL = TimeFrameGetPrice(“L”, inDaily, -1); // low
DayC = TimeFrameGetPrice(“C”, inDaily, -1); // close
DayO = TimeFrameGetPrice(“O”, inDaily); // current day open
// camarilla pivots
if ( True )
{
R = DayH – DayL; // range
PP = (DayH + DayL + DayO + DayO) / 4 ;
R4 = (R * 1.1/2)+DayC;
R3 = (R * 1.1/4)+DayC;
S3 = DayC-(R * 1.1/4);
S4 = DayC- (R * 1.1/2);
}
Dinesh, can you give us the logic behind the code? The problem is that the way codes are written is different for AmiBroker and for Nest Pulse so our developers cannot just pick up the code from here and put it there. Giving us the complete logic behind the strategy will aid in coding.
Hi Hanan, I am just trying to use the camarilla statergy 🙂 Hope you understand now.
Dinesh, our coders wouldn’t be able to decipher the Camarilla Strategy. It would be best if you can write down the logic so we can code it for you. Remember that algoZ is not as advanced as AmiBroker for coding strategies so you have to be able to define the logic in a clear manner for them to code using the tools they have available.
I don’t have the Logic for the previous question but here is another strategy.. Could you please let me know if this can be coded.
Step 1:
Buy 1 share at current market price (ex: buy 1 at 100.00)
If 4 points gain then close position if not go to step 2
Step 2:
if 2 points loss then buy 2 more shares at 98.00, this step continues whenever there is a 2 points loss and the order quantity doubles for every level it goes down (ex: buy 2 at 98, buy 4 at 96, buy 8 at 94..)
Exit:
Close all the positions whenever the point goes up 4 points from the last bought level (let’s say the current price is 96 then it has to close all positions if the point reaches 100), and continue to step 1.
Thanks,
OK..
But what about my code and setting for the given example asked…”For example: Closing price is above 13 ema and cci is greater than 50, buy above the high of this candle with addition to a percentage filter (say 0.5%) and vice versa for sell.”
Thanks..
Why don’t you send us a detailed strategy explanation by email to [email protected]. Let me get this checked by my developers. The key is my developers need complete clarity about what you want your strategy to do so they can code it for you.
hi
as all of the code give signal whenever meet the given criteria , as well as the order also generated on the same candle. I want to get order alert above/below the high/low price of the signal candle with a percentage filter. how can it be coded?
For example: Closing price is above 13 ema and cci is greater than 50, buy above the high of this candle with addition to a percentage filter (say 0.5%) and vice versa for sell.
Sonai,
In the present version, signals will be generated only after completion of the candle and not during the candle.
dear team
please mack a code below given expresoine
ema highe 20,ema low 20 and with ema 200
signeal should be come when cross both ema (EMA-H20,EMA-L20) to cross EMA-200
Didn’t get by what you mean by EMA high and EMA low?
Buy: EMA(Close, 20)> EMA(Close, 200)
Sell: EMA(Close, 20)< EMA(Close, 200) The above strategy is to buy and sell on EMA crossover, if this is what you are asking for.
i mean sir buy signel should come when ema high & ema low cross the ema 200
(Ema(High, 20) > Ema(close, 200)) and (Ema(Low, 20) > Ema(Close, 200))
sir i sent chart screen print in you are mail , what i need sir please check
You should have gotten a reply from [email protected]
Check your email, Tirumal. We’ve given you the code and also info on how to use it.
nithin and hanan sir
can we code open range breakout system for day trading time fram 5min
stratagy is when ever price break ORB there should come buy and sell signels
Tirumal, this will not be possible on the present platform as we need time element to code ORB, but we are working on our new platform which should be up in the next couple of months and where it will be possible.
Hi Nithin, I am Manikandan from Chennai …. a client and an AP for Zerodha … I have a simple constant strategy in Bank Nifty Futures, with no If and but logic …
I have back-tested that for the last 9 years and it gives 70 fold returns on capital, with max negative MTM of 2000 points in bank nifty at any point of time … Accuracy at 70% ….
I have explained this to Bosco in person in Chennai … He should too inform you about this …
I want this logic automated so that clients can allocate budget and follow it (The logic is very simple and it should be very very easy to automate) …
I have explained the back-tested results in a video … If you can spend 10 mins, you can watch it at http://www.youtube.com/watch?v=XaKek5-H2NM
If you can spend some time, i can explain in detail ….
Thanks Mani,
It is a little tricky automating, because exchanges presently don’t let retail to automate strategies. I am forwarding this to Nikhil to have a look, you can connect to him on [email protected], he takes care of our trading desk. Will also speak to bosco about this.
okay … To add more info, the constant strategy i talk about only involves time based orders, twice a day ….
Does the exchange also restrict putting in time based orders? I mean, a mechanism where i can make it recursive … I will look forward to get in touch with Nithin for further discussions …
Thanks for your timely response …
How I can add formulas and back test the formula in nest plus. Please describe
Did you know any successful strategies with 95% accuracy?
Or how I can collect a successful strategy from the best earning member of zerodha?
Give me a code for triangular moving average for 5 days with top and bottom with sell buy signal and avoid signals in flat movements
Check this link has examples on how to add formula and backtest. This blog has examples on strategies asked by our clients.
Presently we don’t have a strategy exchange kind of program, but we are planning for one.
About triangular moving average, can you be more specific with all the conditions you want to code.
Please give code for MACD HISTOGRAM.
what are the charges and procedure to fully automate trading as per new regulations? Please let me kniw.
Thanks
Sameer,
Fully automation is not possible on a retail client terminal. You will need a dealer terminal which would mean that you need to register on the exchange as an Authorized person of Zerodha, costs around 10k. Once done, you need to get approval for your strategy from the exchange and running cost for the strategy, which can be anywhere between 2k to 50k per month based on what you want. Send your contact to [email protected], he will get in touch and explain you more.
In algoZ trading, Suppose the system puts a long order on exchange along with a stoploss and the stoploss gets triggered for below stratergy .So the long position is closed because of stoploss and not due to buy exit condition. Now when the sell condition becomes true at some point, will the system first execute buy exit and then opens short position? or does the system knows that the long is closed due to stoploss and only opens a short position?
Buy: EMA(Close,7)>EMA(Close,14) Sell: EMA(Close,7)<EMA(Close,14)
Buy exit: 0 Sell exit: 0
Hey,
First of all thanks a ton for your efforts !! 🙂
A few queries
1. Can the variable(s) calculated in the previous condition check be used in the next check.
Say I use “SET A =” function and the BUY or SELL expression returns FALSE. Can I use this information (that it returned FALSE) in the next check ?
2. How do you incorporate memory element ?
Say I use SET B= some function in the BUY expression. After 10 intervals, can I use the value of REF(B,10) ??
3. Explain LOOP function. Is this similar to array in C++.
Thanks again !
Hi!
It seems that your strategy requires our developers to directly interact with you. Could you please share your client ID at Zerodha and your contact number so we can get them to talk to you directly and assist you with the strategy?
Hello,
I would like to know how to call functions.
Thanks
Check out this link to figure out how to code on algoZ. All the information you need on how to call a function is available here. You need to have some kind of programming knowledge or you need to be computer savvy to work with this.
ZERODHA TRADERS,WHO ARE IN NEED OF PROFITABLE STRATEGIES,CAN CONTACT US-MAIL TO:
[email protected]
Hi Nithin,
Could you please code the below strategy for me.
For Long Entry:
1. EMA(3) crossing EMA(13)
2. ADX(14) greater than 20
3. CCI(14) greater than 100
For Exit
1. candle closing below SMA(26) or
2. CCI(14) less than -100
Here’s your strategy…
2. adx(14) > 20
Please backtest the strategies before applying live.
HI
ZERODHA
can you code this ADX(10)is increasing for eg:- from 20 to 21 to 22……
I just want a code to catch trades when ADX is increasing.
THANK YOU
Here’s your strategy…
Please backtest the strategies before applying live.
Hi Sir,
can u give me the buy and sell expression for the below strategy:
# Calculate the x period simple moving average . Use the end-of-minute prices.. Let’s say it as reference_1.
# Compute a point that is 1% above reference_1. Let’s call it as reference_2. E.g. If X period simple moving average is 6000, then ref_1 = 6000 and ref_2 = 6060.
# Starting position = FLAT.
# At the end of any minute, if price > ref_2, go LONG.
# When position is LONG, at the end of any minute, if price < ref_1, close the long position.
Anticipating great amount of support in this regard
Hi, Sidharth:
Here’s our answer for you. 🙂
Please backtest the strategies before applying live.
Can you please help with expression in the following case
Buy when previous RSI30. Also Current low< previous candle low. Sell when previous RSI>60 and current RSI Previous candle high
Basically i would like to have expression to find RSI divergence
Buy when previous RSI<30 and current RSI>30. Also Current low< previous candle low. Sell when previous RSI>60 and current RSI<60. Also current High > Previous candle high Basically i would like to have expression to find RSI divergence
Buy:
(REF(RSI(CLOSE, 14), 1) < 30) AND (RSI(CLOSE, 14) > 30) AND (LOW < REF(LOW, 1))
Sell:
(REF(RSI(CLOSE, 14), 1) > 60) AND (RSI(CLOSE, 14) < 60) AND (HIGH > REF(HIGH, 1)) RSI divergence: Currently not available in pulse.
Initiate long when the close is above 3day high average ( 3 HMA) and 3 day close average ( 3SMA) crosses above 8 day close average ( 8 SMA). (stop loss 3 day low average)—
—Initiate long when the close is above 3day high average ( 3 HMA) and 3 day close average ( 3SMA) crosses above 8 day close average ( 8 SMA). (stop loss 3 day low average)— => (((DHIGH(1) + DHIGH(2) + DHIGH(3)) / 3) < close) and ((sma(close, 3) > sma(close, 8)) SL 3 day’s low: (DLOW(1) + DLOW(2) + DLOW(3)) / 3 this could be profit booking also, you can define the sl when you go live. Initiate short when the close is below 3day low average ( 3 LMA) and 3 day close average ( 3 SMA) crosses below 8 day close average ( 8 SMA). (stop loss 3 day high average)
=> (((DLOW(1) + DLOW(2) + DLOW(3)) / 3) > close) and (sma(low, 3) < sma(close, 8)) SL 3 day’s high: (DHIGH(1) + DHIGH(2) + DHIGH(3)) / 3 this could be profit booking also, you can define the sl when you go live. Requesting you to backtest the strategies before going live.
Hi Zerodha,
Could you please let me know if we have any feature/possibility to real time feed/EOD feed to excel sheet from Zerodha trader ? I need to know this to apply certain criteria and sort out stocks ahead of time before applying strategies into Algoz.
Thanks.
Yes, you can. We have a “Link to Excel” feature available on Zerodha Trader which you can use to get intraday, real-time data onto Excel. What you do with it in Excel after that is up to you.
End of day data is available on Yahoo or Google for free and you can also get it from the exchange website.
To use the “Link to Excel” facility, please do this:
First you need to right click on your Market Watch on ZT and select ‘Link to Excel’. In that option, you have to select ‘All Items.’ Then you go to Excel and just do a paste or ‘Ctrl+V’. This will enable streaming quotes on Excel.
Settings within Excel:
1. Open Excel – ZT supports Office 2007 and above. You can try other versions of Excel, but the methodology is as described below.
2. Click the “Office Button” on the top left of your screen.
3. Click on “Excel Options” at the bottom of the new window.
4. In the new window, click on “Trust Center” on the left-hand side menu bar.
5. On the right-hand side, please click on an option called “Trust Center Settings”.
6. In the new window, click on “Trusted Locations”.
7. Click on “Add new Location” on the bottom of the window.
8. Browse and select the “Omnesys” folder from your Program Files.This will enable Excel to receive streaming quotes from ZT.
Handy Tip: If it does not work, right click on ZT and on the Excel and run both these programs as ‘Administrator.’
Hi Nithin,
Could you please code the below strategy for me.
Here you go…
Kindly advise us code for rsi(14) trendline breakage
Buy:When RSI(14) DOWNWARD TRENDLINE IS BROKEN
SELL:When RSI(14) upward trendline is broken .
Regards.
This one is easy:
Buy Expression: RSI(Close,14) < 30
Sell Expression: RSI(Close,14) > 70
Sorry,but above may not be correct.We have requested a code which will say about “RSI(CLOSE,14) LINE TRENDLINE”.The one given by you is simply oversold and averbought position of RSI(CLOSE,14).
I think it is the reply to the previous question repeated here…..erroneously
“RSI Trendline” breakage may happen at any stage of the RSI values.
Please correct if wrong.
Regards
Chintamani, the kind of strategy you mention is not possible on algoZ. Yes, you can combine two strategies like moving average and RSI to get the desired strategy. Moving averages are as good as trend lines.
Try this:
EMA(CLOSE, 12) > EMA (CLOSE, 26) AND RSI (CLOSE, 14) > 70
EMA(CLOSE, 12) < EMA (CLOSE, 26) AND RSI (CLOSE, 14) < 30
fine.Thanx.
hi zerodha
sir
i dont know much about coding and all.i want o know one thing.
in a particular scrip the Rsi crosses 70 or above the graph should show a sell signal and if the rsi is bellow the 30 should show a buy signal.how i can write it in a code style.For that what i have to do
waiting for your replay job
This one is easy:
Buy Expression: RSI(Close,14) < 30
Sell Expression: RSI(Close,14) > 70
Hi Zerodha,
Still waiting for the code of the following.
Buy:
Condition 1:When stochastics (8,3,4) %K>%D>20 and price crosses above the high of last candle. No buy if % K remains lower than 20 for atleast 5 candles.
and
Condition 2:When %K remains above 80 for atleast 5 candles and stochastics (8,3,4) %K>%D (Positive cross over)
Sell:
Condition 1:When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle. No sale if %k remains abole 80 for atleast 5 candles.
and
Condition 2: When % K remains below 20 for atleast 5 candles and stochastics (8,3,4) %K<%D (Negative cross over)
sir
i dont know much about coding and all.i want o know one thing.
in a particular scrip (if it is DLF) the Rsi crosses 70 or above the graph should show a sell signal and if the rsi is bellow the 30 should show a buy signal.how i can write it ina code style
waiting for your replay
job
Buy Expression: RSI(Close,14) < 30
Sell Expression: RSI(Close,14) > 70
SIR ,
I WANT TO CODE THE BELOW SYSTEM :-
INTRADAY SYSTEM – 1
TURNING POINT = (Previous Close+Open+ATP)/3
BUY – IF 5 MINUTE TIME FRAME CANDLE CLOSE ABOVE TURNING POINT , THEN PLACE BUY ORDER JUST ABOVE THE LAST 5 MINUTE CANDLE HIGH .
EXIT – JUST BELOW LAST 30 MINUTES LOW .
SELL – IF 5 MINUTE TIME FRAME CANDLE CLOSE BELOW TURNING POINT , THEN PLACE SELL ORDER JUST BELOW THE LAST 5 MINUTE CANDLE LOW.
EXIT – JUST ABOVE LAST 30 MINUTES HIGH .
INTRADAY SYSTEM – 2
BUY – IF 5 MINUTE TIME FRAME CANDLE CLOSE ABOVE PIVOT POINT . THEN PLACE BUY ORDER JUST ABOVE THE LAST 5 MINUTES CANDLE HIGH .
EXIT – IF 5 MINUTE CANDLE CLOSE BELOW LAST SUPPORT LEVEL.
SELL – IF 5 MINUTE TIME FRAME CANDLE CLOSE BELOW PIVOT POINT . HEN PLACE SELL ORDER JUST BELOW THE LAST 5 MINUTE CANDLE LOW.
EXIT – IF 5 MINUTE CANDLE CLOSE ABOVE LAST RESISTANCE LEVEL.
THANKS IN ADVANCE
Zerodha,
Why should we take Amibroker,when we have ZT with ALGOZ ? For a Daytrader?
Can we fully automate your strategies given with Algoz ,in a Dealer terminal with Zerodha,if it is sucessful and backtested ?
Hi,
As i dont have enough time to trade so is there any trader who can trade in my account or else they can write script & set the algo z in my account…..
waiting for your reply.
[email protected]
Well, if you don’t have time to trade, automation seems to be the best way forward. Automating your trades requires you to have a lot of knowledge about systems and technical analysis so you can automate or semi-automate your trades. Please read up this blog and the introduction blog on algoZ so that you can get an idea of how to setup your own trading system.
Zerodha doesn’t manage funds for anyone, but we’re coming up with our ground-breaking product Open Trade very soon. 🙂
Zerodha,
If I get Trader terminal ,can I trade fully automated,using simple strategies with ALGOZ ?
How much will be cost of Amibroker software ,plus plug in, Data, monthly for 5 scrips ?
pls reply
All answers for this are available here.
https://www.zerodha.com/main/zerodha-trader-plugin-amibroker.html
Hi Zerodha,
Waiting for the code of the following.
Buy:
Condition 1:When stochastics (8,3,4) %K>%D>20 and price crosses above the high of last candle. No buy if % K remains lower than 20 for atleast 5 candles.
and
Condition 2:When %K remains above 80 for atleast 5 candles and stochastics (8,3,4) %K>%D (Positive cross over)
Sell:
Condition 1:When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle. No sale if %k remains abole 80 for atleast 5 candles.
and
Condition 2: When % K remains below 20 for atleast 5 candles and stochastics (8,3,4) %K<%D (Negative cross over)
Don’t think we can code “
Sell:
Condition 1:When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle. No sale if %k remains abole 80 for atleast 5 candles.
and
Condition 2: When % K remains below 20 for atleast 5 candles and stochastics (8,3,4) %K<%D (Negative cross over)
Zerodha,
pls arrange a seminar or demo with your kerala office to clarify all our doubts, who is the right person in Kerala,to get a Demo on Amibroker,Nest pulse,features and advantages?
OR pls call me on 9495716716-SASIMENON.a ZERODHA trader.
We’ll get someone to call you… 🙂
Unfortunately, we are not trained to coach our clients on how to use AmiBroker or algoZ. There are a lot of self-help tools which you can use to learn how to trade using these.
Zerodha,
1.Where would I get Amibroker,to get fully automated,How much it will cost?and the procedures?
2.Full automation through Amibroker includes execution of trades through strategies or conditions for the day,or expiry ?
3.Can I use ALGO strategies with Amibroker
Pls help me to learn and earn Awaiting for your reply soon.
Our answers:
1. Check out this link for details: https://www.zerodha.com/main/zerodha-trader-plugin-amibroker.html. Note that the exchange has restrictions on automatic or semi-automatic trading using external programs, so you have to get each strategy of your approved by the exchange before using it. You actually have to demonstrate each strategy to the exchange before they allow you to use it.
2. algoZ works independently of AmiBroker. Also the strategies written for AmiBroker have a different language and cannot be imported onto algoZ.
We have loads of articles written here and this is the best place to get started on learning how to use these tools. Since these are high-end tools, there aren’t too many qualified people to train you on these, so it’s best to utilize online resources.
Pls reply these questions,
1.Can I use the NISM certificate,of other person as my authorised dealer,to take fully automated Terminal,in my trading a/c
2.Can I trade on cash,f&O,and currencies,with automated terminal with that certificate,in my trading a/c
3.Can I trade on different strategies on different scrips and sectors,on fully automated terminal.
4. How many days it will take,to get it fully automated,if I have already a trading a/c with zerodha.
5.Should I become an AP/SB,or the Dealer ? to get an automated terminal on my trading a/c.in such a case?
Awaiting for your reply pls
with regards,
sasirammenon.
1) No, the NISM certificate should belong to the person who is going to be availing the services of Zerodha.
2) Yes, you can.
3) If you are using NEST Pulse, you can run different strategies on different scrips and sectors but it isn’t fully automated… You’ll have to click to execute the trade… Full automation is available with AmiBroker
4) We’re yet to get approval for complete Automation… Nest Pulse single click to place orders is available.
5) You should become an AP to get an Automated Trading Terminal.
Please note that it is Zerodha’s discretion to offer a trading terminal to a retail client.
Hi Zerodha,
Just to modify the strategy a bit
Buy:
Condition 1:When stochastics (8,3,4) %K>%D>20 and price crosses above the high of last candle. No buy if % K remains lower than 20 for atleast 5 candles.
and
Condition 2:When %K remains above 80 for atleast 5 candles and stochastics (8,3,4) %K>%D (Positive cross over)
Sell:
Condition 1:When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle. No sale if %k remains abole 80 for atleast 5 candles.
and
Condition 2: When % K remains below 20 for atleast 5 candles and stochastics (8,3,4) %K<%D (Negative cross over)
Hello,
I had a previous post without an answer, i guess because i may have not expressed myself very well. Anyway, if you can help me with that i will very much appreciate. I have read previous posts on this blog and found something similar to what i want to do. The i saw here is Close>EMA(HIGH,40) AND EMA(HIGH,40)-CLOSE<2. If i understood it well, in this code, the buy entry will happend when the difference between the EMA (HIGH,40) and the last closing price is no greater than 2 points. I want to do something similar, but im not sure on how to write the code. I want to buy when the price of the last candle touches the EMA (CLOSE,17) and the current candle open with no more than 10 points of difference to the EMA (CLOSE,17). Also, i would like to sell when the price pierces the upper bollinger band. Please, could you kindly help me?
Thanks
When i said “The i saw here” i mean The code i saw here.
That worked just fine and i was also able to improve a few aspects of my trading system, thanks!
Hello NIthin,
please share me strategy(code) for below script.
Buy:For RCOM Future ( just example )
If 14 EMA cross over to 42 EMA with above average daily volume with target of 0.50 praise and stop loss will be cross over of 42 EMA to 14 EMA.
Regards,
Vinod
You can’t use the volume data, but it is actually simple strategy and mentioned few times in this blog already.
Buy: EMA(Close,14)> EMA(Close,42)
Stop loss can’t be a strategy it has to be put in terms of %, check the blog managing script
Target has to be a strategy and can’t be a price from your purchase..
Cheers,
HI,
CAN YOU WRITE A CODE FOR THE FOLLOWING STRATEGY FOR INTRADAY NIFTY FUTURES FOR 1 MIN INTERVAL.
BUY SIGNAL. WHEN STOCHASTIC OSCILLATOR %K CROSSES %D FROM BELOW AND RSI IS BELOW 40.
SELL SIGNAL. WHEN STOCHASTIC OSCILLATOR %K CROSSES %D FROM ABOVE AND RSI IS ABOVE 60.
BUY : SOPK(9,3,9,EXPONENTIAL)<SOPD(9.3.9,EXPONENTIAL) AND RSI(CLOSE,14)<40
SELL : SOPK(9,3,9,EXPONENTIAL)>SOPD(9,3,9,EXPONENTIAL) AND RSI(CLOSE, 14)>60
IS THIS CORRECT? OR
BUY : CROSSOVER(%K,%D) AND RSI(CLOSE,14)<40
SELL : CROSSOVER(%D,%K) AND RSI(CLOSE,14)>60
THANK YOU
Your 1st question:
How to get the price at which last signal was generated?
for example, how to code : exit long when close is below (LONG_PRICE – 50)?
Sameer,
You cannot get the price at which you entered or exited in algoZ, you will have to code this based on your entry signal..
on chart right click show running script
on running script right click open report
it will show you genrrated signal with time and price
Can I run the stratergy on two different scripts simulaneosly?
Yes you can run multiple scripts at a time.
Cheers
Will the Algo script running, consider the carry over positions? Suppose I carried a long position from previous trading day, then will the script genate exit signal for that carried over long position?
The script won’t consider the carry over position, but if your strategy gives an exit signal, it will ask you to exit that..
Hello, i would like to know if the following strategy can be coded:
Thanks
Dear Zerodha,
I would like to know if the following strategy (or something similar) could be coded:
The idea is to scale-in the trades as price action runs in our favor, to maximize profits due to proper pyramiding, decreasing the impact of unprofitable trading decisions. The script would have to do something like that (Doesnt have to be exactly this but something similar that could be transformed into a code):
Buy at market price and place 3 further pending orders
Sell at market price and place 3 further pending orders
Place a buy stop order at the high of the previous bar and 3 further pending orders
Place a sell stop order at the low of the previous bar and 3 further pending orders
Some other facts you should know:
The first trade has a risk allocation of 2%.
All further pending orders decrease in lotsize to avoid overbetting.
All orders have an ATR-based stop-loss. Default is ATR(30)*2 from the opening price.
All pending orders have an ATR-based distance between them. Default is ATR(30)/2.
Here are some images:
Thank you in advance
Additional info:
/+——————————————————————+
//| PZ_ProggresiveBuy.mq4
//| —
//| This script places four long orders with proper SL settings.
//| The goal is to enter the market progressively as it runs in our favor.
//| Orders have a distance of ATR(30)/2 between each other and lotsize is
//| decreased for each trade to avoid overbetting. Initial risk 2%.
//+——————————————————————+
#property copyright “Copyright © http://www.pointzero-trading.com”
#property link “http://www.pointzero-trading.com”
//—- Dependencies
#import “stdlib.ex4”
string ErrorDescription(int e);
#import
#include <stdlib.mqh>
#include <WinUser32.mqh>
//– Orders to be opened
#define PendingOrders 3 // Amount of pending orders to be added
//– Money management
#define MoneyManagement 1 // Use Money Management
#define LotSize 0.1 // If not, use this lotsize
#define RiskPercent 2 // Risk for initial trade
#define RiskDecrease 0.5 // Risk decrease for the next trade
//– ATR and multipliers
#define ATRPeriod 30 // ATR Period to use
#define ATRStopMultiplier 2 // Multiplier for the initial stop-loss
#define ATROrderMultiplier 0.5 // Multiplier for further pending orders
//– Don’t change me
#define ShortName “PZ Proggresive Buy”
#define MagicNumber 5001
#define Slippage 6
#define Shift 1
//– Internal
double LastOrderLots = EMPTY_VALUE;
double LastOrderPrice;
double DecimalPip;
//+——————————————————————+
//| Custom Script start function
//+——————————————————————+
int start()
{
// Confirm
if(MessageBox(ShortName +” – Do you really want to BUY and place “+ PendingOrders +” BUYSTOP orders?”,
“Script”,MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
// Pip value
DecimalPip = GetDecimalPip();
// Place the first order
PlaceOrder(OP_BUY, GetLotSize());
// Place pending orders
for(int it = 0; it < PendingOrders; it++)
PlaceOrder(OP_BUYSTOP, GetLotSize(), LastOrderPrice + iATR(Symbol(), 0, ATRPeriod, Shift)*ATROrderMultiplier);
// Hi there!
Comment(“Copyright © http://www.pointzero-trading.com“);
// Bye
return(0);
}
//+——————————————————————+
//| My functions
//+——————————————————————+
/**
* Calculates lot size according to risk
* @return double
*/
double GetLotSize()
{
// Lots
double l_lotz = LotSize;
// Lotsize and restrictions
double l_minlot = MarketInfo(Symbol(), MODE_MINLOT);
double l_maxlot = MarketInfo(Symbol(), MODE_MAXLOT);
double l_lotstep = MarketInfo(Symbol(), MODE_LOTSTEP);
int vp = 0; if(l_lotstep == 0.01) vp = 2; else vp = 1;
// Apply money management
if(MoneyManagement == true)
l_lotz = MathFloor(AccountBalance() * RiskPercent / 100.0) / 1000.0;
// Wait! Check if we are pyramiding
if(LastOrderLots != EMPTY_VALUE && LastOrderLots > 0)
l_lotz = LastOrderLots * RiskDecrease;
// Normalize to lotstep
l_lotz = NormalizeDouble(l_lotz, vp);
// Check max/minlot here
if (l_lotz < l_minlot) l_lotz = l_minlot;
if(l_lotz > l_maxlot) l_lotz = l_maxlot;
// Bye!
return (l_lotz);
}
/**
* Places an order
* @param int Type
* @param double Lotz
* @param double PendingPrice
*/
void PlaceOrder(int Type, double Lotz, double PendingPrice = 0)
{
// Local
int err;
color l_color;
double l_stoploss, l_price, l_sprice = 0;
double stoplevel = getStopLevelInPips();
RefreshRates();
// Price and color for the trade type
if(Type == OP_BUY){ l_price = Ask; l_color = Blue; }
if(Type == OP_SELL){ l_price = Bid; l_color = Red; }
if(Type == OP_BUYSTOP) { l_price = PendingPrice; if(l_price <= Ask+stoplevel*DecimalPip) l_price = Ask + stoplevel*DecimalPip; l_color = LightBlue; }
if(Type == OP_SELLSTOP) { l_price = PendingPrice; if(l_price >= Bid-stoplevel*DecimalPip) l_price = Bid – stoplevel*DecimalPip; l_color = Salmon; }
// Avoid collusions
while (IsTradeContextBusy()) Sleep(1000);
int l_datetime = TimeCurrent();
// Send order
int l_ticket = OrderSend(Symbol(), Type, Lotz, MyNormalizeDouble(l_price), Slippage, 0, 0, “”, MagicNumber, 0, l_color);
// Rety if failure
if (l_ticket == -1)
{
while(l_ticket == -1 && TimeCurrent() – l_datetime < 5 && !IsTesting())
{
err = GetLastError();
if (err == 148) return;
Sleep(1000);
while (IsTradeContextBusy()) Sleep(1000);
RefreshRates();
l_ticket = OrderSend(Symbol(), Type, Lotz, MyNormalizeDouble(l_price), Slippage, 0, 0, “”, MagicNumber, 0, l_color);
}
if (l_ticket == -1)
Print(ShortName +” (OrderSend Error) “+ ErrorDescription(GetLastError()));
}
if (l_ticket != -1)
{
LastOrderLots = Lotz;
LastOrderPrice = l_price;
if (OrderSelect(l_ticket, SELECT_BY_TICKET, MODE_TRADES))
{
l_stoploss = MyNormalizeDouble(GetStopLoss(Type, PendingPrice));
if(!OrderModify(l_ticket, OrderOpenPrice(), l_stoploss, 0, 0, Green))
Print(ShortName +” (OrderModify Error) “+ ErrorDescription(GetLastError()));
}
}
}
/**
* Returns initial stoploss
* @param int Type
* @param double ForcedPrice
* @return double
*/
double GetStopLoss(int Type, double ForcedPrice = 0)
{
double l_sl = 0;
if(Type == OP_BUY) l_sl = Ask – iATR(Symbol(), 0, ATRPeriod, Shift)*ATRStopMultiplier – (Ask – Bid);
if(Type == OP_SELL) l_sl = Bid + iATR(Symbol(), 0, ATRPeriod, Shift)*ATRStopMultiplier + (Ask – Bid);
if(Type == OP_BUYSTOP) l_sl = ForcedPrice – iATR(Symbol(), 0, ATRPeriod, Shift)*ATRStopMultiplier – (Ask – Bid);
if(Type == OP_SELLSTOP) l_sl = ForcedPrice + iATR(Symbol(), 0, ATRPeriod, Shift)*ATRStopMultiplier + (Ask – Bid);
return (l_sl);
}
/**
* Returns decimal pip value
* @return double
*/
double GetDecimalPip()
{
switch(Digits)
{
case 5: return(0.0001);
case 4: return(0.0001);
case 3: return(0.001);
default: return(0.01);
}
}
/**
* Normalizes price
* @param double price
* @return double
*/
double MyNormalizeDouble(double price)
{
return (NormalizeDouble(price, Digits));
}
/**
* Get baseline plus deviation
* @return double
*/
double getStopLevelInPips()
{
double s = MarketInfo(Symbol(), MODE_STOPLEVEL) + 1.0;
if(Digits == 5) s = s / 10;
return(s);
}
looks like it will be tricky on algoZ, but you can try on amibroker and use the plugin, check this for knowing more on how you can integrate amibroker onto this: http://www.zerodha.com/z-connect/blog/category/zerodha-amibroker-plugin
Hello,
I am trying to verify some strategies with manually vs alogz.. Here is what I am finding disconnects and need your help to understand the problem. First the expression.. simple one for this e.g.:
Buy Expression: RSI(CLOSE, 21) <40
Sell Expression: RSI(CLOSE, 21) >60
Exit Expression: 0
Chart Type:
Historical 1 year data (EOD) for NIFTY Future Sept 13
The first trade it is showing as:
01/04/2013 12:00:00 AM SHORT 6048.0000
While as per the data table the first trade should be much earlier, see the row from data table:
Date RSI(21)
NIFTY13SEPFUT 07-11-2012 00:00:00 5760.0500 5818.8000 5742.5000 5793.2500 237543 59.4483
NIFTY13SEPFUT 08-11-2012 00:00:00 5744.7000 5776.8000 5740.0000 5765.2000 186408 60.8500
NIFTY13SEPFUT 09-11-2012 00:00:00 5756.2000 5782.1000 5702.6000 5720.6000 211739 58.6069
So as per the Data table the first short should be on Nov. 6, 2012. I plotted RSI(24) on the chart
Please help to understand the problem.
Regards
Hello,
is there any way I can get alert in email or SMS based on the technical triggers like RSI > 70?
Thanks
Hello,
I suspect RSI calculations are not correct by NEST. It seems it shows the RSI value of previous period. For e.g, for NIFTY it is showing RSI(21) – Daily at 57.95 at the end of today (Sept 19), while my own calculations and calculations of another source (investing.com), this value is of Sept 18. Today’s value is 63.23 and I assume it will the value tomorrow (at the end of Sept 20). Please check as it impacts the results of many strategies.
Thanks
Hello,
I want to back test my strategy of 5 minutes time interval over 1 year of data. How can I do that?
Thanks
Presently this data is not available so won’t be possible. We are looking at giving you 5 months of 5 minute data in the next version.
Cheers,
Hello, How can I write a script that first wait for one signal and then second, for e.g. I want to write a script where I wait for RSI(CLOSE,21) < 30 and then EMA(CLOSE,3) < CLOSE. I can't put AND in between as by the time EMA(CLOSE,3) < CLOSE RSI is probably > 30.
Thanks
Hi Zerodha,
I am new in Zerodha and would like to have my Algoz activated.
Account number DA1153.
Also would need your help to code the following two strategies
Strategy1:
Buy : When 5ema (close) crosses over 13ema (close) from below and in stochastics (8,3,4) %K>%D>20
Buy Exit: When %K<%D< 80
Sell: When 5ema (close) crosses below 13ema (close) from above and in stochastics (8,3,4) %K<%D<80
Sell Exit: When %K>%D>20
Strategy 2:
Buy: When stochastics (8,3,4) %K>%D>20 and price crosses above the high of last candle
Buy exit: When price pierces upper bollinger band (20,2) and price crosses below the low of last candle after touching the higher bollinger brand
Sell: When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle
Sell Exit: When price pierces lower bollinger band (20,2) and price crosses above the high of last candle after touching lower bollinger band
Egarly looking forward to your reply. Also, it would be great if you can backtest and suggest about the strategies.
Regards,
Abir
Abir, Find bellow:
Strategy1:
Buy : When 5ema (close) crosses over 13ema (close) from below and in stochastics (8,3,4) %K>%D>20
EMA (CLOSE, 5) > EMA (CLOSE, 13) AND SOPK (8, 3, 4, EXPONENTIAL) > SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) > 20
Buy Exit: When %K<%D< 80
SOPK (8, 3, 4, EXPONENTIAL) < SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) < 80
Sell: When 5ema (close) crosses below 13ema (close) from above and in stochastics (8,3,4) %K<%D<80
EMA (CLOSE, 5) < EMA (CLOSE, 13) AND SOPK (8, 3, 4, EXPONENTIAL) < SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) < 80
Sell Exit: When %K>%D>20
SOPK (8, 3, 4, EXPONENTIAL) > SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) > 20
Strategy 2:
Buy: When stochastics (8,3,4) %K>%D>20 and price crosses above the high of last candle
SOPK (8, 3, 4, EXPONENTIAL) > SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) > 20 AND CLOSE > REF (HIGH, 1)
Buy exit: When price pierces upper bollinger band (20,2) and price crosses below the low of last candle after touching the higher bollinger brand
REF (CLOSE, 1) > REF (BBT (CLOSE, 20, 2, EXPONENTIAL), 1) AND CLOSE < REF (LOW, 1) – Here, it will only check if the price goes below the low of the candle immediately after the candle in which price crosses upper Bollinger band. Won’t be able to code the second half of the condition unless we know exactly how many candles after the prices should breach the low of the candle in which upper Bollinger band was breached.
Sell: When stochastics (8,3,4) %K<%D<80 and price crosses below the low of last candle
SOPK (8, 3, 4, EXPONENTIAL) < SOPD (8, 3, 4, EXPONENTIAL) AND SOPD (8, 3, 4, EXPONENTIAL) < 80 AND CLOSE < REF (LOW, 1)
Sell Exit: When price pierces lower bollinger band (20,2) and price crosses above the high of last candle after touching lower bollinger band
REF (CLOSE, 1) < REF (BBB (CLOSE, 20, 2, EXPONENTIAL), 1) AND CLOSE > REF (HIGH, 1) – Here, it will only check if the price goes above the high of the candle immediately after the candle in which price crosses lower Bollinger band. Won’t be able to code the second half of the condition unless we know exactly how many candles after the price should breach the high of the candle in which lower Bollinger band was breached.
Hi
Hi,
As per your previous reply
It would have been great if there was no user confirmation for the placed algoz strategy, because many users will not be able to sit completely in-front of the system.
please suggest the below changes in software.
Or (confirmation message can be made as optional in the settings )-
or Alert messages should be send as SMS to the registered mobile number.
Thank you
Balu,
Exchanges don’t permit retail clients to completely automate strategies. This would be possible only through a dealer terminal and for dealer terminal you need to be registered with us as an authorized persona and have dealer terminal certifications from NISM.
Alert messages through SMS, let me find out if this is possible and let you know.
Cheers,
Hi Zerodha,
Is there any way in NEST trader, to change the % required in Study lines > Fibonacci retracements tool.?
Currently 0%,38.2%,61.8%,76.4%,85.4%,91.0%,94.4% & 100% are available. For example; if I don’t want the 85.4%,91% and 94.4% (remove), instead need to add 88.6%, is it possible.?
Please advise.
Thanks & Regards,
Ajit
This isn’t possible. Currently only the default percentages are displayed together. You can remove all together or none.
Hi Zerodha,
Can this be added in the future milestones, as all major charting software has the ability to change the % required, also able to enter values manually, change color (from/to) in fibonacci retracement properties.
Thanks & Regards,
Ajit
Hi,
1. I have written the algoz code in the attached screenshot for
buy signal when 3 EMA break 15 EMA and RSI(14) > 30
sell signal when 15 EMA break 3 EMA and RSI(14) < 70. Please let me know if any mistake from below code. CROSSOVER(EMA(CLOSE, 3), EMA(CLOSE, 15)) AND RSI(CLOSE, 14) >30
CROSSOVER(EMA(CLOSE,15), EMA(CLOSE, 3)) AND RSI(CLOSE, 14) < 70 2. I would like to know how this strategy is executed ? whether this strategy is executed automatically or it just gives alert message ? ( because buy signal already generated long back according to my Time frame 30 min chart) 3. would the strategy be live all the day ?
1.This code is proper.
2. It generates an alert through which you can execute the order. You have to confirm by clicking on the Act on Alert button in the alert window, which will invoke the Buy or Sell order entry window, from where you can place the order. Orders will not be placed without user confirmation.
3. Yes, if no start/ end time is mentioned
NSE F&O – 15 Minuts Candel Chart
———————————————-
Get First 15 minutes close price and open price – find whether the close price is above or below open price. If it is below, then consider it as 1st DOWN or if it is above, then consider it as 1st UP
Get the next 15 mins close price.
Use the 1st 15 mins close price and compare with the next 15 mins close prices. If the next close price is below the 1st close price, then consider it as 2nd DOWN and use this close price for finding the next DOWN close price. If close price is above the first close price, then consider it as 2nd UP close price.
Find the next close using the last DOWN close price, till it becomes 3rd DOWN.
Like point 5, calculate for 3rd UP.
If any stock becomes 3rd DOWN, then check for next open price, if the DOWN stock goes down, then short the stock or if it goes above buy the stock
Condition for BUY -> 15 paise up for 100 rupees.
Condition for SELL -> 15 paise down for 100 rupees.
Buy Alert Expression:
REF (CLOSE, 3) > REF (OPEN, 3) AND REF (CLOSE, 3) < REF (CLOSE, 2) AND REF (CLOSE, 2) < REF (CLOSE, 1) AND OPEN > REF (CLOSE, 1)
Sell Alert Expression:
REF (CLOSE, 3) < REF (OPEN, 3) AND REF (CLOSE, 3) > REF (CLOSE, 2) AND REF (CLOSE, 2) > REF (CLOSE, 1) AND OPEN < REF (CLOSE, 1)
Condition for BUY -> 15 paise up for 100 rupees. – didn’t understand; is this in conjunction with the conditions mentioned above?
Condition for SELL -> 15 paise down for 100 rupees. – didn’t understand; is this in conjunction with the conditions mentioned above?
Buy exit will Active only and after BUY Expression satisfied right? If yes then can i pass/set the data or variable of BUY expression to Buy-exit expression?
Yes, buy exit will be active only after buy condition satisfied.
Can you give an example for the 2nd part of the question.
As u mentioned Buy-exit will active only after buy condition satisfies.
Buy expression
example: SET A =avg(HIGH,5)
LAST<=A
SET B=LAST
Buy expression end
can i Use the A & B values(which we used in BUY expression and active for BUY) in BUY-exit expression? as A is variable which is keep on changing with each candle and B is Buy executed price.
If you use the same A & B values in Buy Exit, this means both A & B become variables. B value will also keep changing with each candle/ tick. Currently, the system will not store the value of any function.
HI..
How to write buy exit expression after buy-alert (buy price+10)
i mean how to set buy-alert price which is executed on condition in Buy-exit expression?
Pl. help me to write this BUY-exit expression?
In algoZ you cannot really use buying or selling price as a part of condition. So buy exit has to be a separate logic completely.
So you cannot use a buy price +10
HELLOW ZERODHA .PLEASE HELP ME TO WRITE THE STRETEGY.
BUY IF THE NEXT
CANDLE CROSES ABOVE THE FIRST CANDLE WHICH WAS CLOSED ABOVE 21SMA. EXIT BUY WHEN
CROSING BELOW THE LOW OF THE FIRST CANDLE (WHICH WAS CLOSED ABOVE 21
SMA).
AND SELL WHEN THE NEXT CANDLE CORSING BELOW THE FIRST CANDLE WHICH WAS
CLOSED BELOW 21SMA. EXIT SELL WHEN CROSING ABOVE THE HIGH OF THE FIRST CANDLE
(WHICH WAS CLOSED BELOW 21SMA).EXACT AND EARLYH REPLY
EXPECTED.
FAZULUR REHMAN
Buy alert:
REF (CLOSE, 1) > REF (SMA (CLOSE, 21), 1) AND REF (CLOSE, 2) < REF (SMA (CLOSE, 21), 2) AND CLOSE > REF (CLOSE, 1)
Buy exit:
This won’t be possible unless we define how many candles after, the low should be breached, which is not possible to predict.
Sell alert:
REF (CLOSE, 1) < REF (SMA (CLOSE, 21), 1) AND REF (CLOSE, 2) > REF (SMA (CLOSE, 21), 2) AND CLOSE < REF (CLOSE, 1)
Sell exit:
This won’t be possible unless we define how many candles after, the high should be breached, which is not possible to predict.
THANKS SIR . CAN IT BE BUY EXIT… EXIT BUY IF CLOSED BELOW 20 SMA AND SELL EXIT IF CLOSED ABOVE 20 SMA
PLEASE ADD THIS.
How can we write a strategy on following conditions
1.Buy above 5500 and sell below 5495
2.Buy above first minute open price and sell below first minute open price ( First 5 minutes also)
3.Buy above ATP of a particular time (11.am ) and sell below ATP of a particular time( ATP =Average Traded Price)
4.Buy above price goes above 100 sma and sell below price goes below 150 sma
5.Buy above the previous close and sell below the previous close
6 Buy above the previous high and sell below the previous low
pls give me the 6 strategies
1.
CLOSE > 5500 – Buy Alert Expression
CLOSE < 5495 – Sell Alert Expression
2. not possible to define first minute’s open, which is effectively Day’s Open. Only way is to enter the values manually
3. won’t be possible
4. CLOSE > SMA (CLOSE, 100) – Buy Alert Expression
CLOSE < SMA (CLOSE, 150) – Sell Alert Expression
5. can’t define previous close; he will have to enter previous close value manually
6.
CLOSE > DHIGH (2) – Buy Alert Expression
CLOSE < DLOW (2) – Sell Alert Expression
HI, ZERODHA,
All the Backtest results are wrong,then what is the use of it,whenever you give backtest result for a period,the result should include all the trades taken place,most of the times the result start in between.
For eg. if showing Backtested from 08/12/2013 to 08.30.2013,a specific period , software must show all the trades taken place from 12.08.13 to 30.08.13.But software is showing the trades from 20.08.13.does not give you the result of your strategy
when I enquired your people told me ,the result inclusive of 1 trade even,But I can show you no backtest result is getting even if there are 3-4 trades within your backtested period,this is a very serious problem ,
As long as this is a free software,we have to be satisfied,what you give,but we are putting the errors and problems,facing daily as zerodha traders.
If you dont want our suggestions ,we can stop comments.we hope, this to be the best error free,india ‘s No.1 software to trade,and all traders should make use of this.
Sasi,
Will have this checked and replied.
Cheers,
Thanks Zerodha for having algo trading. Please help me with the code for below logic.
This code is based on 1 minute candle and is based on 2 sets of EMA crossover only.
logic for buy entry :
one minute EMA(90) crossing over one minute EMA(390) ( meaning the previous minute ema 90 is less than ema 390) and the ema(90) should also be greater than ema(150)
logic for sell entry :
one minute EMA(90) cutting down one minute EMA(390) ( meaning the previous minute ema 90 is greater than ema 390) and the ema(90) should also be less than ema(150)
Buy:
REF (EMA (CLOSE, 90), 1) < REF (EMA (CLOSE, 390), 1) AND EMA (CLOSE, 90) > EMA (CLOSE, 390) AND EMA (CLOSE, 90) > EMA (CLOSE, 150)
Sell:
REF (EMA (CLOSE, 90), 1) > REF (EMA (CLOSE, 390), 1) AND EMA (CLOSE, 90) < EMA (CLOSE, 390) AND EMA (CLOSE, 90) < EMA (CLOSE, 150)
Can we put the previous close value in our strategy ,as you mentioned? OPEN < 5300 * 0.99 ,in 1 minute or 5 minute?
can we put our value ,if we want to buy if market opens above 5400 like this, OPEN > 5400 * 0.10,IN 1 min. or 5 min.
pls explain, how can I write my strategy,if I want to sell nifty future opens 5 points below 5400 on monday ?
And if I want to buy nifty future if opens 5 points above 5400 ? why sma 1 is not working and not getting backtest result?
Can we put the previous close value in our strategy ,as you mentioned? OPEN < 5300 * 0.99 ,in 1 minute or 5 minute?
Ans: Yes
can we put our value ,if we want to buy if market opens above 5400 like this, OPEN > 5400 * 0.10,IN 1 min. or 5 min.
Ans: Yes
pls explain, how can I write my strategy,if I want to sell nifty future opens 5 points below 5400 on monday ?
Ans: CLOSE > 5395
And if I want to buy nifty future if opens 5 points above 5400 ? why sma 1 is not working and not getting backtest result?
Ans: CLOSE > 5405
SMA (CLOSE, 1) is the same as CLOSE; you’ll need more than 1 bar to compute an average.
Is there anyway to convert Metastock formulas in Algoz format?
Not manually…
If there is any…pl advise.
Regards
All our codes are written in Vector format..You’ll have to arrange to get the codes from Meta stock in Vector format to be able to use it on algoZ..
IN ZT-ALGOZ-MY STRATEGY- Edit option is available but live is not .
What is to be done?
ZT VERSION IS-3.10.57.97.7 .
Pl help.This is a frequent happening.
Regards
Are you getting the Backtest option? Give us your client ID and we’ll have this sorted for you.. You could email it to us..
hi zerodha
i have a question how to take position based on gap up or gap down at open. if it possible using algo z please give me codes for these two strategies
1) taking position for long side or short side based on gap up or gap down at open.
2) avoiding taking any position if there is gap up or gap down at open.
thank you
Nifty,
you can have a condition saying that if closing of present candle is higher than the closing of the previous one, a buy alert to generate. What you have mentioned is not really a strategy, if you can mention when exactly you want to buy and when you want to sell, we will write it for u.
for eg nifty future previous day closing is 5300 and today it opened at 5250 means there is a gap down opening of 50 points whenever there is gap down opening i will take a short position this can be done manually as i have to look for gap down in 5 to 10 futures then a algorithm will make things easy if possible please let me know.
Part of this can be done, but you will have to put in the previous close value and the quantum by which gap up/ gap down occurs.
Taking forward the example,u can enter a condition like:
OPEN < 5300 * 0.99
(This will check if Nifty has opened 1% below the previous close, if yes, then buy or sell. “5300” we’re considering as the previous close, which u will have to change every day manually.)
While taking the strategy live, u can set a start time and an end time of 9:15 to 9:16, so that this condition won’t be checked after the first interval. Evaluate as tick should be checked and interval can be the minimum – 1 minute.
So for each scrip, u would have to create a separate strategy. u can keep the strategy name the same as the scrip name, so that there is no confusion while taking the strategy live.
Hey!! I want to code the following strategy.
I use the following indicators when trading for an Intraday.
– 8SMA and 34EMA
– STOCHASTIC with 0.15 and 0.85
BUY
– When 8SMA crossed above 34EMA and STOCH is above 0.85, Go Long and Exit when the 2 MAS crosses again.
– When 8SMA crossed below 34EMA and STOCH is below 0.15, Go Short and Exit when the 2 MAS crosses again.
Here’s your strategy:
Buy:
SMA (CLOSE, 8) > EMA (CLOSE, 34) AND SOPK (9, 3, 9, EXPONENTIAL) > 85
Buy Exit:
SMA (CLOSE, 8) < EMA (CLOSE, 34)
Sell:
SMA (CLOSE, 8) < EMA (CLOSE, 34) AND SOPK (9, 3, 9, EXPONENTIAL) < 15
Sell Exit:
SMA (CLOSE, 8) > EMA (CLOSE, 34)
Dear Sir,
i have newly account opened client to zerodha.. and my strategy was that follows……….
for Buy:
SMA CROSSOVER(SMA(CLOSE, 5), SMA(CLOSE, 12))
for Sell:
SMA CROSSOVER(SMA(CLOSE, 12), SMA(CLOSE, 5))
for Buy Exit:
0
for Sell Exit:
0
what my problem was:
my strategy not shows a proper exit to cut the profit..
i want a proper exit strategy for exiting our profit..
and another one is that
i want to combine one extra strategy is that directional movement index….follows:
for long:
DIP (21) > DIN (21) AND ADX (21) > 25
for short:
DIP (21) < DIN (21) AND ADX (21) > 25
how to combine the moving average crossover system with the direction movement index system.
Hi Subhash:
The crossover itself should work as an exit strategy, but without any logic for how or when you’d like to exit your position, we can’t really recommend any exit strategy, per say.
You say you’d like to combine these two, using what variables/ parameters? As in, what’s the type of MA, for how many periods, etc… Once you know these fields, we just need to link the conditions with the ADX conditions using the “AND” function.
thanks for quick reply ..
Hi Nithin,
I would like to know if a Keltner Channel overlay is available? If not then is their a way I can code it (Create the indicator). I prefer readings of 20 and 2 on Keltner channel.
Calculations:
There are three steps to calculating Keltner Channels. First, select the length for the exponential moving average. Second, choose the time periods for the Average True Range (ATR). Third, choose the multiplier for the Average True Range.
Middle Line: 20-day exponential moving average Upper Channel Line: 20-day EMA + (2 x ATR(10)) Lower Channel Line: 20-day EMA – (2 x ATR(10))
Please suggest how I can chart the above?
No… ATR is not available in algoZ currently. You can use Amibroker plugin, if you have the AFL for the same.
Cheers,
Dear Sir,
I use 10 day simple moving average to initiate trades. My strategy is as follows:
Buy if price moves up from below and crosses 10 SMA of yesterday;
Sell if price moves down from above and crosses 10 SMA of yesterday
For example:
Nifty Futures Contract closed yesterday at 5600 and the 10 day SMA of Nifty Future at market close yesterday was 5500. So, today I would intiate short only if Nifty breaks below 5500.
However, your system initiates trade by calculating 10 day SMA starting from the live market hours which is not my strategy. The code should look like this:
CLOSE > SMA(CLOSE OF YESTERDAY,10)
Kindly help me code the strategy as mentioned above.
Kind Regards,
Nasrudeen
Buy:
CLOSE > SMA (CLOSE, 10) AND REF (CLOSE, 1) < REF (SMA (CLOSE, 10), 1)
Sell:
CLOSE < SMA (CLOSE, 10) AND REF (CLOSE, 1) > REF (SMA (CLOSE, 10), 1)
What this does is will consider SMA on selected interval, not daily SMA.
I am learner of AlgoZ Trading . Can anybody help me regarding this strategy.
I want to
1.>Sell 5 Lots of Nifty-5800-29-August-PE within 26th August at some predefined value say Rs.450.
2.> If (1.) executed within 26th August 3.10 p.m, Sell 6 Lots of Nifty-5500-29-August-PE @ Market price , just after (1.) executed.
3.> If (1.) and (2.) will not executed within that date @ 3.10 p.m , then SELL bot 5800-PE and 5500-PE ; at the market value of that day after 3.10 p.m
4.> After any of the (1,2,3) orders are executed then , within that money, I want buy some Lots of Nifty-5700-26-Sep-CE s , investing maximum Rs. 1,00,000 @ market value within 26th August 3.29 p.m.
Can anybody help me , what will be the script or commands , I will give ?
My email is [email protected]
With Regards…………
D. Pal
As I mentioned on your other post, this would not be possible as algoZ presently can do only technical analysis based strategies.
Thanks for the code. But the code seems not working. When put to back test, script error displays ” Error: undefined variable ‘HAOPEN”.
Please help.
Regards,
Debjani.
Hi, Firstly I want to congratulate ZEROdha for providing us this platform.
1. I wanted to add CCI over CCI, like wat we do with Stochastics in different parameters and I have failed to figure out a way to do it.
2. Is there a way to enter both buy and sell at same point instead of going back and filling the order form again, Say If i want to buy NF @ 5700 and sell the same when it reaches 5710
and ya congrats on reaching 3rd anniversary 😉
cheers,
and one more thing, how to keep Trailing stop loss
Hi Zerodha,
Please provide code for the following
1.PRICE STYLE : HEIKIN ASHI
2. BUY EXPRESSION:
Heikin Ashi Close> Heikin Ashi Open and Ref(Heikin Ashi Close,1)>Ref(Heikin Ashi Open,1) And Heikin Ashi Close>SMA(Close,10)
3. BUY EXIT EXPRESSION
0
4.SELL EXPRESSION:
Heikin Ashi Close< Heikin Ashi Open and Ref(Heikin Ashi Close,1)<Ref(Heikin Ashi Open,1) And Heikin Ashi Close<SMA(Close,10)
5.SELL EXIT EXPRESSION:
0
Regards,
Debjani
Heikin Ashi won’t be 100% accurate because typically in HA, open is typically average of previous HA open and Previous HA close. In algoZ presently you cannot use previous HA open to defite HA open. We have used previous open in a normal chart, so this should be very close to what you are looking for:
Buy:
SET HACLOSE = (OPEN + HIGH + LOW + CLOSE)/ 4
SET HAOPEN = (REF(OPEN, 1) + REF (HACLOSE, 1))/2
HACLOSE > HAOPEN AND REF (HACLOSE, 1) > REF (HAOPEN,1) AND HACLOSE > SMA (CLOSE, 10)
Sell:
SET HACLOSE = (OPEN + HIGH + LOW + CLOSE)/ 4
SET HAOPEN = (REF(OPEN, 1) + REF (HACLOSE, 1))/2
HACLOSE < HAOPEN AND REF (HACLOSE, 1) < REF (HAOPEN,1) AND HACLOSE < SMA (CLOSE, 10)
debjani Aug 16 2013, 12:27 pm
Thanks for the code. But the code seems not working. When put to back test, script error displays ” Error: undefined variable ‘HAOPEN”.
Please help.
Regards,
Debjani.
[ Click to thank ]
Have you used the SET function as mentioned above? There should be a space between SET and HAOPEN.
Hi,
I wanted to enquire whether it is possible to allow the system to trade entirely by itself once a script is running, rather than it giving prompts and then requiring us to take the action.
It is possible, but not allowed on a retail terminal. You will need a dealer terminal for this and to get a dealer terminal, you will need to get registered as an authorized person with us one time cost of around 6k per exchange, u need to have NISM series 8 certification, pay us dealer rental charges 250/segment/exchange..
Will you please tell me Whether following A & B Expressions are same(Equal) for Algo trading if Not please elaborate each Expression
A) Buy Expression: EMA(Close,3)>EMA(Close,6) AND EMA(Close,6)>EMA(Close,9) AND EMA(Close,3)>EMA(Close,9) AND MACD(15,8,5,EXPONENTIAL)>MACDSIGNAL(15,8,5,EXPONENTIAL) AND RSI (CLOSE, 14) >54
Regards,
Banti
Both are same and should give the same results.
Both the codes are not showing similar results strategies are attached in previous image while attaching results in this blog request to check & confirm
Both the codes are not showing similar results strategies are attached in previous image while attaching results in this blog request to check & confirm
Banti Aug 16 2013, 8:20 pm
Still I have not received feedback for the last blog of Equal Expressions answer given by you for which I have got different results??/
[ Click to thank ]
Banti,
Will get back to you by monday on this.
Nithin
Hi,
I wanted to make use of the price at which the script purchases a scrip as an argument for further processing. Is there any possible way that I could get the price at which the script purchases a security ?
Thanks in Advance. Am sure someone could help me out.
The price at which it is bought cannot really be used in a condition for now.
Zerodha,
If I take fully automated dealer terminal ,can I add my zerodha clients to follow my strategy,with their requests to allow them with sufficient margin ? pls give the reply in detail
2. The fully automated algo trading terminal is different from Nest Trader without i3 ?
Sasi,
We don’t allow anyone to trade on behalf of another person unless it is through the PMS license or any such authorized mechanisms approved by SEBI.
Automated terminal is basically a dealer terminal where you can have i3 or link amibroker or use algoZ and have them all automated.
applying strategy to 30 symbols every time i login is very time consuming task is there any solution for that,like sve applied strategy and symbol for next time?
We are working on it appan, but presently this would be the only way.
Cheers,
Dear Sir, Please suggest me some means to tackle situation similar to the one mentioned below?
Nifty closed @ 5677.9 on 02-08-2013 (Friday). I was having a view that ‘downward momentum is building in the index and it can head lower to 5566 and then 5430’ and also that ‘If there is rebound early next week (i.e this week) the index can move upto 5818 or 5850’.
On Monday 05-08-2013, Nifty open -5682, High-5721, Low-5661, Hence, when High 5721 was reached I thought there is a rebound and accordingly I took position at that level. But Nifty closed at 5685 on that day. Next day, i.e on 06-08-2013 it declined and reached the target of 5566. Hence, there was a loss for me. (I took positions correspondingly in Index futures).
In such a scenario what shall I do? Whether short term reversal mentioned as above could be confirmed from the charts? Or there any other means? Or shall I have to wait and see the closing price even if that means an opportunity lost? Kindly enlighten me as I come across this problem many times.
With regards,
Chella
Chella,
Markets are pretty tricky and your strategy is something which is very important.
What I’d advise is that you were correct in knowing that intermediate trend is down and you buying nifty was putting up a counter trend trade.
The best way to put a counter trade is to reduce your trading size significantly from your normal size or put a very strict stop loss. I guess you probably didn’t do both of that. Check this Blog , he mainly does counter trend but uses options that too out of the money with only a small capital. This works for him, you need to find what works for you. But you need to remember what I mentioned above, the biggest problem with traders is that we are all inclined to take trades assuming that just because it has come down it will go up or vice versa.
best of luck
1) Still I could not find any reply from Zerodha for the issue which I have raised for streaming value of RSI neither I have received call from technical team nor mail
2) See attached Screen shot for Strategy tested results
a) There are seven trades shown by system where in summary it shows only 6 Trades ( No of trades) whether system takes the trades only squared off
(b)Largest loss 48.2 is shown by system But Why No of losing trades is 0 as there is one losing trade
3) What is interpretation for EMA(Close,3)>EMA(Close,6)>EMA(Close,9) while back testing & going live option with above strategy it has given results & there is no problem observed, please elaborate
Hi Banti,
1. The next release should have the fix for the RSI issue
2. If there is an open trade, it doesn’t get considered on number of trades field. Also if this 48.2 loss is because of the open trade, then the number of losing trades will be shown as 0, loss of 48.2 in this case would be MTM loss on the open position. Can’t see the screen shot, can u upload this.
3. Didn’t get what you are saying, are you saying the signals is getting generated correctly or not?
Cheers
Can u send this image to [email protected] , some issue uploading images I guess.
The new release is expected this month for Pulse.
Hi still there is streaming RSI issue observed 2 months later also there is No solution
kindly expedite
Hi
This is Srikanth (RS 0285). I want you to write my strategy. 20 day moving Average. Buy Above 20 day cross over. Sell below 20 day. Also Stchohastic ocillator K% 12, D% 3. Buy Above 12% / 20%. Sell After 85 to 90%. In ten minute time frame.
Also I would like to thank you for providing low cost brokerage. Mr Nitin your valuable inputs on various topics. Also I would request you to improve your charting software. One small hitch is it dosent change according to the time frame. For example if you are in 1, 5, 10, 30, Minute time frame. The next candle does not change. Insted one single candle is displayed. I mean every time frame the candle has to change its position. Your support staff have been good. keep the good work going.
Regards
Srikanth
Srikanth,
How it works on algoZ is that you write a strategy based on the candle size. So we can write a strategy based on 20 candles, if you open on a daily chart it becomes 20 day, if you open on an intraday minute chart it becomes 20 minute average.
Buy:
CLOSE > SMA (CLOSE, 20) AND SOPK (9, 3, 9, EXPONENTIAL) > 12
Sell:
CLOSE < SMA (CLOSE, 20) AND SOPK (9, 3, 9, EXPONENTIAL) < 85
Cheers,
Is there any simple way to add same strategy for all symbol in my watch list like export from excel?
No Appan, presently you will need to add strategy individually to all the scrips.
greetings,
Buy Expression:-
crossover(MACD(26,12,9,EXPONENTIAL),MACDSIGNAL(26,12,9,EXPONENTIAL))
Sell Expression:-
crossover(MACDSIGNAL(26,12,9,EXPONENTIAL),MACD(26,12,9,EXPONENTIAL))
How can i add buy exit expression for 1% profit or 1% loss from the buy price and same for sell exit expression?
Buy exit Expression:-?
Sell exit Expression:-?
Appan,
Buy exit and sell exit can’t be added in terms of % profit, it has to be again a technical condition. You can keep both at 0, in that case if you have bought, the sell expression will be for exit as well as taking a new sell.
Appan
Came across ur query… the script that u have given gives relevant signals but also gives signals at times when crossover has already happened. do u have any addition that can be done to rule out irrelevant signals.
also kindly provide changes for if crossover was to happen below 0 for buy and above 0 for sell.
Regards
Anshuman
Hi…
I want code for this strategy….
market price> yeasterday high then buy
Market price< yesterday Low then sell
Please give me code for this….
also tell me how can i get the monthly results of at least 36 months for this strategy…..
Thanks in advance…
Buy Alert Expression:
Close > DHIGH (2)
Sell Alert Expression:
Close < DLOW (2)
About backtesting, if you run it on historical daily chart, the results may not be the best because on daily chart, the buy/sell will come only end of the day.
If you are looking at backtesting on intraday data, we presently give only 22 days intraday data, so you can backtest on that. The new version of algoZ will have a lot more days of intraday data to backtest on. Check the blog , an example for more.
I Could able to see there is Error in RSI In my previous blog i have attached Images where RSI is not changing as per streaming value of Quote its getting changed only after interval which is of no use & you should take care of this
1) see images 1 where there is Large red candle while RSI is not changed it remains 54.91 at 18:30
2) It gets changed after completion of Candle See image 2 at 18:32 (RSI 33.25)
3) Image 3 shows there is no streaming of RSI at 18.36 also it shows Same RSI 33.25
4) Image 4 shows change in RSI when New candle gets generated
Above Example shows that those who are using RSI will get wrong results & may not Exit if there strategy is based on RSI kindly look into this & resolve it at earliest
My Strategy is As below
if EMA3 crossesEMA6 & EMA 6 Crosses EMA9 with MACD Positive crossover &RSI>54 then I will buy
My Buy Exit will be IF RSI >65 I will Exit
I have coded as below please check & reply is it correct or not
Buy Expression
EMA(Close,3)>EMA(Close,6)>EMA(Close,9) AND MACD(26,13,9,EXPONENTIAL)>MACDSIGNAL(26,13,9,EXPONENTIAL) AND RSI (CLOSE, 14) >54
Buy Exit
RSI(CLOSE, 14) > 65
Sell Expression
EMA(Close,3)<EMA(Close,6)<EMA(Close,9) AND MACD(26,13,9,EXPONENTIAL)<MACDSIGNAL(26,13,9,EXPONENTIAL) AND RSI (CLOSE, 14) < 45
Sell Exit
RSI(CLOSE, 14) <35
(A)Suppose I get buy signal pop up as per my strategy & I act on it with predefined stop loss & my Stategy is working as soon as RSI goes 65 will system automatically square off the buy position or will it show pop up again to square off & I need to click on it please confirm
( B) if I made profit I need to cancel my sell stoploss order Manually or will it get cancelled by system
(C) In above case will system again shows buy order if RSI gets lower upto 56
Kindly confirm
Regards,
Banti
Banti,
Thanks for pointing out the issue, get our tech team to look at this.
As far as your queries go:
Buy expression:
EMA(Close,3)>EMA(Close,6) AND EMA(Close,6)>EMA(Close,9) AND MACD(26,13,9,EXPONENTIAL)>MACDSIGNAL(26,13,9,EXPONENTIAL) AND RSI (CLOSE, 14) >54
Buy exit is correct
Sell:
EMA(Close,3)<EMA(Close,6) AND EMA(Close,6)<EMA(Close,9) AND MACD(26,13,9,EXPONENTIAL)<MACDSIGNAL(26,13,9,EXPONENTIAL) AND RSI (CLOSE, 14) < 45
Sell exit is correct.
Other parts to your query:
A. It will show pop up for exit condition.
B. Stop loss will get cancelled by the system, when exit order gets traded
C. I am little confused on this, if what you are asking is that if SL is already hit, will your buy condition again give a sell, it won’t.
Hope this clarifies.
Cheers,
Banti Jul 30 2013, 7:43 pm
Thanks for Reply in continuation with your answers I have following Queries
1) Whether streaming RSI problem is for all clients of ZT or its for me only whether Technical person will call me?
2) For Point C in previous blog, I mean to say if I bought one lot of Nifty SL is placed as per my predefined % after reaching RSI 65 I close the Position by POP given by system so as stated earlier by you My stop loss order will be cancelled by system, now as on time I am having no open position but after some time let say after 20min RSI decreases to 56 & all other conditions of EMA & MACD are as per my strategy will system show again Buy order here?
Regards,
Banti
[ Click to thank ]
Banti Jul 30 2013, 7:43 pm
Thanks for Reply in continuation with your answers I have following Queries
1) Whether streaming RSI problem is for all clients of ZT or its for me only whether Technical person will call me?
2) For Point C in previous blog, I mean to say if I bought one lot of Nifty SL is placed as per my predefined % after reaching RSI 65 I close the Position by POP given by system so as stated earlier by you My stop loss order will be cancelled by system, now as on time I am having no open position but after some time let say after 20min RSI decreases to 56 & all other conditions of EMA & MACD are as per my strategy will system show again Buy order here?
Regards,
Banti
[ Click to thank ]
1. The tech team is checking out for your issue, if required they will cal you back.
2. Yes if all conditions are satisfied again, you will get another buy …
1) Still I could not find any reply from Zerodha for the issue which I have raised for streaming value of RSI neither I have received call from technical team nor mail
2) See attached Screen shot for Strategy tested results
a) There are seven trades shown by system where in summary it shows only 6 Trades ( No of trades) whether system takes the trades only squared off
(b)Largest loss 48.2 is shown by system But Why No of losing trades is 0 as there is one losing trade
3) What is interpretation for EMA(Close,3)>EMA(Close,6)>EMA(Close,9) while back testing & going live option with above strategy it has given results & there is no problem observed, please elaborate
There shouldn’t be any difference but I would recommend using (B)
EMA(Close,3)>EMA(Close,6) AND EMA(Close,6)>EMA(Close,9) AND MACD(15,8,5,EXPONENTIAL)>MACDSIGNAL(15,8,5,EXPONENTIAL) AND RSI (CLOSE, 14) >54
But Option A has given Better results as compared to option B in backtesting? as told earlier if basic is same why it is not delivering same results
Please give me the code for below strategy:
Buy if 3 min ema is above 13 min ema and 13 min ema is above 34 min ema.
exit long if 3 ema crosses below 34 ema.
and vice versa for sell
Thanking you
Buy:
EMA (CLOSE, 3) > EMA (CLOSE, 13) AND EMA (CLOSE, 13) > EMA (CLOSE, 34)
Buy exit:
EMA (CLOSE, 3) < EMA (CLOSE, 34)
Sell:
EMA (CLOSE, 3) < EMA (CLOSE, 13) AND EMA (CLOSE, 13) < EMA (CLOSE, 34)
Sell exit:
EMA (CLOSE, 3) > EMA (CLOSE, 34)
Hi,
I want to develop a simple strategy on My AlgoZ platform.
Time Frame – 30 Minute intraday Futures candles.
– if Last > Open of each candle then Buy
– if Last < Open of each candle then Sell
– if Long the exit at closing price of the 30 Min candle
– if Short then cover short at the closing price of the 30 Min candle
Note:
If the Last goes above and below Open price of the 30 min candle 10 times the position should change all 10 times.
Kindly guide.
Thanks!
Sam
Sam,
On algoZ, you will generate only one signal per candle,
Buy expression: Close>open
Sell expression: Close<open
When you are taking a strategy live, if you click the option evaluate as a tick, orders will be generated in between the candle instead of waiting for your candle to complete. But as I mentioned earlier it won’t give more than 1 signal per candle.
So some of the things you have mentioned won’t be possible to code.
Where i can get the data of advances issues and decline issues ?
or we have charts of the same ?
Zerodha doesn’t yet provide Advance/Decline Ratio on our charting platform. Your best option would be to check it out on the NSE website or on moneycontrol.
Please tell the code for :
ALERT TO BE GENERATED ON 3 MINUTE CHART.
for Nifty
Sell condition MACD -ve Crossover
then semi-auto sell will be 5 points below the closing bar (the bar how satisfied condition of sell ) and SL will be the top the same bar.
Buy condition MACD +ve Crossover
then semi-auto buy 5 points above the closing bar (the bar how satisfied condition of Buy ) and SL will be the bottom the same bar.
Sell:
MACD (26, 13, 9, EXPONENTIAL) < MACD (26, 13, 9, EXPONENTIAL).
Buy:
MACD (26, 13, 9, EXPONENTIAL) > MACD (26, 13, 9, EXPONENTIAL)
While going live, you can enter an offset of Rs. 5, which will be applicable for both Buy and Sell. SL – you can define in terms of % using Stop Loss Trigger %.
Please tell the code for :
ALERT TO BE GENERATED ON 3 MINUTE CHART.
for Nifty
Sell condition
MACD -ve Crossover and CCi below 0 (Zero ) line
then sell 5 points below the closing bar (the bar how satisfied condition of sell ) and SL will be the top or 5 points above the same bar.
Buy condition ( for Buying call )
MACD +ve Crossover and CCi above 0 (Zero ) line
then buy 5 points above the closing bar (the bar how satisfied condition of Buy ) and SL will be the top or 5 points top of the same bar.
Sell
MACD (26, 13, 9, EXPONENTIAL) > MACD (26, 13, 9, EXPONENTIAL) AND CCI(12, SIMPLE) < 0
Buy
MACD (26, 13, 9, EXPONENTIAL) > MACD (26, 13, 9, EXPONENTIAL) AND CCI(12, SIMPLE) > 0
While going live, you can enter an offset of Rs. 5, which will be applicable for both Buy and Sell. SL – you can define in terms of % using Stop Loss Trigger %.
Please tell the code for :
ALERT TO BE GENERATED ON 15 MINUTE CHART.
Short Sell
CCI ( commodity channel index ) Period 14 is crossing +100 downside or CCI value Less than +100 and MACD -Ve Cross over
for Long
CCI ( commodity channel index ) Period 14 is crossing -100 upside or CCI value greater than -100 and MACD +Ve Cross over
Dear sir nithin kamath
please mack code for this stratagy
for buy
if price above 60ema and 42-RSI-40 level above then buy
and for sell
if price below 60ema and 42-RSI 60 level below then sell
br
tirumal
Your buy expression would be: Close>EMA(Close,60) AND RSI(Close,42)>40
Your sell expression would be : Close < EMA(Close,60) AND RSI(Close,42) < 60
Please tell the code for :
ALERT TO BE GENERATED ON 1 MINUTE CHART.
RSI-CLOSE-14 PERIOD ON 5 MINUTE CHART IS >60 AND
RSI -CLOSE-14 PERIOD ON ONE MINUTE CHART IS <30
WHEN RSI ON ONE MINUTE CHART IS LESS THAN 30-PLEASE GENERATE THE ALERT.
REGARDS.
Chintamani,
On algoz you cannot code a strategy on 2 different time intervals at once. So we cannot combine a 1 minute and a 5 minute chart.
Cheers,
Can we explore the possibility of doing this?
Please consider the idea of the same.
Every trade consists of the tIck and then the same is converted to timeframes.Timeframe is nothing but total number of trades during the same interval.
Here we are exploring an idea to evaluate the base structure i.e.one minute chart and then when such five minutes are completed ,we call the same as 5 minute chart …so on and so forth.
Considering the fact that “WHEN FIVE CANDLES ARE COMPLETED IN ONE MINUTE CHART”=ONE CANDLE IS SAID TO HAVE BEEN COMPLETED ON A 5 MINUTE CHART.
Here for e.g
The open on ref(open ,5 ) can said to be the open on a five minute chart -but defined on a one minute chart.
The close for the five minute chart will be the same as a close on one minute chart,but after completion of five minutes.
THE HIGHEST HIGH VALUE OF THE FIVE CANDLES ON A ONE MINUTE CHART IS THE HIGH ON A FIVE MINUTE CHART.
AND LOWEST LOW VALUE OF THE FIVE CANDLES ON A ONE MINUTE CHART IS THE LOW ON A FIVE MINUTE CHART.
SO A FIVE MINUTE CANDLE ON ONE MINUTE CHART MAY BE DEFINED AS:
OPEN-REF(OPEN ,5)
CLOSE-CLOSE
HIGH-HIGHEST HIGH VALUE OF THE FIVE CANDLES -SORRY BUT I DO NOT KNOW THE CODE FOR THE SAME.
LOW-LOWEST LOW VALUE OF FIVE CANDLES -HERE TOO I DO NOT KNOW CODE FOR THE SAME.
Once defined,a correlation to the other factors may be possible.
This, if possible, may be extended to other data array as RSI, MACD ETC.
This may make us trade RSI when it is below 30 on one minute chart and above 60 on five minute chart.
I am not able to extend the idea further……
Kindly correct if wrong and please extend the idea if correct and code the strategy for the benefit of all.
Perhaps it may help all to have combination in various ways for trading their own ideas.
Best Regards
Chintamani.
On algoZ as I had mentioned you can’t combine 1 and 5 min candles. The problem with calculating the way you have mentioned is the signal won’t be accurate. But let me find this out and let you know.
Cheers,
Nithin
Like DHIGH(2) and DLOW(2) , are there functions for previous day’s OPEN and CLOSE ?
Vijay,
DHIGH() , DLOW() will give you the high and low of that particular day. There is no function presently for open and close for that day.
DHIGH(1), DLOW(1) will be today’s high and low
DHIGH(2), DLOW(2) will be yesterday’s high and low
So on ..
Zerodha,
Can I give a code for my strategy? like this?
For example. REF A = EMA(Close,13)>EMA(Close,50).
REF B = EMA(Close,13)<EMA(Close,50)
Buy expression REF A
Sell expression REF B
OR SOMETHINGELSE ? pls give me an answer at the earliest.
Sasi,
A correct way to do this would be:
SET REF A = EMA(Close,13)>EMA(Close,50).
SET REF B = EMA(Close,13)<EMA(Close,50)
Buy expression REF A = TRUE
Sell expression REF B =TRUE
Cheers,
where should I save set ref B
Buy:
Set REF A = EMA(Close,13)>EMA(close,50)
REF A= TRUE
Sell:
SET REF B = EMA(Close,13)<EMA(Close,50)
REF B = TRUE
Hi Zerodha,
Could you please help me code with the following:
Buy: PSAR crosses above price, MACD above signal line, RSI less than 40, AROON > 70
Sell: MACD below signal line
I did try some expressions with the info above, but strangely they do not show signal points where they ought to be as per my criteria.
Best regards,
Sim
Buy:
PSAR (CLOSE, 0.02, 0.2) > CLOSE AND REF (PSAR (CLOSE, 0.02, 0.2), 1) < REF (CLOSE, 1) AND MACD (26, 13, 9, EXPONENTIAL)> MACDSIGNAL (26, 13, 9, EXPONENTIAL) AND RSI (CLOSE, 14) < 40 AND AROONUP (14) > 70 and AROONDOWN (14) > 70
Sell:
MACD (26, 13, 9, EXPONENTIAL) < MACDSIGNAL (26, 13, 9, EXPONENTIAL)
Zerodha,
As stated earlier, have you introduced next version of Z Trader in place of present beta version? If not,please mention the expected time when next version will be introduced.
Regards,
RD
ZT is a live full version. If you are talking about algoZ, this piece where you can write strategy and backtest etc, we are yet to release the updated version.
Sir,
I have back tested the following strategy:
Buy : CROSSOVER(CLOSE, PSAR(CLOSE, 0.02, 0.2)) = TRUE (Close > PSAR)
Sell : CROSSOVER(PSAR(CLOSE, 0.02, 0.2), CLOSE) = TRUE (Close < PSAR)
The above mentioned strategy generated few buy sell signals. To check I have added PSAR indicator (0.02,0.2) in the chart. The signals generated by the back test results are not matching with the signals generated in chart by indicator. Please clarify.
There is some issue with psar, speaking to the tech team on this and will get back to you
Please provide code for the following
A = ((Previous High + Previous Low)/2)+10
B = ((Previous High + Previous Low)/2)-10
Buy if close (current) cross above B from bottom
Sell if Close (current) cross below A from Top
If you are referring to the previous Day’s high and low then,
Buy Alert Expression:
SET A = ((DHIGH (2) + DLOW (2))/2) + 10
SET B = ((DHIGH (2) + DLOW (2))/2) – 10
CLOSE > B AND REF (CLOSE, 1) < B
Sell Alert Expression:
SET A = ((DHIGH (2) + DLOW (2))/2) + 10
SET B = ((DHIGH (2) + DLOW (2))/2) – 10
CLOSE < A AND REF (CLOSE, 1) > A
If you are referring to previous candle’s high and low then,
Buy Alert Expression:
SET A = ((REF (HIGH, 1) + REF (LOW, 1))/2) + 10
SET B = ((REF (HIGH, 1) + REF (LOW, 1))/2) – 10
CLOSE > B AND REF (CLOSE, 1) < B
Sell Alert Expression:
SET A = ((REF (HIGH, 1) + REF (LOW, 1))/2) + 10
SET B = ((REF (HIGH, 1) + REF (LOW, 1))/2) – 10
CLOSE < A AND REF (CLOSE, 1) > A
zerodha,
when we go live ,there is a window,we have to select execution period,product type,
Can this software keep our strategy , as GTC ( good till cancel) so that we can avoide login everyday , on automated trading.If the margin is sufficient the trades will automatically take place according to the strategy
Which one , NISM or NCFM is sufficient for your dealer terminal ?
pls reply at the earliest,delayed replies ,block this blog active———–
Even if you automate your trade completely, you will still need to take strategies live everyday.
Yes if you have a dealer terminal, you can automate your trades.
YOu need this exam: http://www.nism.ac.in/index.php?option=com_content&view=article&id=375&Itemid=299
along with this certification you will need to become an authorized person on the exchange with us and also rent the dealer terminal. One time cost of Rs 5000 to become an AP on exchange and Rs 250/month/segment/exchange for dealer terminal charges.
hi i need help in coding my strategy
time frame 5 min
buy / exit short: when two consicutive close above ema of high for period 144
short / exit long: when two consicutive close below ema of low for period 144 thanks
Buy: CLOSE > EMA (HIGH, 144) AND REF (CLOSE, 1) > EMA (HIGH, 144)
Sell: CLOSE < EMA (LOW, 144) AND REF (CLOSE, 1) < EMA (LOW, 144)
Is there any incentive if I share ALGO Z strategies?
Yes Vijay,
If you have a profitable strategy let us know, we can blackbox it and show with backtesting results to all our readers/clients. We could get them to get your strategy for a price, which can be shared with you.
Let us know,
Cheers,
Please let me know how to take this forward. I have also sent an email
Vijay
We are working on putting up something, will let you know as soon as the interface is ready..
HI
ZERODHA
can you code
for buy
after 3 pm price above 10 MA
in above comments i know that time based strategy is not formed but as in one comment i read using candle close we can do that i use 5 min candle please help in that
Don’t know how I couldn’t think of it earlier.
Use the same code Close>SMA(close,10) but in alert preference keep the start time as 3pm.
Hopefully this helps.
Cheers
that’s a great idea and thank for that
Hi Zerodha,
Yesterday I had sent report(contract note and Screenshots) where false signals were generated during live hours from pulse. I had lost 22000 on 24 June because of that. I had also put Nithin in cc. Could you please let me know what went wrong? I also see many people complaining that false signals are generated during live hours. Is the AlgoZ reliable? I am in touch with Omneysys regarding this but could you also look into it? A little effort from your side would be helpful for traders like me.
Best regards,
Akhilesh
Akhilesh,
We are looking into your issue, I guess it has got to do with alert preference, will get back to you soon on this.
It is absolutely possible that backtesting and live doesn’t match, based on when you go live and the alert preferences chosen.
You went live on a strategy at 10am, at the end of the day you backtest and see that it doesn’t match. The reason is because when you are backtesting it is taking from beginning of the day and not when you went live.
But that said, we are retesting to see if there is any issue with generation of false signals.
Hi Zerodha,
Thanks for your reply.
I went live before 9:15 AM. As you can see from the contract note trades were done as early as 9:35 AM. Also my Alert preference was set to “Place from Signal price”.
hi
akh64bit
can you share want error leads to this huge loss for you if you share this will be help ful for me also becouse this has happened to me also like some time we set interval as 5 min but signals are genrated on 1 minutes chart
please share with us also the screen shot
thank you
A big thank you and thumbs up for your team’s efforts.
I have some request for coding my MT4 strategy into AlgoZ, so that i can benefit from that.
My strategy is as below:
Buy:
1.) CLOSE> 5EMA displaced by 5 periods forwars2.) 4EMA -5EMA positive crossover3.)RSI should be above 50 and should be above the signal line (or whatever you can suggest with RSI, MACD, STOCH etc will be most welcome.)
Buy Exit:
If close < last 5 bar low.
Sell:
1.) Close< 5EMA displaced by 5 periods forward. 2.) 4EMA-5EMA negative crossover3.) RSI should be below 50 and should be below the signal line.
Sell exit:
If close> last 5 bar high
I am attaching a snapshot of my MT4 chart for better understanding.
I would be highly thankful to you guys if you get it done….
Buy:
REF (CLOSE, 5) > EMA (CLOSE, 5) AND EMA (CLOSE, 4) > EMA (CLOSE, 5) AND RSI (CLOSE, 14) > 50 AND MACD (26, 13, 9, EXPONENTIAL) > MACDSIGNAL (26, 13, 9, EXPONENTIAL)
Yes,I agree with Niftytrader,I have some suggestions for the ALGOZ.
1.Backtest results are not same as live signals,on any timeframes,you can test,I have tested.
2.Backtest results are not as per your specified period given on result window on any timeframe.
3.If you specify a period from 03.06.13 ,pls show the result from the next signal onwards,as per strategy and dont show the signal and result in between,will mislead the backtest result
4.we are not getting backtest results for the same strategy working , if there is 1 or 2 results on higher timeframes.
5.Occassionally we have lost ,the strategies that we have saved on NESTTRADER.
pls consider this as the suggestion of a wellwisher,and not as a critic
we expect the best ,from you ,we know you can do it.
All suggestions are taken in good faith, this product still has a long way to go and the journey will be faster with constructive feedback.
Cheers,
hi
i have coded above strategy using your comments on above query by other folks on this page but i am very disappointed with ALGO Z. I say NAAM BADE AUR DARSHAN CHHOTE which i think suits best for ALGO Z but on expected lines a free product work like that only.
ALGO Z is working very fine and showing good results in back testing as per my strategy it works well and given signal only when it occurred but when i take it live then what a disaster happens to ALGO Z it started giving false signals it has given almost 20 false signal to me thank god i am using semi automate version other wise i may be bankrupted today and after market close i again back test to see weather it gives this signal again or not and i am surprised it has only given one signal which is as per my strategy so i want to know why ALGO Z has not working good in live mode and giving false signals please rectify this problem in this product and make it more professional so that retail traders can take advantage of that
thank you
hope to see some improvement in this product in future
and one thing i have to only relay on my eyes and brain not on this ALGO Z
Hey Nifty,
It is important that you set the alert preference correct before taking the strategy live.
Check this blog on managing your script: http://www.zerodha.com/z-connect/blog/view/managing-your-script
If you are backtesting on a 5min candle, when you take live, you need to set interval to 5mins.
Also if you have ticked on evaluate as tick, order will trigger even before the completion of the candle.
If you are following all these correctly, i’d appreciate if you send me the screen shots of such triggered orders. send them to [email protected]
Cheers,
i researched on this and found that the problem is not in ALGO Z but in nest plus chart it has stopped forming new candle in my case in every 5 minute insted of that all data is updated in one candle only for eg at 12:55 candle is running 9:35 with current price and volume is huge means all volume and price event after 9:35 is shown in single candle it happens today also with me but when i re login to system charts started updating so zerodha please tell me why this problem occurred and how to avoid this in future as you know after re login you have to again run each and every strategy from start and have some other issues in it
thank you
Point noted, will bounce it off the tech team.
hi
ZERODHA
code this strategy for me
for buy
5 minute candle close above 5 MA and 20 MA and in stochastic oscillator %K above %D and ADX above 20
thank you
Sir,
I have less knowledge about coding. So please explain in little simple words. Firstly, I want to know which software do I need to run the code?
Secondly, I want alerts only. When price pierces upper or lower bollinger band on 30 mins or Dly TF, I want an alert.
Third, to get these alerts, should the chart be open?
Thanks,
Rahul
Rahul,
Can you check out the following 2 blogs, will show you how exactly it works.
http://www.zerodha.com/z-connect/blog/view/algoz-a-simple-example
http://www.zerodha.com/z-connect/blog/view/managing-your-script
Rahul,
Can you check out the following 2 blogs, will show you how exactly it works.
http://www.zerodha.com/z-connect/blog/view/algoz-a-simple-example
http://www.zerodha.com/z-connect/blog/view/managing-your-script
Rahul123Jun 20 2013, 12:30 pm
On both the links it is not mentioned if my chart needs to be open to get the alert. Meaning if my chart is not open, and I have a buy signal, will it give me an alert that so and so stock has met the condition?
Thanks.
[ Click to thank ]
Rahul,
You will have to open a chart and take the strategy live. Once you have taken the strategy live, even if you close your chart you will get an alert as shown in the blog ” managing your script”.
Here i am sending the chart of Colgate.of-17-06-13. There are 4 trades on red line but, the back test results are not found so please check out-
Can you tell me what the strategy is, that you are backtesting?
Zerodha,
Your backtest results are not getting properly,
How many trades should be there minimum to get the results ? 4 or 5 ?
Today showing the results from 27-05-13, but not getting the results as you see on the charts
pls clear my doubts
You should get a bactest result even if there is only 1 trade. You have forgotten to attach the chart.
HI Zerodha,
I want to write code for Nifty Fut. Buy@ open with 10 points SL?
Vin,
Buy at open is not really a technical strategy and there is no real use of algoZ for this.
Hello,
I need to code the strategy where
buy when william % is lesser than -80 and heikin ashi candles is green
and sameway
sell when william % is greater than -20 and heikin ashi candles is red
Also how do i write code for
buy when william % is <-80 and sell when its value is 5 points lesser than previous one. (say if its current value is 60 and than i want to sell it if it comes to 65)
Do we have ichimoku kinko hyo?
Thanks
Hello,
Any help will be appreciated.
Thanks
Sorry for the delayed response, Mitch. We had to get someone to code your strategy for you. 🙂
buy when william % is lesser than -80 and heikin ashi candles is green
SET HOPEN = (REF (OPEN, 1) + REF (HCLOSE, 1))/ 2
and same way
SET HCLOSE = (OPEN + HIGH + LOW + CLOSE)/ 4
WPR(14) > -20 AND HCLOSE < HOPEN
Buy: WPR (14) < -80
Do we have ichimoku kinko hyo?
Hello,
Thanks fo the code but its not working, none of them are working, when i try to save the code it gives me error “Please write a valid Expression”
Kindly check if i have done something wrong or code has issues
Thanks
Mitch,
If you don’t have separate exit expression for buy and sell mention a 0. If you leave the buy exit and sell exit blank, you will get this error..
Hello,
Thanks. With adding of 0 it saves properly but results are completely wrong, with that backtesting does not show more buying and selling singal as it should be with what code should do.
Here is the screenshot
Hello,
I have made some changes to the code its somewhat working but i want to make some changes
For eg. as per our code buy when william % is greater than 80 and heikin ashi green candle and vice versa
Problem with that is even if william % is coming down and if green candle is there it will trigger buy, so what i want here is buy should only happen when william % is crossing -80 from that is like from 100 to 90 to 80 rather than while falling.
Same with sell expression i want to short only when william % is crossing -20 from higher up that and not when it reaches from bottom.
Also here in the code we are checking for close green candle, but what i want is that buy should happen when current candle is turing green (rather than waiting to close in green) and william % is crossing -80 towards upside.
Exit Expression
In buy exit expression i want to exit when william % is falling with red candle and same with sell exit expression i want to exit when william % is rising with green candle.
I am sorry its long thing and i hope i am clear putting it here. Your help will be really appreciated.
WPR (14) > – 80 AND REF (WPR (14), 1) < -80 – this means it was less than -80 in the previous candle and greater than -80 in the current candle.
Heikin Ashi code is the same, which was given earlier. If you want the signals in between the interval instead of waiting for the close, you should tick the checkbox for evaluate as tick in live (alert preference) window.
For sell expression: WPR (14) < – 20 AND REF (WPR (14), 1) > -20
Your buy exit and sell exit is similar to your buy/sell expression, so you could just mention a 0.
Hi Zerodha,
I wanted to know more about Algoz and wanted your help in building a strategy. Please help me out with the same
1. buy – when 13 ema crosses 50 ema with the 20 paisa price filter
2. sell – when 50 ema crosses 13 ema with 20 paisa price filter
required in 5 min time frame…
Deepak,
When you write a strategy you don’t choose the time frame. You choose the time frame when you are going live. Check this blog on Managing your script
Also to set how you want to buy once the signal has initiated a trade, use the alert preferences mentioned on the blog.
When you are backtesting, you will get an intraday chart with 1 min by default, change this to 5 mins and then backtest the strategy.
Your code is pretty simple and explained above:
Buy: EMA(Close,13)>EMA(Close,50)
Buy exit: 0
Sell: EMA(Close,13)<EMA(Close,50)
Sell exit: 0
Kindly code this strategy for me…
Strategy 1:
Enter at the 50 points above or below the open price for Bank Nifty. And Keep trailing the SL to 50 points.
After it exits, again the entry would be 50 points above or below. (50 points above Long and 50 points below short)
Shaan, unfortunately this strategy won’t be possible on algoZ. You can try lots of other strategies that are workable on algoZ or you can try our Zerodha Trading Plugin with AmiBroker.
CAN YOU CODE BELOW STRATEGIES.
1.BUY( LONG) ABOVE OPENING PRICE
SELL (SHORT) BELOW OPENING PRICE
2.BUY (LONG) ABOVE AVERAGE TRADED PRICE (ATP LINE)OR WEIGHTED AVG.
SELL (SHORT) BELOW (ATP LINE) OR WEIGHTED AVG.
Here you go…
CLOSE > OPEN (of the candle/ interval)
CLOSE < OPEN
ATP/ Weighted average price isnt available, but we have something called Weighted Close, which is basically an average of a candle’s open, high, low and close values, where more weightage is given to the close price. If this can be used, the code will be CLOSE > WC()
Hope this helps.
dear siir
1si startegy -ema 8/18 crossover after that buy & sell sighal &sl previous candel s high=low &macd 12/26/9 when rsi is above 40 buy it &below 60 after sell it pl. advise me how to wrie this code dear sir iam not a pl. yo adivce me also which strategy is sutaible 7strategy provider is avaliable pl. told me
with regards
sudhir biranje
8087566996
1. EMA crossover:
Buy: EMA(Close,8)>EMA(Close,18) Sell: EMA(Close,8)<EMA(close,18)
2. MACD Strategy:
Buy:
MACD(26,12,9,EXPONENTIAL)>MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI(Close,10)>40
Sell:
MACD(26,12,9,EXPONENTIAL)<MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI (CLOSE,10) < 60
sir,
1.can i make a strategy on 2000 sma on 1 min. in this version?
2.is it limited to 1000 now?
3.can you provide us in the next version atleast ?
4. we have a group of traders waiting for it,so pls provide 2000 sma , atleast on 1 minute chart.
pls give me a reply at the earliest.
Curr,
Currently the limit is 999 candles and don’t think we can increase this number soon.
how to write a code to add two closing price at specific time, X=close at 10:30:59 am + close at 2:05:59
You can’t mention specific times, but you can say how many candles before the current candle using the REF function.
Suppose, you have an hourly chart and your intervals are 10:00:00, 11:00:00, 12:00:00 and so on.
Current time is 12:00:00, then
CLOSE denotes closing price of the candle at 12:00:00
REF (CLOSE, 1) denotes close at 11:00:00
REF (CLOSE, 2) denotes close at 10:00:00
when can we expect algoz in mcx . next version of algoz??
We are hoping to have it soon, MCX hasn’t given approvals for this product yet..
sorry i posted the backtest signals for 45 sma rejection in seperate comment
sir i want to code for buy when 45 sma rejection occurs. when i enter the following code, it shows entry signals at wrong places
buy: (sma(close,45)>ref(1,low))and ( close>sma(close,45) )
Hi Zerodha,
A quick question: is there any possibility of getting the Super Trend Indicator onto the Intraday and Historical Charts on Nest Trader / Nest Plus?
Please let me know.
Thanks,
Sid
Sid,
In the present version it won’t be possible, but we are working on getting it live..
Yes I see the backtest result and the live popup rates are different on the same strategy.pls clarify,
You can conduct a monthly workshop for zerodha traders, on working days ,in zerodha branches to clarify the doubts,and disscuss these kind of problems,and open a new window to handle these issues.
We are planning on an online initiative for this, will keep you all updated..
Cheers
Hi The strategy is given below with the logic.
Please advise if it is correct in programming language or otherwise.
Strategy: Buy Expression-0
Buy Exit Expression-0
Sell Exit Expression-0
Sell Expression-
HIGH>=OPEN AND
OPEN>CLOSE AND
CLOSE>=LOW AND
LOW<REF(LOW,1) AND
CLOSE<REF(LOW,1) AND
CLOSE>=REF(OPEN,2) AND
REF(OPEN,3)=REF(OPEN,2)AND
REF(HIGH,1)>=REF(OPEN,1) AND
REF(OPEN,1)>=REF(CLOSE,1) AND
REF(CLOSE,1)>=REF(LOW,1) AND
REF(LOW,1)>=REF(OPEN,2) AND
REF(HIGH,1)<=REF(CLOSE,2) AND
REF(HIGH,2)>REF(CLOSE,2) AND
REF(CLOSE,2)>REF(OPEN,2) AND
REF(OPEN,2)>REF(LOW,2) AND
REF(HIGH,3)>=REF(OPEN,3) AND
REF(OPEN,3)>REF(CLOSE,3) AND
REF(CLOSE,3)>=REF(LOW,3) AND
REF(HIGH,2)>REF(HIGH,3) AND
REF(HIGH,2)>REF(HIGH,4) AND
REF(HIGH,2)>REF(HIGH,5) AND
REF(HIGH,2)>REF(HIGH,5) AND
REF(HIGH,2)>REF(HIGH,6)
Expression complete.
LOGIC OF EXPRESSION
HIGH IS GREATER THAN OR EQUAL TO OPEN PRICE AND(PRESENT CANDLE )
OPEN IS GREATER THAN CLOSE AND
CLOSE IS GREATER THAN OR EQUAL TO LOW PRICE AND
LOW IS LESS THAN PREVIOUS CANDLE LOW AND
CLOSE IS LESS THAN PREVIOUS CANDLE LOW AND
CLOSE IS GREATER THAN OR EQUAL TO PRIOR TWO CANDLE OPEN AND
PRIOR THREE CANDLE OPEN IS EQUAL TO PRIOR TWO CANDLE OPENING PRICE AND
PREVIOUS CANDLE HIGH IS GREATER THAN OR EQUAL TO PREVIOUS CANDLE OPENING PRICE AND
PREVIOUS CANDLE OPENING PRICE IS GREATER THAN OR EQUAL TO PREVIOUS CANDLE CLOSING PRICE AND PREVIOUS CANDLE CLOSING PRICE IS GREATER THAN OR EQUAL TO PREVIOUS CANDLE LOW PRICE AND PREVIOUS CANDLE LOW IS GREATER THAN OR EQUAL TO PRIOR TWO CANDLE OPENING PRICE AND
PREVIOUS CANDLE HIGH PRICE IS LESS THAN OR EQUAL TO PRIOR TWO CANDLE CLOSING PRICE AND
PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR TWO CANDLE CLOSING PRICE AND
PRIOR TWO CANDLE CLOSING PRICE IS IS GREATER THAN PRIOR TWO CANDLE OPENING PRICE AND
PRIOR TWO CANDLE OPENING PRICE IS GREATER THAN PRIOR TWO CANDLE LOW PRICE AND
PRIOR THREE CANDLE HIGH PRICE IS GREATER THAN OR EQUAL TO PRIOR THREE CANDLE OPENING PRICE. PRIOR THREE CANDLE OPENING PRICE IS GREATER THAN PRIOR THREE CANDLE CLOSING PRICE AND
PRIOR THREE CANDLE CLOSING PRICE IS GREATER THAN OR EQUAL TO PRIOR THREE CANDLE LOW PRICE AND PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR THREE CANDLE HIGH PRICE AND
PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR FOURTH CANDLE HIGH PRICE AND
PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR FIFTH CANDLE HIGH PRICE AND
PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR FIFTH CANDLE HIGH PRICE AND
PRIOR TWO CANDLE HIGH PRICE IS GREATER THAN PRIOR SIXTH CANDLE HIGH PRICE.
Here we need to have the signal/Alert on the candle which denotes expression-high/low/close /open.
Then we need to take the position on the next candle as all the conditions are fulfilled.
Please advise if the expression is correct.
We have already made the strategy live but the signals that we are gettig on the chart are not correct ones.
The same strategy have already been implemented in Metastock , and is working fine
Are we going wrong somewhere in expression or in making the strategy live or otherwise somewhere. Please advise as this is vvimp for us.
Guess someone must have replied to your email already. The logic looks alright, the code also seems alright, but there might be some And/or missing..
Thanx for your reply.
We received your replied mail and then found that we had committed mistake in copying and pasting the same.
This one is a rectiied one and is put in the strategy as it is as we were advised to write all the algos related notes here.
But in vain…appears wrong somewhere as it is giving wrong signals on the charts.
Where are we wrong is not known.
If the code is right, then perhaps we are wrong in the next step i.e in taking it “LIVE”-We have examined the same as well but could not detect.
How to finish the same?.Please help.Really sorry for bothering you.
Let me try connecting you with a programmer and see if it can be debugged..
ANY DEVELOPMENT ON THIS ?
We have a few strategies to be implemented on this.Pl help us resolve the status quo so that the implementation can be done on this.HELP US FINISH.Thanx .
Also pl advise.
1.If we put:
Buy expression= 0
Buy Exit Expression-0
Sell Exit Expression-0
Sell expression –
(Strategy no1)
Or
(Strategy no 2)
and so on ‘n” number of strategies.
Will it work?
2.
Buy expression-
( No 1)
Or
( No 2)
and so on “n”number of (strategic)expressions.
Buy Exit Expression-0
Sell Expression-
( No 1)
Or
( No 2)
and so on “n”number of (strategic)expressions.
Sell Exit Expression-0
Will it work?
3.
In the 2 above,the logic is to-
a.Take all the strategies live at a time and not to have the hassle to put every strategy live in the morning.
b.Follow the simple trailing SL manually.
4.Or do we have to make all buy expressions with one strategy mode and all sell expressions with another seperate strategy mode and :
a.Take “buy” -STRATEGY LIVE IN THE MORNING.
b.Take “sell”-STRATEGY LIVE IN THE MORNING.
Please advise.
If what I have understood is right, yes 1 and 2 should work.
You will have to take all the strategies that you have saved live individually and everyday.
If there is disruption of internet connection from our side,is there a possibility that the candles/bar shown on the nest chart changes-as the data received is disrupted and leads to generation of alerts based on the data received till the time the candle /bar is formed.
Are the candles /bars backfilled automatically once internet connection is restored.
Please inform.
I want to run the following:
a. Single Scrip
b. Based on my technical logic, want to enter the market based on SL-Limit or SL-Market Order
c. Execution of this order, should then either place a profit order or a stop-loss order
d. Execution of either of the order, other order gets cancelled, and I start from point b again.
Request you to assist.
Rd
referring to SASIMENON on May 8 2013, 10:44 pm.
A stoploss % is essential or we can keep it blank.?
Can you please explain further?
if I (using Algoz) have taken a position for BNF @ 12500 and I set SL as 4% it will sqr off the position at 12000?
I am trying to put my proposed strategy across. Pure Intraday trades.
Time Frame: 15 Min
Long Position: 5 EMA crosses over 10 WMA (Buy at MKT)
Stop Loss: Previous Candle Low
TSL: Previous Candle Low
Short Position: 10 WMA crosses over 5 EMA ( Short at MKT)
Stop Loss: Previous Candle High
TSL: Previous Candle High
regards,
Hi Zerodha,
My requirement are simple.
1) For EOD trades, Buy Nifty Calls when 3 EMA > 15 EMA on Nifty Spot. Buy Nifty Puts when 3 EMA < 15 EMA on Nifty Spot.
Additionally as a confirming indicator, I also want to make certain that MACD (5,20,4) has given a buy / sell signal as well as RSI-EMA 21,9 (9 EMA of 21 RSI) has also given the same buy / sell signal.
Please help me code the same and back test it.
2) For Intraday Trades, I want to buy Call / Puts if the Nifty Spot crosses a certain value, say 6000, upwards (then Calls) or downwards (then Puts) respectively. How can I put in this sort of a conditional order?
for example: if Nifty Spot < 6000, initiate Buy Nifty Puts (In The Money / At The Money).
OR
if Nifty Spot > 6000, initiate Buy Nifty Calls (In The Money / At The Money).
Thanks for your help in advance and eagerly awaiting your help / reply.
Regards,
Sid
Sid,
In algoZ you cannot write a strategy based on a different underlying. If you want to trade a particular call/put, you have to mention your technical analysis strategy on that.
So it won’t be possible to write a strategy to buy calls/puts based on how nifty spot is moving.
AH!! Had this question as well. But Sid, can we not do this? the system generates a buy/sell signal, go and buy the Call/Put. some manual work though.
if this can be incorporated by the Zero guys, I would be make me a billion!! 🙂
When I try for backtesting, I dont see any such option. All there is in my strategy is the Edit option. How do I proceed further?
Also what expression do I use for EMA crossover say 3 EMA crossing over 7 EMA then Buy and vice-versa?
Miks,
Guess algoZ is not enabled for you, you can send an email to [email protected] asking to be enabled. A lot of queries are already explained above, do have a look
Buy expression: EMA(Close,3)>EMA(close,7)
Buy exit: 0
Sell expression: EMA(Close,3)<EMA(Close,7)
Sell exit: 0
Also check the blog on managing your script
I have sent email for enabling Algoz twice before and received email yesterday that it will done in 2 hours, but still it seems it has not been done.
Keep a cc to [email protected] and send it again
There appears to be some problem in this
.As we have also faced the same problem and only edit option is available.
But ,again when we close zerodha trader and start again , it shows all the three options viz,edit,live and backtest.
Please can you brief on the difference between crossover function and “<” or “>”. Also please give me the code for my strategy as posted below:
Buy : EMA3 cross EMA 21 from below, MACD histogram slops upwards, Stochastics %K above %D and going above 30.
Sell : EMA21 cross EMA3 from above, MACD histogram slops downwards, Stochastics %K below %D and coming below 80.
Thanks
Ajit
Buy:
EMA (CLOSE, 3) > EMA (CLOSE, 21) AND REF (EMA (CLOSE, 3), 1) < REF (EMA (CLOSE, 21), 1) AND TREND ((MACD (26, 13, 9, EXPONENTIAL) – MACDSIGNAL( 26, 13, 9, EXPONENTIAL)), 3 )= UP AND SOPK (9, 3, 9, SIMPLE) > SOPD (9, 3, 9, SIMPLE) AND SOPD (9, 3, 9, SIMPLE) > 30 AND REF (SOPD (9, 3, 9, SIMPLE) < 30
Sell:
EMA (CLOSE, 3) < EMA (CLOSE, 21) AND REF (EMA (CLOSE, 3), 1) > REF (EMA (CLOSE, 21), 1) AND TREND ((MACD (26, 13, 9, EXPONENTIAL) – MACDSIGNAL( 26, 13, 9, EXPONENTIAL)), 3 ) = DOWN AND SOPK (9, 3, 9, SIMPLE) < SOPD (9, 3, 9, SIMPLE) AND SOPD (9, 3, 9, SIMPLE) < 80 AND REF (SOPD (9, 3, 9, SIMPLE), 1) > 80
Sir,
we cannot make a strategy above 1000 sma even on 1 min. chart and it does not backtest and get the result
pls allow the system to work upto 3000 sma on 1 min.chart.
There are 60 candles per hour,375 candles per day,and for 22 days it will have 8250 candles.
A 3000sma will start after 3000 candles from the beginning and it goes on , so can you provide us more than 1000 sma,s
atleast on 1 min, chart and let the strategy backtest and proceed???
Am checking with our tech team on this, we will try to incorporate in the next version. 3000 candles will be quite a bit of data and might slow the process of backtesting. Will update you on this.
currencyandnifty.comMay 20 2013, 11:27 pm
Sir ,
Atleast 2000 sma will be useful for a net profit on f&o traders less loss trades ,brokerage and other govt.charges.
If it slowdown the process so, backtesting can be permitted only after trading hours.
Pls consider this upgrading from limited 999 candles and encourage more successful trades.
[ Click to thank ]
sir can u please code this strategy for me:-
Exit Strategy
1. When fast Stochastic reverses from it’s upward move, curves downwards and crosses the slow line from above, sell half of the units.
2. If the next bar goes below the low of the previous bar, exit completely
thanks in advance
Ricky,
1/2. your entry strategy: SOPK (8, 3, 4, SIMPLE) > SOPD (8, 3, 4, SIMPLE)
3. your entry strategy: EMA (CLOSE, 5) > EMA (CLOSE , 13) AND REF (EMA (CLOSE, 5), 1) < REF (EMA (CLOSE, 13), 1)
Do note that algoZ doesn’t support multiple time frames on the same strategy. For example, you can have a strategy different one running on a 5 min chart and another on 30min chart. You cannot have a strategy which requires both 5 min and 30 min chart.
Again Stop loss can be set as % using the alert price window.
Exit strategy: SOPK (8, 3, 4, SIMPLE) < SOPD (8, 3, 4, SIMPLE) AND REF(SOPK (8, 3, 4, SIMPLE), 1) > REF(SOPD (8, 3, 4, SIMPLE), 1)
Again, cannot split the quantity for exiting, when the above condition gets satisfied, the order will be for the complete quantity.
Please let me know on the query posted on 11 May; I’ve reproduced it below.
Could you please help me with the code for below ?
Buy trigger – +DI higher than -DI AND Slow Stochastic (14,3); 14 period crossing above 3 period at the closure of 15 minute candle OR +DI crosses over -DI when 14 period Slow Stochastic is above 3 period at the closure of 15 minute candle.
Exit Slow Stochastic (14,3); 14 period crossing below 3 period at the closure of 15 minute candle OR -DI exceeds +DI at the closure of 15 minute candle
Short trigger -DI higher than +DI AND Slow Stochastic (14,3); 14 period crossing below 3 period at the closure of 15 minute candle OR -DI crosses below +DI when 14 period Slow Stochastic is below 3 period at the closure of 15 minute candle.
Exit – Slow Stochastic (14,3); 14 period crossing above 3 period at the closure of 15 minute candle OR +DI exceeds -DI
Vasant,
Buy Alert Expression:
DIP(14) > DIN(14) AND SOPD (14, 3, 3, SIMPLE) > SMA (SOPD (14, 3, 3, SIMPLE), 3)
Buy Exit: 0
Sell Alert:
DIP(14) < DIN(14) AND SOPD (14, 3, 3, SIMPLE) < SMA (SOPD (14, 3, 3, SIMPLE), 3)
Sell Exit:
0
Hi can you give formula for Trailing Stop loss
Example 1% trailing Stop in Picture:
There is no concept of trailing stop loss, but you could use the buy exit option to write strategy which can be used as a stop loss. For example, your blue line looks like a moving average line, so you can have a moving average condition as a stop loss.
Here is my idea that may be of help. Please modify it into workable Code
LONG EXIT
SET A= if(BUY= TRUE, HIGH, 0 ) \ When Buy happens intialize A with current HIGH
SET A = if( HIGH >REF(HIGH,1) , HIGH, A)
CLOSE <= A*0.01
i am planning to use my strategy but it is not showing any option to go live and also i want to take backtest of my strategy
how to enable the options of backtest, go live and alert of my strategy
Send an email to [email protected] asking to be enabled on algoZ
Is it possible to get alert when a candle cross to 30 sma (in blue circle) also i wish to avoid continues signals (in red circle)
I try the close<SMA…,,.It work well in back test but in live trade its generating signal in all candle below the sma line.
Sebu,
You can use the AND condition and have something else to filter so that you don’t get chopped on those moves. The logic will have to be yours,
Cheers,
Nithin
Hi,
You corrected my code for reversal strategy. thanks a lot. But tht code gives signal when a reversal candle gets formed and that too when i run scrip by scrip only.
But buy/sell is actually abv /blow the high/low of PR/NR. So Pls. give me a code tht generates signal on actual buy/sell with exit tgts as defined blow.
When I backtest, Should I go scrip by scrip? Or is there anyway to test this strategy in nifty 50 for a particular period?
My strategy for reversal:
Buy:abv the high of the positive reversal(PR) candle.SL is the low of the PR. exit for buy: closing the 50% buy posn at 1:1 and rest at 1.618 fibo extn(diff between high and low of th PR * 1.618) added to the high of the PR.
Sell: blow the low of the negative reversal candle. NR is just opposite of PR definition.
Definition of positive rev can:
Low of the current candle should be more than the low of the previous candle.
close of the current candle should be more than previous candles close and open of the current candle.
high of the current candle should be less than the high of the previous cndl.
RSI of the current candle should be more than 30 and RSI of the previous candle should be less than 30.
hope to get the reply soon. Thanks in adv.
Firstly,
When you backtest, it has to be done scrip by scrip.
About your strategy: this wont be possible. it will generate on the pr/ nr candle or if u specify that above/ below high/ low in the next 5 candles, then can be done using ref function
I add MACD crossover strategy to 10 charts and make live.Then i close 9 charts.
but it work only in 3 charts.In the chart i find the crossover but no buy sell signal generated by the system. is there any limit in no of charts.can i add strategy without open the plus chart?
Sebu,
You have to open a chart, apply the strategy and then open another chart apply the same strategy and so on…
after applying strategy can i close the chart.keeping many charts open make the system slow..
If i close the chart after loading strategy,is it work or not?
Yes once you apply the strategy, you can close the charts. Once you go live on the strategy, you would not need the chart to be open anymore..So you can close the chart once you take the strategy live..
Cheers,
After closing plus chart only 3 out of 10 strategy works.is there any update required for plus or nest.
Sebu, let me find this out and get back.
i want to have a strategy for buy if RSI period 14 close above 55
and exit the position if RSI period 14 close below 30
i tried this RSI(CLOSE,14)>55
RSI(CLOSE,14)<30
but it is showing invalid expression
pls help me in getting correct expression
PY,
The expression is correct,
In Buy expression: RSI(CLOSE, 14) > 55
Buy exit: RSI(CLOSE,14)<30
Since you don’t have a sell strategy make sure to write a 0 in both those places. It might be showing an error because you are not mentioning the 0.
i am planning to use my strategy but it is not showing any option to go live and also i want to take backtest of my strategy
how to enable the options of backtest, go live and alert of my strategy
Hi
Can u pls code me the below strategies :
1 ) Buy : Bar close > The high of immediate previous bar and Bar close > Bar open
Sell : Bar close < The low of immediate previous bar and Bar close < Bar open.
2 ) Buy : Price crossover > Highest high of previous 30 bars
Sell : Price crossover < Lowest low of previous 30 bars.
Regards,
Anil.
1.
Buy: CLOSE > REF (HIGH, 1) AND CLOSE > OPEN
Sell: CLOSE < REF (LOW, 1) AND CLOSE < OPEN
2.
Buy: CLOSE > MAXOF (MAX (HIGH, 29), REF (HIGH, 1))
Sell: CLOSE < MINOF (MIN (LOW, 29), REF (LOW, 1))
Code 2 not working.
Replace 1 by 30 in code
Dear Zerodha,
Not getting Historical charts in Nest Plus Charts
for algoZ
ID : DD0314
Devendra
Devendra,
You have to right click inside the plus chart(initiate chart using key shift+P) and say historical chart.. It should show up, let me know if it doesn’t. Also can you tell me for what contract are you trying to look at the historical chart?
Dear Zerodha,
I have a strategy
of EMA 8 and 13 Crossover
on 10 min chart
which (on an avg) gives 1 OR 2 trades a day
i.e. 2-3 buy AND sell signals
When Backtested it plots arrows at right places
But When I set it live,
on 10 min interval
and keep watching 10 min chart of nest plus
unnecessary alerts are shown
instead of 8-9 alerts 20-30 Alerts pop up
How to avoid this ?
IS it a Bug in algoZ
This happens for any strategy !
Pl. Guide
Devendra
shouldnt be happening. can unregister and register the NestPulse.dll file and check. You can shoot an email to [email protected] with your client id, I will get someone to call you back and get this fixed.
Could you please help me with the code for below ?
Buy trigger – +DI higher than -DI AND Slow Stochastic (14,3); 14 period crossing above 3 period at the closure of 15 minute candle OR +DI crosses over -DI when 14 period Slow Stochastic is above 3 period at the closure of 15 minute candle.
Exit Slow Stochastic (14,3); 14 period crossing below 3 period at the closure of 15 minute candle OR -DI exceeds +DI at the closure of 15 minute candle
Short trigger -DI higher than +DI AND Slow Stochastic (14,3); 14 period crossing below 3 period at the closure of 15 minute candle OR -DI crosses below +DI when 14 period Slow Stochastic is below 3 period at the closure of 15 minute candle.
Exit – Slow Stochastic (14,3); 14 period crossing above 3 period at the closure of 15 minute candle OR +DI exceeds -DI
Vasant,
need more info on the stochastic condition. do you require a K% crossover to D% or if its greater than 0 or ..?
I would just need a crossover, 14 period crossing over/below the 3 period
Could you please let me know on this ?
Pls. answer my query posted on 11th may. thank you.
Which question Sangi, can you repeat it here..
Hi Team,
I haven’t yet received any clarification on below issue. Kindly help me to solve the below problem.
This is a simple MACD crossover script as mentioned below. But there are false signals (encircled in red), though crossover has not happened. Can you please explain the reason for these false signals? Thanks..
KK,
Sorry had missed your query,
Looking at this I can see 2 reasons,
1. Instead of using the Crossover function, just use the > or < , for example use this instead of crossover: MACD(26,13 9,EXPONENTIAL) > MACDSIGNAL (26,13,9,EXPONENTIAL)
2. MACD and MACD signal use exponential moving average and not simple average for plotting. This may also be creating the mismatch.
Please can you brief on the difference between crossover function and “<” or “>”. Also please give me the code for my strategy as posted below:
Buy : EMA3 cross EMA 21 from below, MACD histogram slops upwards, Stochastics %K above %D and going above 30.
Sell : EMA21 cross EMA3 from above, MACD histogram slops downwards, Stochastics %K below %D and coming below 80.
Thanks
Ajit
zerodha,
pls allow to work our strategy in all sectors like equities.FO and currency at the same time,if we login ZT and select.
we mean to work our strategy SBIN on cash and TCS on FO at the same time on ZT if we select both,can you ?
Yes Currency and nifty, you can run multiple scripts at a same time.
Check this blog on how to manage your script/program
http://www.zerodha.com/z-connect/blog/view/managing-your-script , you can run multiple programs on fo, currency and equity at the same time.
Cheers,
Hi Zerodha,
Thanks for your reply,,
And one more query i have.
Why it is not working in MCX, because i trade in most in commodity.. when it will be available in commodity…
Presently Kiran,
This product is still not approved by MCX, we are waiting for exchange approvals and once we have it, this will be enabled for commodities.
Hi,
Please provide the code for the below strategy.
Buy—If the range (difference between high and low) of previous candle is the least of past 30 period/candle and Last price(LTP) crossovers high of previous candle.
Sell—-If the range (difference between high and low) of previous candle is the least of past 30 period/candle and Low of previous candle crossovers LTP.
Thanks,
Harish
Buy:
SET RANGE = HIGH – LOW
REF (RANGE, 1) < MINOF (MIN (RANGE, 29), REF (RANGE, 30)) AND CLOSE > REF (HIGH, 1) AND REF (CLOSE, 1) < REF (HIGH, 2)”
Sell:
SET RANGE = HIGH – LOW
REF (RANGE, 1) < MINOF (MIN (RANGE, 29), REF (RANGE, 30)) AND CLOSE < REF (LOW, 1) AND REF (CLOSE, 1) < REF (LOW, 2)”
Sir,
An automated strategy can go live with your server on all trading days,without trader login with a dealer terminal?
You have to login everyday to the terminal if you’re using the retail version. In the dealer version (where you need to have a NISM certificate) it’s possible for trades to get executed every time a signal occurs… but you still need to log into the trading platform. Or someone else needs to log into it for you.
Hi,
Can u pls give me a code for the below strategy :
Buy : Price close > Recent peak
Sell : Price close < Recent low.
Anil.
Anil,
Can you let me know what you mean by recent peak? You mean high for the day or for the last 30 candles or anything like that. If you don’t specify that it won’t be possible to code.
Sir,
As you suggested, kindly give the strategy for the same period [last 30 candles].
Buy : Price [need not to be the close] > Highest high in the last 30 candles.
Sell : Price [need not to be the close] < Lowest low in the last 30 candles.
Anil.
How a stoploss can assure , minimum 2% profit,from each trade?
pls explain
Sasi,
Stop loss can’t really assure you profits, but it can only be used to make sure you exit fast if you make a loss..
To exit at profit, you need to have an exit strategy. Unfortunately, there is no definite exit strategy which would say give you a 2% profit.
Hi Zerodha,
I have made a strategy as follows :
Buy: EMA(Close,3)>EMA(Close,5) Sell: EMA(Close,3)< EMA(Close,5)
Buy exit: CLOSE<EMA(close,5) Sell exit: CLOSE>EMA(close,5)
In this case, does it exit the existing lots and add a new lot into position or just exit the existing position.
I.e. I have a short at nifty 5851.4. At 5726 long trigger occured. so in that case it should exit current short position and need to add one long position. How can this be done. the above code is sufficient ?
Faisal,
let me give you an example,
Assume the 3 candle ema crossovers the 5 at 5900, you will get a buy trigger and assume it went up and it came down to 5 candle ema again at 5910. This is your exit strategy and you will get a sell trigger.
But this is not your sell strategy, the next fresh sell trigger will happen when your condition: EMA(Close,3)< EMA(Close,5) is met.
If you want to exit and take a fresh sell, then you need to keep your buy exit and sell as same strategy or you can keep exit as 0 and keep sell.
Hope, this clarifies, let me know if it didn’t.
Cheers,
Hi Zerodha,
Is this tool wil work in mobile application.. If works how to use,,
If not what is the alternative way to see the charts in mobile and tablets..
I’m using mobile application i don’t have have access to systems..
Thanks in Advance…
Hi Kiran,
Currently the algoZ facility is not available on Mobile.. The charting on Mobile/Tablet is very lite as it is required to be..
How to code stochastic for following condition
Buy when stochastic +ve crossover is below 20
Sell when stochastic -ve crossover is above 80
one member asked this but it gives error when applied
with regards
You can try this:
Buy: CLOSE > EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) > SOPD (20, 3, 4, SIMPLE) AND REF (SOPK(20, 3, 4, SIMPLE), 1) < REF(SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4, SIMPLE) > 30
Sell: CLOSE < EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) < SOPD (20, 3, 4, SIMPLE) AND REF (SOPK(20, 3, 4, SIMPLE), 1) > REF (SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4, SIMPLE) < 80
Hi is there a code for buy@ stochastic D 90 with buy exit @ when stochastic d is greater than 35 and sell exit when stochastic LESS than 75…..please suggest me code for this
Thanks in advance
Buy:
((SOPD(9, 3, 9, SIMPLE)) = 90)
Buy Exit:
((SOPD(9, 3, 9, SIMPLE)) > 35)
Sell Exit:
((SOPD(9, 3, 9, SIMPLE)) < 75)
Thanks Nithin, Just I have a follow up question. What is the max number of symbols/ script you can automate… I mean is there any cap on data and script automation for an individual account and also… will able to do future trading with automated strategy.
Once you have a strategy approved by the exchange, you can automate it on as many scrips as you want, equity & futures. Check this post.
Dear Zerodha,
How can i cancel alert on my live strategy.
Regards,
Mani
Mani, check this blog:
A stoploss % is essential or we can keep it blank.?
You can keep it blank
Hello Zerodha programmers,
Can you suggest few moneymaking scripts for all zerodha traders, atleast one
Sasi,
We will be starting this feature soon, where we will share profitable trading systems, it need not always be complex. If you see the example of manage your script blog, if you had put a stop loss, even that would have made you a pretty decent return.
Hi Zerodha,
Thanks for the new features added . Can you please help me to develop a expression for the below strategy.
Strategy 1:
EMA cross over 12 x 26 for buy and sell signal with the filter of MACD cross over at “0” line to generate buy or sell signal
Strategy 2:
EMA cross over 12-26 with filter parabolic SAR indicator buy and sell signal.
Strategy 3:
EMA cross over 12 x 26 for buy and sell signal with the filter of MACD cross over buy and sell.
Thanks in Advance.
Regards,
Sridhar
Zerodha…
I’m still waiting for your help..
Thanks,
Sridhar
Sorry Sridhar,
Had missed this query,
Strategy 1:
BUY: EMA (CLOSE, 12) > EMA (CLOSE, 26) AND MACD (26, 13, 9, EXPONENTIAL) > 0 AND REF (MACD (26, 13, 9, EXPONENTIAL), 1) < 0
SELL: EMA (CLOSE, 12) < EMA (CLOSE, 26) AND MACD (26, 13, 9, EXPONENTIAL) < 0 AND REF (MACD (26, 13, 9, EXPONENTIAL), 1) > 0
Strategy 2:
BUY: EMA (CLOSE,12) > EMA (CLOSE, 26) AND CLOSE > PSAR (CLOSE, 0.02, 0.2)
SELL: EMA (CLOSE, 12) < EMA (CLOSE, 26) AND CLOSE < PSAR (CLOSE, 0.02, 0.2)
NEHALMay 7 2013, 5:04 pm
Zerodha,
Can you please help me to develop code for following criteria?
1. buy = average of 15 period highest price & 15 period lowest price is greater than average of 30 period highest price & 30 period lowest price
2. sell = average of 15 period highest price & 15 period lowest price is lower than average of 30 period highest price & 30 period lowest price
Thanks in advance.
Nehal
[ Click to thank ]Zerodha replyMay 8 2013, 1:50 pm
Buy:
SET H = MAXOF (MAX (HIGH, 14), REF (HIGH, 15))
SET L = MINOF (MIN (LOW, 14), REF (LOW, 15))
SET AVG = (H+L)/2
SET H1 = MAXOF (MAX (HIGH, 29), REF (HIGH, 30))
SET L1 = MINOF (MIN (LOW, 29), REF (LOW, 30))
SET AVG1 = (H1 + L1)/ 2
AVG > AVG1
Sell:
SET H = MAXOF (MAX (HIGH, 14), REF (HIGH, 15))
SET L = MINOF (MIN (LOW, 14), REF (LOW, 15))
SET AVG = (H+L)/2
SET H1 = MAXOF (MAX (HIGH, 29), REF (HIGH, 30))
SET L1 = MINOF (MIN (LOW, 29), REF (LOW, 30))
SET AVG1 = (H1 + L1)/ 2
AVG < AVG1
I think Super trend is an indicator, just like PARSAR and should be incorporated in the list of Indicators on Nest Plus Charts and must show on chart.
As a user then we can buy / sell as the indicator signals, for the given timeframe.
Please provide the code for the below strategy
Supertrend:
Formula
Srinivas,
As rainmaker has mentioned,
Supertrend should be available in the list of indicators on the chart. It is presently not available. If you are using amibroker, I’d suggest you to use the trading bridge.
Hi Zerodha,
Please provide the code for the below strategy which is based on narrow range.
1) Buy LTP > previous day high and previous candle range(difference between High and Low) should be narrowest of any of the past 6 candles(range of each candle may or may not be continuous).
2) Sell LTP < previous day low and previous candle range(difference between High and Low) should be narrowest of any of the past 6 candles(range of each candle may or may not be continuous).
Please find the screen shot for your reference.
Thanks,
Harish
Harish,
Sorry for the delay:
Buy:
CLOSE > DHIGH(2) AND (HIGH – LOW) < (REF (HIGH, 1) – REF (LOW, 1)) AND (HIGH – LOW) < (REF (HIGH, 2) – REF (LOW, 2)) AND (HIGH – LOW) < (REF (HIGH, 3) – REF (LOW, 3)) AND (HIGH – LOW) < (REF (HIGH, 4) – REF (LOW, 4)) AND (HIGH – LOW) < (REF (HIGH, 5) – REF (LOW, 5)) AND (HIGH – LOW) < (REF (HIGH, 6) – REF (LOW, 6))
Sell:
CLOSE < DLOW(2) AND (HIGH – LOW) < (REF (HIGH, 1) – REF (LOW, 1)) AND (HIGH – LOW) < (REF (HIGH, 2) – REF (LOW, 2)) AND (HIGH – LOW) < (REF (HIGH, 3) – REF (LOW, 3)) AND (HIGH – LOW) < (REF (HIGH, 4) – REF (LOW, 4)) AND (HIGH – LOW) < (REF (HIGH, 5) – REF (LOW, 5)) AND (HIGH – LOW) < (REF (HIGH, 6) – REF (LOW, 6))
DHIGH and DLOW not taken by Pi
Can you post your issue here: https://tradingqna.com/c/algos-strategies-code A forum member may be able to help you out.
Hi sir,
Can u please give me codes for the following strategies?
1. Divergence in RSI,
2. Divergence in Stochastics,
3. a) Buy when the price close >Day’s Open and sma50.
b) Sell when the price close < Day’s Open and sma50.
Regards,
Anil.
Anil,
All the ones you mentioned cannot presently be coded on algoZ presently. About 3a and 3b, presently Day’s open cannot be coded on pulse, should be up in the next version.
On go live with 5 minute candle setting , it is firing based on one minute candle and generating lot of trades
Please help
APM,
Firstly when you go live, you need to set interval to 5mins in the alert preference window as shown in the manage your script blog. Just making the chart as a 5 min chart won’t be enough.
If you have done this and still getting the prompts, can you double click on any prompt that you have gotten on the running script window, take a snapshot and send it to [email protected] . Also mention your client id .
Cheers,
My logic is explained below. Kindly let me know the code for he same.
Buy on the previous day’s high. Stop loss for Nifty is 30 points. If it moves in the direction of the trade, then the stop loss moves to the previous day’s low or 30 pts which ever is lower. Similarly for Short positions as well.
Buy: CLOSE > DHIGH(2)
Sell: CLOSE<DLOW(2)
Stop loss can be placed as % in set alert window, as shown in this blog. You cannot have a trailing stop loss.
SIR CODE IS NOT WORKING, DHIGH(2) for previous day high not working, what is code for previous day high or low.
Dear Sir
Please Reply to my mail
While making Live- Even if I am specifying 5 minute Candle, it is firing based on 1 minute Candle
Please help
Thank you for previous answer.
Today taken system live. It generated 2 signals as per my expectations but there was no sound alert only pop up mg.
Set security alert gives beep for alert . Nothing for algoZ running scripts.
Please let me know where is the option in nest plus to configure sound alerts. If not in front of pc sound alerts are very useful.
Thank you
Shri,
The next version will have sound alert and should be available by end of the month.
the code i have given above is for NR.
Hi,
This is my strategy for reversal. I have coded and it works in odin , but not in algoz. Can u tell me why it is not working in algoz and pl rectify the mistake.
Buy:abv the high of the positive reversal(PR) candle.SL is the low of the PR. closing the 50% buy posn at 1:1 and rest at 1.618 fibo extn(diff between high and low of th PR * 1.618 added to the high of the PR.
Sell: blow the low of the negative reversal candle. NR is just opposite of PR definition.
Definition of positive rev can:
Low of the current candle should be more than the low of the previous candle.
close of the current candle should be more than previous candles close and open of the current candle.
high of the current candle should be less than the high of the previous cndl.
RSI of the current candle should be more than 30 and RSI of the previous candle should be less than 30.
Code:
SET A = HIGH
SET B = REF(HIGH,1)
SET C = CLOSE
SET D = OPEN
SET E =REF(CLOSE,1)
SET F = RSI(CLOSE,14)
SET G = REF(F,1)
SET H = LOW
SET I = REF (LOW,1)
A > B AND C < D AND C < E AND H > I AND E > 70 AND G < 70
Please help me in this regard. If you find that this is not coded properly, pls give me the correct code.
Thanking you in advance.
Sorry Sangi for missing this, I had answered which didn’t get posted before.
Your code almost right except for the small mistake, F is the RSI not E, you have mentioned E>70, it is actually F>70. So if you change, it will look like:
A > B AND C < D AND C < E AND H > I AND F > 70 AND G < 70
thank you for the response. I am yet to take it live. I have 2 doubts. Pls clear it.
1. To back test and know whether this strategy generates profit/loss, the tgt aspect is not yet coded. I hv given the tgt aspect in my prv post. Can you please give the code including tgt aspect?
2. When I backtest, Should I go scrip by scrip? Or is there anyway to test this strategy in nifty 50 for a particular period?
Thanks in advance.
I want to have a code for the following
Buy : When the Low of the Candle is above EMA 34 Close and the previous candle close is below EMA 34 ( Candle moving from Bottom crossing EMA 34)
Sell : When the high of the Candle is below EMA 34 close and the previous candle close is above EMA 34
I am using the following code :
LOW>EMA(CLOSE,34) AND Ref(Low,1)<EMA(CLOSE,34)
Buy Exit :0
HIGH<EMA(CLOSE,34) AND Ref(HIGH,1)>EMA(CLOSE,34)
Sell Exit : 0
During live I have specified 5 minute candle but it is firing using one minute candle for example for sun pharma between 9.15 to 10.30 I got more than 6 firing
Can you please let me know the code for following.
This is for my exit Criteria
Buy Exit : 3 Consecutive Red Candles
Sell Exit : 3 Consecutive Green Candles.
Buy exit: CLOSE < OPEN AND REF (CLOSE, 1) < REF (OPEN, 1) AND REF (CLOSE, 2) < REF (OPEN, 1)
Sell exit: CLOSE > OPEN AND REF (CLOSE, 1) > REF (OPEN, 1) AND REF (CLOSE, 2) > REF (OPEN, 2)
ON My strategy > Edit what is meant by :
ORDER IS RELEASED AT THE VWAP CLOSE IT CONSIDERS THIS FACTOR FOR THE SAME
Aren’t all orders are based on the close price (LTP) of the respective timeframe candle.?
I do understand the VWAP, but the point I wish to know is whether trades are based on VWAP or LTP calculations in algo.
Rainmaker,
VWAP is presently for order slippage, isn’t functional yet.
Yes, all are orders are based on close price of previous candle.
Orders/trades are based on LTP and not VWAP, as I mentioned VWAP is only for order slippage..
Hi,
I am looking to trade with pivot points. My Buy expression would be =(Prev Day High+Prev Day low+Prev Day close)/3)*1.001)
and Sell Expression would be (Prev Day High+Prev Day low+Prev Day close)/3)*.999)
Pls help me code this for back testing. Thanks!
Dharam,
You cannot really this strategy live because it is based on daily candles or daily chart. But yes you can in the evening backtest the strategy and if an buy/sell indicator comes you can take a buy/sell the next day.
Buy: CLOSE > ((REF(HIGH, 1) + REF (LOW, 1) + REF(CLOSE, 1))/ 3) * 1.001
Sell: CLOSE < ((REF(HIGH, 1) + REF (LOW, 1) + REF(CLOSE, 1))/ 3) * 0.999
Buy exit: 0
Sell exit: 0
Once you have saved the strategy, open intraday historical chart and backtest. If a buy/sell indicator comes up, you can take the trade the next day.
Thanks Zerodha. I am little confused with the codes given. Does it generate the Signals based on last day’s High, low and close or the latest high,low & close. My manual signals do not match with the Code generated signals. pls help…
Dharam,
Didn’t see your reply,
You can’t backtest this strategy on an intraday chart. So firstly, open an historical chart and then backtest it.
Also you cannot take this strategy live as the signals will be generated only at the end of the day. so you will need to backtest it in the evening and take a trade next day.
Cheers,
Few questions.
1. Does back test include brokerage and other charges too?
2. Back test results for how much quantity for cash and futures? Is it like for cash 1 share and for F&O one lot?
3. I should be connected to trading platform once i take my strategy live to run it during trading hours always? or i can logoff in between?
1. Backtest doesn’t include any charges, you will have to factor it in externally.
2. The results show based on what you are backtesting on. If you are backtesting on equity, it will show you total points for 1 share and if it is f&o for 1 lot.
3. You will have to be logged in continuously after you take a strategy live. If you logoff, you will have to take strategy live once again after logging back in.
Dear sir,
This DJ9237.
BUY
Buy when close price of the scrip is above 3 period EMA crosses over 18 period SMA.
CLOSE>CROSSOVER(EMA(CLOSE,3),MA(CLOSE,18))
Jawahar,
Firstly, if you are talking about activating algoZ for your ID, can you send an email to [email protected]. It might be already activated, do double check.
The correct code:
Buy: EMA(Close,3)>SMA(Close,18)
Buy exit: 0
Sell: EMA(Close,3)<SMA(Close,18)
Sell exit: 0
How to write this code and taking it live is explained in the 2 blogs, simple example and managing your script.
Zerodha,
Thank you for previous code.
I have another query.
I use MACD crossover system to buy and sell on 5 min chart of Nifty call/put Options.
When I get a signal I confirm and order is executed. In preferences I have put stoploss of 0.5.
Now how to modify the stoploss once trade is in profit .
And since this is Options trade once I get sell signal as per system will it execute the order if I confirm.
Earlier before algoZ when I traded , for options after buying I could place only either SL order or sell order and not both.
If tried to place both it gave RMS limits error for not sufficient margin.
So in algoZ should I cancel SL first for options and then confirm sell or how does it work.
Sorry for long question.
Thank you.
Shri,
The stop loss which you place will show as a pending order in your order book. You can go to the order book and modify the stop loss.
If you place a new sell for the same option, you will still be asked for more margin as the new order will be considered as a fresh short position. To exit what you can do is go to pending stop loss order and modify it as a exit order or else cancel it before confirming on the selling signal that your system would have provided.
Hope this clarifies.
Zerodha, I am waiting for 4 Days to
get answer to my queries. Pl. Help !
———————————————–
Thanks a lot to Zerodha for algoZ
How can I write Buy Expression when :
ADX (14) > 10 AND +DI > 20
Sell When
ADX (14) > 10 AND -DI > 20
—————————————-
My other Strategy is :
Buy when Price closes above Bollinger Band middle or centre
Buy Exit when when Price closes above Bollinger Band top
Sell when Price closes below Bollinger Band middle or centre
Sell Exit when when Price closes below Bollinger Band bottom
Pl. provide Code for above 2 Strategies [ADX and BB]
Thanks in Advance
Devendra
Sorry Devendra for the delay,
1st STrategy on ADX
Your expression is almost correct 🙂 ,
Buy: ADX(14) > 10 AND DIP(14) > 20
Buy exit: 0
Sell: ADX(14) > 10 AND DIN (14) > 20
Sell exit: 0
2nd Strategy on Bollinger bands:
Buy: CLOSE > BBM (CLOSE, 20, 2, EXPONENTIAL)
Buy exit: CLOSE > BBT (CLOSE, 20, 2, EXPONENTIAL)
Sell: CLOSE < BBM (CLOSE, 20, 2, EXPONENTIAL)
Sell exit: CLOSE < BBB (CLOSE, 20, 2, EXPONENTIAL)
how to write strategy for macd histogram?
buy – macd histogram<0 and increasing value
sell – macd histogram>0 and decreasing value
Buy: SET MACDHIST = MACD(26, 13, 9, EXPONENTIAL) – MACDSIGNAL(26, 13, 9, EXPONENTIAL)
MACDHIST<0
Sell: SET MACDHIST = MACD(26, 13, 9, EXPONENTIAL) – MACDSIGNAL(26, 13, 9, EXPONENTIAL)
MACDHIST>0
The statement increasing and decreasing, you have to quantify it to be coded..
hi,
I just tried to test algoZ, for that I copied the expressions given in the example and tried to save, on clicking save button, nothing is happening and even in my strategy EMA, still showing EDIT only instead of other options..
I’m using WINDOWS 8
Thanks
Ramesh Rao
Hi Ramesh,
Shootout an email to [email protected] with your account details and we’ll get it activated for you.
hi,
I just tried to test algoZ, for that I copied the expressions given in the example and tried to save, on clicking save button, nothing is happening and even in my strategy EMA, still showing EDIT only instead of other options..
I’m using WINDOWS 8
Thanks
Ramesh Rao
Ramesh,
This means you are still not enabled, send an email to [email protected] for this, we will have it done by monday evening.
Hi Zerodha,
can you reply to my question asked on Apr 30 2013, 11:12 pm? Please provide the formula for the same.
thavva
Done, have updated on your query.
Vincent asked this on an email:
I TRIED TO WRITE THE CODE AND FAILED. PLEASE TRY TO HELP ME AND TELL ME HOW TO SAVE.
FOR BUY SIGNAL
1) EMA5 CROSSING EMA6 FROM BELOW AND THE PRICE IS ABOVE EMA5:
PARABOLIC SAR CROSSING BELOW PRICE.
FOR SELL SIGNAL:
2) EMA6 CROSSING BELOW EMA5:
PARABOLICSABOVE
ALSO I WANT THE POP UP MESSAGE OF THE STOCK WHICH SATISFIES THE CONDITION.
REGARDS,
Answer:
Buy:
EMA (CLOSE,5) > EMA (CLOSE, 6) AND REF (EMA(CLOSE, 5),1) < REF(EMA(CLOSE,6),1) AND CLOSE > EMA(CLOSE,5) AND PSAR (CLOSE,0.02,0.2) < CLOSE.
Sell:
EMA (CLOSE,5) < EMA (CLOSE, 6) AND REF (EMA(CLOSE, 5),1) > REF(EMA(CLOSE,6),1) AND CLOSE < EMA(CLOSE,5) AND PSAR (CLOSE,0.02,0.2) > CLOSE
Buy exit: 0
Sell exit: 0
You will have to run this strategy individually for stocks, there is no option to run a screener. What you will have to do is, take live the same strategy individually for the various stocks you are tracking. Blog http://www.zerodha.com/z-connect/blog/view/managing-your-script shows you how to take live and setting alert preferences.
Sir,
whenever I go live on my strategy,whether my 10sma on
1-minute chart,will work as 50 sma,on 5-min.alert preference??
Give me a clear answer pls.
Sasi,
Check out this blog: http://www.zerodha.com/z-connect/blog/view/managing-your-script
You cannot 2 time frames on one strategy. You can either use a 1 min or a 5min.
10 SMA on 1 min chart won’t be like a 50SMA on 5 min chart, it will be very different.
Dear Zerodha,
I want to backtest following system:
Buy: CROSSOVER OF 9 EMA & 20 SMA (on five min chart) AND 9 EMA > 20 SMA (on 15 min chart)
Sell: CROSSOVER OF 20 SMA & 9 EMA (on five min chart)
Is it possible in Algo Z
Anamika,
You can’t apply different time frames to the same strategy. You can either use 5 min or 15min, but you can’t combine both.
If it is just on one time frame then :
Buy: EMA(close,9) > SMA(Close,20)
Sell: EMA(close,9)< SMA(Close,20)
Buy exit: 0
Sell exit: 0
Cheers,
Please let me know how to write a Script if I wan t to buy Nifty Future if it crosses a particular certain level say 5900.
Hi OP,
algoZ is based on technical analysis , so you can’t define to buy above a certain price like 5900, you could just use the stoploss to enter if you know the price.
But if the price is based on a technical analysis strategy, yes it can..
super trend indicator possible to code in nest plus script ?
If you can share the formulae, we can try.
@Zerodha,
I want to write code to find MACD histogram.
i.e MACD – (minus) Macd Signal
For eg if macd (12,26) =10 macd signal (12,26,9)= 2 Histogram=Hist=Macd minus Macd signal = 10-2 =8
After finding histogram value my sell signal would be
Sell = Histogram < ref(close,1) and ref (close ,1) < ref (close ,2).
Here close is macd histogram values and not candle values.
Please help me code this..
Thank you
Sell:
SET MACDHIST = MACD(26, 12, 9, EXPONENTIAL) – MACDSIGNAL (26, 12, 9, EXPONENTIAL)
MACDHIST < REF (MACDHIST, 1) AND REF (MACDHIST, 1) < REF (MACDHIST, 2)
I want to find whether the trend of the last three CLOSE periods of 5 minute interval charts. Can i use?
TREND(CLOSE, 3) = UP
Particularly, the second parameter “2” is it for “periods” or only “days” ?
Thanks,
Juggy…
Yes Juggy, the code is correct, the number is for candles. When going live you can choose on what candle(1min, 5min, hourly etc) you want to go live on, similarly when backtesting you can change the candle to whichever you prefer and backtest. But the number in the code will be basically the number of candles.
SuperTrend indicator possible to code in Nest Pulse script ??
Can you share the formula, we could give it a shot.
Zerodha
How to code stochastic for following condition
Buy when stochastic +ve crossover is below 20
Sell when stochastic -ve crossover is above 80
**when stoch comes above 20 for BUY after the crossover
** stoch moves below 80 for sell after the crossover
Buy: CLOSE > EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) > SOPD (20, 3, 4) AND REF (SOPK(20, 3, 4, SIMPLE), 1) < REF(SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4) > 30
Sell: CLOSE < EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) < SOPD (20, 3, 4) AND REF (SOPK(20, 3, 4, SIMPLE), 1) > REF (SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4) < 80
For above formula we are getting below error.
Replace SOPD (20, 3, 4) with SOPD (20, 3, 4, SIMPLE) for all you should get it running.
I want to use 5 minute candle instead of 1 minute candle
Buy for closing above 34 EMA with Stochastic % K period 20, % k slowing 3 and % D period 4 with % K Crossing % D above 30
Sell for closing below 34 EMA and Stochastic % K period 20, % k slowing 3 and % D period 4 with % D Crossing % K below 80
Please let me know the program
APM,
If you want to use the 5 min candle on the chart, you can right click on the chart and change the interval from 1 min to 5min.
If you want to use a 5 min candle while going live, you will need to set it in the alert preferences box. Check this example.
Buy: CLOSE > EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) > SOPD (20, 3, 4) AND REF (SOPK(20, 3, 4, SIMPLE), 1) < REF(SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4) > 30
Sell: CLOSE < EMA (CLOSE, 34) AND SOPK(20, 3, 4, SIMPLE) < SOPD (20, 3, 4) AND REF (SOPK(20, 3, 4, SIMPLE), 1) > REF (SOPD(20, 3, 4, SIMPLE), 1) AND SOPD (20, 3, 4) < 80
DEAR SIR I WANT TO TRADE WHEN 31 EMA CROSS 131 EMA AND SELL WHEN 131 EMA CROSS 31 EMA
Ashish EMA Crossover is already coded a few times in the queries above. You can post all queries on coding on tradingqna.
Hello. Since RSI below 30 may not always be a good signal to buy especially if your not closely monitoring the prices, I usually rely on RSI divergences ….So is it possible to create an expression to buy if there is an RSI divergence or may be a MACD or KST divergence?
Can you provide formula for below strategy.
1. Buy when CLOSE > EMA(HIGH,40) and difference is not more than 2 points.
2. Exit buy position when difference between trading price and EMA(High,40) is more than 5 points
3. Buy again when prices is touching EMA(HIGH,40)
4. Exit the buy position when difference between price and EMA(HIGH,4) is >= points.
5. Close the position when closing price is < EMA(LOW,40) and initiate short.
6. Follow same procedure for shorts to book profits for 5 points and enter again whince price touches EMA(LOW,40).
Find the attached image for reference.
Thavva,
Buy : Close>EMA(HIGH,40) AND EMA(HIGH,40)-CLOSE<2
Buy exit: EMA(HIGH,40)-CLOSE>5
Sell : CLOSE<EMA(LOW,40)
Sell exit: CLOSE – EMA(LOW,40)>5
Thavva, what you need to understand is that there is no way to write a code saying sell 5 points after buying, Sell, buy, sell exit , buy exit , everything has to be a code.
Thanks for the reply!
How to avoid repeat Buy / Sell?
If I have already sold a script, how to avoid selling it again on the second and third third signal generated by the logic?
Hi Deb,
Check this blog to manage your script
When you take a strategy live on algoZ, by default once a sell is initiated a new sell will come through only when there is an exit for the sell, i.e a new buy comes through.
So you don’t have to worry about it…
Hi Nithin,
Firstly, congrats on bringing algoz.
Being an engineer, I feel its THE BEST FEATURE. 😀
Now moving on to my doubt,
In ur previous comment u have mentioned that when algo is live,once a sell signal is initiated, a new sell signal will come thru only after an exit for the first sell.
But you yourself have mentioned that this works only in “LIve”
What should I do, so that my strategy works in the same way as “live” when i “backtest”? that is while backtesting also, my algo should nt give new signals unless i exit my position 🙂
Sibi, Backtest by default will not give you 2 buy or 2 sell signals next to each other. So you don’t have to do anything, it is already incorporated.
Dr Suhas had asked this query:
Dear Sir/Madam,
I want to write strategy, but I am not able to fit my startegy in this algo. Anybody please let me know how to write this.
1) I want to buy when closing of the candle is higher than highes of previous 9 candles & sell when closing of candle is lower than lows of previous 9 candles. This will be in hourly TF.
2) Secondly buy will be only when the trend is uptrend confirmed by cross-over of 8 & 34 EMA in hourly TF. Sell will be vice-versa.
3) In this system , exit from buy will be when candle closes below the lows of previous 9 candles with closing price below 8 EMA and exit from sell will be when candle closes above highes of previous 9 candles with closing price below 8 EMA.
Please let me know how to write this strategy?
Answer:
Buy expression: CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND EMA(CLOSE,8) > EMA (CLOSE,34)
Sell expression: CLOSE MINOF(MIN(LOW,8), REF(LOW,9)) AND EMA (CLOSE,8) < EMA (CLOSE,34)
Buy Exit: CLOSE < MINOF(MIN(LOW,8), REF(LOW,9))AND CLOSE < EMA (CLOSE,8)
Sell Exit:CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND CLOSE > EMA (CLOSE,8)
Pls code following strategy for me: all standard params
Buy if Close < Lower Bollinger AND RSI < 30
Exit long if RSI > 50 OR Touch Bolinger Avg.(Central MA)
Short Sell if Close > Upper Bolinger and RSI > 70
Cover Short if RSI < 50 OR Touch Bolinger Avg.(Central MA)
Stop Loss of 5%
Thanks.
Dweep:
Buy : CLOSE < BBB(CLOSE, 20, 2, EXPONENTIAL) AND RSI (CLOSE, 14) < 30
Buy exit: RSI(CLOSE, 14) > 50 OR CLOSE > BBM(CLOSE, 20, 2, EXPONENTIAL)
Sell: CLOSE > BBT(CLOSE, 20, 2, EXPONENTIAL) AND RSI (CLOSE, 14) > 70
Sell exit: RSI(CLOSE, 14) < 50 OR CLOSE < BBM(CLOSE, 20, 2, EXPONENTIAL)
Stop loss can’t be integrated into the script, but you can add it when taking your strategy live. Check this blog
How to stop a running script / strategy ?
Once I select to backtest / a strategy the script keeps running. Only when I select another strategy the first one stops and the other one starts running and keep on giving alerts. How to stop it running once I am not interest or done with it.
I could stop the running script only by swithcing off the Ztrader.
Sorry for the delay, was trying to put up a blog explaining this, was receiving a bunch of queries on this.
http://www.zerodha.com/z-connect/blog/view/managing-your-script
Check out the last bit on this blog.
Cheers.
Hi Nitin,
I am using parabolic SAR however, Its giving me weird results
CROSSOVER(CLOSE, PSAR(0.02, 0.2)) = TRUE,
I want to use this for both Buy/Sell, and Buy should signal only when stock price is above Parabola and Sell should signal only when stock price is below Parabola. Please suggest
Thanks in advance
SVR,
The code you have mentioned is correct.
Is AlgoZ available with Z-Trader(the web version) ?
The software version is probably unusable when in office
No Vicky, This can be used only with the software version.
Dear Team,
Is Algoz for intraday only?
When i take positions and close and open ZT where can i see the list of strategies that are already running ?
Thank you,
Juggy…
Juggy, strategy can be run live only on an intraday basis. If you are taking a position based on a daily chart, you will get a signal only after end of the day in the backtest report. You can execute it next day manually on the trading platform.
To manage your script, check this blog
Hi,
My amibroker afl code is
Buy=Cross(MACD(),Signal());
Sell=Cross(Signal(), MACD());
with the support/resistance of fibonacci extension.
How do i use the code in ZT?
Sebu,
Buy: MACD(26,13,9,EXPONENTIAL)>MACDSIGNAL(26,13,9,EXPONENTIAL)
Sell: MACD(26,13,9,EXPONENTIAL)<MACDSIGNAL(26,13,9,EXPONENTIAL)
You can input the values for Long Cycle, Short Cycle, Signal Line and MA Type according to what you select in the Parameter window in Amibroker.
I don’t see Backtest option for My strategy? How to get that option?
Same here also..why I am not seeing any BackTest option for My Strategy?
If you are not seeing backtest option, it means you are still not live on it, can you send an email to [email protected] , we will get it done.
I can see it now. Thanks for the reply!
How to Stop or edit currently runnning live script
no response ???
http://www.zerodha.com/z-connect/blog/view/managing-your-script explained here.
pls help me to write my strategy at the earlirst to backtest,I am anxiousily waiting
I have two stratergy to start of
1) For day trading
how to write a code If it is nearing todays high, or low like which shows up in http://www.buzzingstocks.com/in/heatmap.htm.
in the same expression i want to use buy only when EMA 10 crosses EMA 30 days or vice versa the time period that i want to use in 5 or 15minutes candle
2) Cross over of EMA 10 with EMA 30 days for 15 minutes candle with ADX crossing from 20 i.e buy or sell only when ADX is crossing from less than 20 to rising upward.
also please let me know is it possible to set alert using this stretergy for all the stock listed in market watch or only i can set alart for stock which i have opened in the chart.
Arjun,
Your queries are a little generic, can you be more specific.
We can write something like CLOSE > DIGH(1)*0.995 for buy and CLOSE < DLOW(1)*1.005 to show when its nearing the day’s high or day’s low.
For EMA you can use:
EMA (CLOSE, 10) > EMA (CLOSE, 30) – for buy
Dear Nithin,
I would like to do trade on Nifty future on 5x 3 ema crossover system. If 3 ema crossover 5 ema buy and if 3ema come below 5 ema sell. Basically I would like to long / short 4 lots of nifty. Profit on 1st lot i would like to take on 50 points. 2nd lots profit on 100 points. 3rd lot profit on 150 points. 4th lot for trailing stop loss.
It will be greately appreciated If your people will be able to make a code for the above.
Faisal, EMA crossover is pretty simple, also explained above:
Buy: EMA(Close,5)>EMA(Close,3) Sell: EMA(Close,5)<EMA(Close,3)
Buy exit: 0 Sell exit: 0
Profit of 1st lot 2nd lot etc would not be possible as they are not really a technical analysis condition.
But you can use the code above for buy/sell indicators and also backtest and see if it would have worked.
i want set a exit trigger for buy or sell with 1% from entry price , how to set that?
You have to set your triggers in the alert preference window. Is shown in this blog.
sir i know to put sl in that alert preference window.. what am asking is how to exit with 0.75% or 1% profit by using ‘Buy exit alert expression’
Congratulations on starting this excellent feature! All this would help enhance a trader’s confidence. However, I feel Zerodha seems to be taking the new initiatives at the cost of ignoring the basic requirements.
For example, I want to fully utilize my margin funds (leaving a cushion of say 5%). (This would be in Zerodha’s interest too.) However, there is huge difference between the margin blocked in the trading account (436K) and margin statement (512K) generated (both at EOD). SPAN calc(at browser based Zerodha trader) calculates a much lower amount (252K) for the same position. Can you please give the trader a confidence that she can take a position (without running the risk of a margin call/penalty) based on funds availability shown by trading account?
Now the queries related to algoZ.
1. Would you make this feature available on your browser based trading platform?
2. Is it possible to calculate ratio of the prices of two securities (say Nifty and BankNifty) and apply technical indicators on this ratio?
3. Where can I find the comprehensive list of keywords (eg Close, RSI, REF) that are used in coding?
PS. Sorry for putting an out-of-context concern here. However, I have unable to get a satisfactory response so far.
Thanks,
Anil Kumar
Anil,
Am looking at your query on margin and will get back to that.
about algoZ
1. Presently not possible on browser based platform.
2. You have to apply strategy to individual contracts and hence not possible to calculate as a ratio.
3. The keywords are available in the manual, if anything specific do let me know. Also check out all the strategies that we have coded here.
Hello zerodha.
How can write strategy for different time frame . Suppose i want to write following strategy for 5 min candles.
Also i want use Fibonacci retracement condition for ex buy IF close>38% level
Buy;
close>ema(close,110)&CCI(simple,14)>100
Sell:
close<ema(close,110)&CCI(simple,14)=-100<CCI(simple,14)<-500 (I want to only sell if CCI is greater than -100 on -ve scale for ex -110,-120)
Where i can write Stop loss for buying and selling
for buy close<EMA(Close,3)
for sell close>EMA(close,3)
Eagerly waiting for your valuable guidance.
Sudarshan, on algoZ we cannot write strategies for different time frames. Strategies are independent of time frame and can be applied on any time frame.
Your expressions are pretty much correct, except for small things.
Buy: CLOSE > EMA(CLOSE,110) AND CCI(14, SIMPLE) > 100
Sell: CLOSE < EMA (CLOSE,110) AND CCI(14, SIMPLE) < -100
Buy Exit: CLOSE<EMA(CLOSE,3)
Sell Exit: CLOSE>EMA(CLOSE,3)
ERROR
what is the code for stop loss?
There is no code for stoploss, you can write an exit expression or else choose a preset stoploss order based on Trigger % in the alert preference window.
Check this blog
Traders,
we can make this blog,live, informative,result oriented,profitmaking one.
Clear all your doubts ,for a better profit,share your strategies if you are profitable,
Sharemarket is an ocean of money,anyone can make a profit if you are consistent,
dedicated and not greedy.
@Sasi,
Yes traders can exchange strategies here, but are very soon planning something that will incentivize traders to share strategies. 🙂
Sir,
I have gone through the your replies and examples. Nowhere I saw any mention of timeframe. A particular strategy may not work for all timeframes. Is it that the programmes are only for daily and one minuite?
Prabit,
You decide the time frame to take a particular strategy live in the alert expression window. Have explained the same in this blog, check out Taking it live/Alert preference , you will see an option to set interval.
While backtesting, the backtest result will be based on the chart, if the candle is 1 min, you get 1 min result, if candle is 5 min, the backtest would be based on 5 min interval..
Cheers,
where can we get the complete list of functions and their parameters that are available. The manual and guides that are available in this forum seems to be inadequate. Request the complete programming/user manual please.
Bhuvan,
The manuals on the Zconnect is what is available for now. If there is any expression that you are looking for, let me know.
How to code the following
1 – Highest price value (price value can be open, high. low close of bars) over last n bars
2 – Lowest price value (price value open, high. low close of bars) over last n bars
3 – Remove excess signals (ie, if I am already in sell and again if one of my sell entry conditions is met, I do not want o be prompted to sell again – similar to exrem in AFL)
4 – How many bars before the current bar did the previous high of low appeared (in relation to points 1 and 2 above)
5 – Can I use REF to refer back to values of indicators. If possible, how to get the previous peak value of indicator and the low value of indicator.
6 – How to code the wait (wait 2 more bars after a condition is met before entry)
1 – Highest price value (price value can be open, high. low close of bars) over last n bars?
Ans:
“Will explain this with an example. Highest value among Open, High, Low, Close for a bar is obviously the High, so to calculate Highest Hugh value for say, 10 bars, the following script is recommended:
MAXOF(MAX(HIGH,9), REF(HIGH, 10))”
2 – Lowest price value (price value open, high. low close of bars) over last n bars
Ans: MINOF(MIN(LOW, 9), REF(LOW, 10))
3 – Remove excess signals (ie, if I am already in sell and again if one of my sell entry conditions is met, I do not want o be prompted to sell again – similar to exrem in AFL)
Ans: Already handled in execution, once a sell signal is acted on, the next signal will either be a Sell Exit or a Buy, not a sell again. You might have to include a REF condition to this. Like, if the close price goes above the SMA 10 line, it means in the current candle, close is greater than SMA10, but in the previous candle it was lesser than SMA. So the code would look like CLOSE > SMA (CLOSE, 10) AND REF(CLOSE, 1) < REF(SMA(CLOSE, 10), 1). In this case even if you ignore the signal, it wont generate another one because the condition wouldnt hold true then.
4 – How many bars before the current bar did the previous high of low appeared (in relation to points 1 and 2 above)
Ans: You can use LASTIF(Condition), but would need more information to provide a complete code.
5 – Can I use REF to refer back to values of indicators. If possible, how to get the previous peak value of indicator and the low value of indicator.
Ans: Need more information. An example would be useful.
6 – How to code the wait (wait 2 more bars after a condition is met before entry)
Ans:
use REF. if your condition is something like Close > Sma (Close, 10), with wait for 2 bars, the condition would look like REF (Close,2) > Ref (SMA(Close, 10), 2)
Sir,
Any phone nos,are available to communicate to experts,though we dont want to publish ,our strategy
Sasi,
This is actually pretty simple and the idea of answering everything on an open forum is that when you see examples of a few, you will automatically get an idea of how to code yourself in a while.
But if there is anything specific that you don’t want to share, you can ask me for it with different candles or you can break it up into different queries, so no one gets to know.
🙂
Cheers,
Sir,
Thank you for the valuble reply,
I wish to know, 1. SMA VALUES 2000 ,3000,are available to make an expression ?
2. As I am a zerodha trader,where I can go for these fecilities.
Sasi,
Basically you can make an expression if you have access to 2000 or 3000 candles.
What I mean to say is presently for all stocks we have daily data from commencement. So assume you are analyzing daily historical chart of Reliance for 10 years. You will have 2500 daily candles( 250 days/yr and 10 years), so yes you run the strategy.
But if you are looking at hourly candles, 2500 candles would mean 2500 hours which is around 400 days. We presently don’t give you 400 hourly candles data on algoZ, so this won’t work.
We will be providing only online support for algoZ, all your queries will be answered here. Check this http://www.zerodha.com/z-connect/blog/view/algoz-a-simple-example gives you how to write/backtest/go live on a very simple strategy. The only thing that you will have to change is the code.
Best of luck.
Dear Sir,
Another excellent effor by Zerodha team. I want a code for the following strategy.
Trading Price > Previous close and Trading Price > Open = Buy
(But it should be done @ 10.15 AM of every day and closes the position @ 3.10PM)
Trading Price < Previous Close and Trading Price < Open = Sell
(But it should be done @ 10.15 AM of every day and closes the position @ 3.10PM)
Stoploss is vice versa and it should take position as well in case of stoploss triggered.
Can you make a strategy for this?
Thanks in advance
Gopi,
Presently you cannot code yesterday’s close or today’s open.
But if you are doing it on a particular time frame and use the start/stop time as explained in this blog you can manage. You can keep start as 10.15am and end as 3.10pm. No new alerts come after 3.10pm, but if there is a position/order, it will continue to exist unless you cancel manually.
If you are writing this on a candle basis
Buy expression: Close>REF(Close,1) AND Close>Open
Buy exit: 0
Sell expression: Close<REF(Close,1) AND Close<Open
Sell exit: 0
You can also have a preset stop loss % as explained in the blog.
Hopefully this helps.
Hello Zerodha,
How do I use Start and stop time in Back Testing.. I want to back test say between 10 AM and 3 PM only?
Pradeeep TV asked:
Basically i want to use heikin-ashi charts, so my close, open, low and
high are specified below —
HA-Close = (Open(0) + High(0) + Low(0) + Close(0)) / 4
HA-Open = (HA-Open(-1) + HA-Close(-1)) / 2
HA-High = Maximum of the High(0), HA-Open(0) or HA-Close(0)
HA-Low = Minimum of the Low(0), HA-Open(0) or HA-Close(0)
Buy —> If the close goes above highest close of last 4 candles then buy.
Sell —> If the close goes below lowest close of last 4 candles then sell
Answer:
For all those who don’t know Heiken-Ashi is a type of candle stick chart with the difference being in the following parameters.
Close = (Open+High+Low+Close)/4
Open = [Open (previous bar) + Close (previous bar)]/2
High = Max (High,Open,Close)
Low = Min (Low,Open, Close)
Your condition is the below to buy/sell, which is based only on the close, so you really don’t need to worry about open, high, low.
Buy —> If the close goes above highest close of last 4 candles then buy.
Sell —> If the close goes below lowest close of last 4 candles then sell
The below should be self explanatory.
Buy expression:
SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC>MAXOF(REF(HAC,1), REF(HAC,2), REF(HAC,3), REF(HAC,4))
Buy exit: 0
Sell expression:
SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC < MINOF(REF(HAC,1), REF(HAC,2), REF (HAC,3), REF (HAC,4))
Sell exit: 0
You can check out the example above where I have mentioned the use of REF function. REF basically takes reference of the candle, so REF(HAC,1) would mean HAC for 1 candle before, REF(HAC,2) 2 candles before and so on.
Hello team, I have tried the above script but its giving error undefined variable HAC. Could you please help me out on this ?
Buy:
(MAXOF(REF (CLOSE, 1), REF (CLOSE, 2), REF (CLOSE, 3), REF (CLOSE, 4))) < CLOSE Sell: (MINOF(REF(CLOSE, 1), REF(CLOSE, 2), REF(CLOSE, 3), REF(CLOSE, 4))) > CLOSE
Dear Team,
need your help to write and test following
expression for Let say WR+ => -50 AND STOCHRSI => 0.50 it should buy and WR+ < -50 AND STOCHRSI < 0.50
Thanks
Atul Chaudhari
Sorry for the delay Atul,
Here is the code below and calculated on 14 candles. You can change it to any you want.
Buy expression:
SET R= RSI(Close,14)
SET N=R – (MINOF(MIN(R,13), REF(R,14)))
SET D= (MAXOF(MAX(R,13), REF(R,14))) – (MINOF(MIN(R,13), REF(R,14)))
SET STOCHRSI= N/D
WPR(14)>-50 AND STOCHRSI>0.50
SELL EXPRESSION:
SET R= RSI(Close,14)
SET N=R – (MINOF(MIN(R,13), REF(R,14)))
SET D= (MAXOF(MAX(R,13), REF(R,14))) – (MINOF(MIN(R,13), REF(R,14)))
SET STOCHRSI= N/D
WPR(14)<-50 AND STOCHRSI<0.50
pl help me to config this script, its working on my charting s/w
buy
RSI:=SMA(MAX(CLOSE-REF(CLOSE,1),0),14,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),14,1)*100;
SRSI:=(RSI-LLV(RSI,14))/(HHV(RSI,14)-LLV(RSI,14));;
WR:=-100*(HHV(HIGH,14)-CLOSE)/(HHV(HIGH,14)-LLV(LOW,14));
EXIST((WR>=-90 & SRSI>=0.9),1);
sell
RSI:=SMA(MAX(CLOSE-REF(CLOSE,1),0),14,1)/SMA(ABS(CLOSE-REF(CLOSE,1)),14,1)*100;
SRSI:=(RSI-LLV(RSI,14))/(HHV(RSI,14)-LLV(RSI,14));;
WR:=-100*(HHV(HIGH,14)-CLOSE)/(HHV(HIGH,14)-LLV(LOW,14));
EXIST((WR<=-10 & SRSI<=0.1),1);
pls help me to write my strategy at the earlirst to backtest,I am anxiousily waiting
200 ema crossover above 1300 sma for a buy
200 ema crossover below 1300 sma for a sell
Posting all your queries under one main query.
hi,
where are your experts,so far no reply ?,A reply should be posted at least within 1 hour,what a blog is this.?
One question a day
An answer on another day
A blog should be busy with questions and answers,then only more traders will login to know different strategies,
This is afterall to make money,not for timepass
pls answer me
I have one another question
can I write a strategy to buy above a certain price,to sell below a certain price of a particular scrip
for eg:
TATA STEEL TO BUY N LONG ABOVE RATE 310 ,TO SELL N SHORT BELOW 310
HI,
CAN WE WRITE A VALUE ABOVE BUY AND VALUE BELOW SELL FOR A SCRIP FOR A DAY
Firstly Sasi, This particular blog is for helping you write codes/programs and we are doing it as a value add to our customers. We will be replying to all of this at our convenience, we don’t guarantee reply in any fixed duration.
You can’t write a strategy to buy above and below a price, because that is not really technical analysis. If you have a particular condition, you can set to buy above it or sell below it, like the EMA example you have given.
You can set a buy/sell based on any of the previous candles, but can’t write above and below as you have mentioned in both the queries.
Cheers.
The EMA example is already explained above, do have a look at that also.
Here is your expression:
Buy expression: EMA(Close,200)>SMA(Close,1300)
But exit: 0
Sell expression: EMA(Close,200)<SMA(Close,1300)
Sell exit: 0
Cheers,
Nithin
Hi I am Looking for Price action Trading support tool, Which is available with Angle broking, I.e , Candlestick information , Bearish Engulfing, Bullish Engulfing, Inverted Hammer, Doji, like all the pattern are is available with Angle broking
I am looking this kind of information in PI , or KITE , if you can code it and send the details I would be happy to use it
Please do the needful immediately
Best Regards
Shivakumar
My strategy is:
When 14 period ADX is above 25
MacD with 26,13,6 values shows a buy/sell crossover respectively, and then the move is confirmed by below criteria to open a buy/sell position respectively
Stock retraces at least 3 days from up/down trend (It can be between 3 and 5 days retracement) and then to take buy/sell position respectively when the price goes above/below previous days High/low respectively
I hope there will be a code for my above strategy
More expression
The ADX should be above 25 and rising from lower levels and not falling from higher levels
Reposting all your related quries under 1 heading
When I right click on chart I do not see script. Is it because I am a new trader or its because i have to enable something
Amar, yes you if you are not able to see the edit option as shown in this
Your description for the quote is not very clear, so ensure you backtest and see if it is performing the way you want to :
Buy Expression:
CLOSE > REF(HIGH,1) AND ADX(14) > 25 AND REF(ADX(14),1) < 25 AND MACD(26,12,9,EXPONENTIAL) > 0 AND CLOSE < REF(CLOSE,-1) AND REF(CLOSE,-1) < REF(CLOSE,-2) AND REF(CLOSE,-2) < REF(CLOSE,-3)
Buy exit: 0
Sell Expression:
CLOSE < REF(LOW,1) AND ADX(14) > 25 AND REF(ADX(14),1) < 25 AND MACD(26,12,9,EXPONENTIAL) < 0 AND CLOSE > REF(CLOSE,-1) AND REF(CLOSE,-1) > REF(CLOSE,-2) AND REF(CLOSE,-2) > REF(CLOSE,-3)
Sell exit: 0
Can you share any document on AlgoZ
Anant, the user manuals are put up in algoZ section on Zconnect. Click here…
from when can u give more info about writing strategy , as i work on multiple strategies for scripts
Pawar,
So hopefully all the queries answered above should be of help, also look at the user manuals. You can run multiple strategies with predetermined stop loss % and order size.
I WANT TO CODE THE STRATEGY 3 EMA AND 15 EMA CROSSOVER.
HOW CAN I WRITE THE CODE WHEN –
EMA(CLOSE,3) CROSS EMA(CLOSE,15) THEN I WILL BUY
AND WHEN
EMA(CLOSE,15) CROSS EMA(CLOSE,3) I WILL SELL
TIME INTERVAL – DAILY
REGARDS
GAUTAM
As explained to Jimmy above, a pretty simple code:
Buy expression: EMA(Close,3)>EMA(Close,15)
Buy exit: 0
Sell Expression: EMA(Close,3)<EMA(Close,15)
Sell exit: 0
Gautam, after writing, when you are backtesting the strategy, first open the historical chart which will by default give daily candles. Click on backtest as shown in the simple example. It will now show you backtested result for the above as per daily candles.
If it is daily candle that you are using, you can’t take the strategy live, in the sense the chart will show you a buy/sell at the end of the day and you will have to execute it manually the next day.
Cheers.
I WANT TO CODE THE STRATEGY 3 EMA AND 15 EMA CROSSOVER.
HOW CAN I WRITE THE CODE
–
BUY AT 15:25 HRS IF EMA(CLOSE,3) CROSS EMA(CLOSE,15) ON DAILY CANDLE.
AND
SELL AT 15:25 HRS IF EMA(CLOSE,15) CROSS EMA(CLOSE,3) ON DAILY CANDLE.
Buy: EMA(Close,3)>EMA(Close,15) Buy exit: 0
Sell: EMA(Close,3)Managing your script, you can set an execution time period.
The thing though is that you will not be able to go live on a daily candle as the candle will be complete only at the end of the day and not at 3.25pm, if I am understanding your strategy right. If you want the system to give you an indicator on its own, you will need to run the strategy on intraday chart. If you want to run this on a daily candle, you will have to do it after the market closing and place a trade the next day when market opens.
What is the code for gann hi lo indicator, it gives similar results as given by super trend indicator used by marketcalls.in
You can give us the logic, we can look at coding it. First impression is that it looks a little elaborate and might take some time.
Have sent the detailed info thru mail. Just curious to know how long will it take to complete.
have u add in pi
Prashant,
Gann hi lo is pretty tricky to write. Will take a bit, you are presently using this on which platform?
Thanks for the great idea!
Generally I use MACD of Short Period 12 and Long Period 26 with RSI Period 10.
I buy @ cross over + RSI~30 (Increase the value of RSI from a lover range)
I sell@ cross over + RSI~70 (Decrease the value of RSI from a higher range)
Please make strategy for the expression.
Sebu,
You are looking at MACD crossover, buy if MACD crossover, provided the RSI has moved from less than 30 to more than 30 and similarly sell if RSI has moved from above 70 to below 70.
For those of you who don’t understand MACD crossover and RSI, you can google for it. The thing is we are combining 2 strategies and we have to take a buy or sell only if both the strategies meet the conditions set.
@sebu, you have given me the MACD line which is 12 and 26, but you haven’t given me the signal line, so will take the default 9.
Code:
Buy Expression:
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 AND REF(RSI(CLOSE,10),1)>70
Sell exit: 0
The above is actually pretty simple if you look at it. The new thing which is used here is the ” AND” expression. You can use all boolean logic like AND, NOT, OR etc. In this case AND because you want a buy/sell indicator only if all the conditions are met.
Have explained about REF in the previous example, in the case of buy, you want to buy only if RSI was below 30 the previous candle and it is above 30 at the close of this candle. Do check out the REF example above, should clarify .
Cheers
Can you give strategy for:
Buy: EMA(close 7) crossover EMA(14) + trailing stoploss at 1.5%
Sell: EMA(close 7) crossbelow EMA(14) + trailing stoploss at 1.5%
Jimmy, there is no features of trailing stop loss presently. But in your alert preference you can preset Stop loss%.
Crossover of exponential moving averages are probably what most technical analysts, start off with. With these crossovers, if markets are trending in a big way it makes you money but in flat markets can again chop you.
Your code:
Buy: EMA(Close,7)>EMA(Close,14) Sell: EMA(Close,7)<EMA(Close,14)
Buy exit: 0 Sell exit: 0
Again exit as 0 because for ex, if you bought nifty at 5800 on a crossover at 5850 if a sell crossover happens, you not only exit what you had both also short another.
Cheers,
Hello Nitin,
I am not a programmer, so I will explain my strategy in layman terms and you please let me know is it possible to code this strategy..
it is kind of breakout strategy….i want to place Stop Loss Buy pending order above previous bar’s High and Stop Loss Sell pending order below the previous bar’s low and if any of the order gets executed, the corresponding against order should automatically be the Stop Loss value for the Executed order.
I hope you understand this strategy…do reply me…
This one is actually pretty simple if I got your query right.
The idea is to buy if the price goes higher than high of the previous candle and sell if it goes lower than the previous low.
Good thing with this is that again you are going with the nearest trend. If you are using 1 minute candles there might be a lot of buy and sell signals, ensure you choose the right candle for a strategy like this.
The code:
Buy expression: CLOSE>REF(HIGH,1) Sell Expression: CLOSE<REF(LOW,1)
Buy exit : 0 Sell exit: 0
A REF function basically takes you to any previous candle, in this case(High,1) will give you a reference of highest 1 candle back(previous candle).
If you mentioned REF(High,3), it will take reference of the highest point 3 candles back.
Similarly for the Sell, REF(LOW,1) will give you a reference point of low of 1 candle back. So if the present candle closes below the previous candle low,you automatically get an indicator.
exit expression is kept at 0 , because you want to exit and also reverse the trade if the opposite indicator initiates. So if you have bought 1 lot, when the sell indicator comes, you exit your 1 lot and take a fresh short of 1 lot.
Hope this clarifies.
Thank you very much for your prompt and swift reply.
You got it right, but instead of previous candle like REF(HIGH,1) or REF(HIGH,3) or REF(HIGH,4)…is it possible to mention time…for example I want to place Stop Loss Buy pending order above the High of 11:15 Bar (15-Minute Timeframe chart and when the 11:15 bar closes I want to place Buy Stop above the 11:15 Bar’s High and Sell Stop below the 11:15 Bar’s Low)….can you please explain how to code this simple concept….Thanks in advance…
You guys are really doing good job….I really appreciate it
sir ji.. did u got the algo code for your question?..based on time candle break out buy and sell..
thats good strate..
if u found code
please forward
thank you
Also please do let me know, is it possible to place Stop Loss and Target Profit for the orders
Hi Ztrader,
Were you able to generate a code for this. I am also looking for a similar strategy to trade pivot high/lows/
Abhishek, can you ask all your coding queries here: http://tradingqna.com/
Check this http://www.zerodha.com/z-connect/blog/view/managing-your-script
How to place Stop loss is shown above.
Your sell expression is your exit order for your buying position and at sell expression you can take a fresh sell also or vice versa.
Otherwise you can also mention a buy exit expression, which will be your exit for buy and sell exit for sell..
Sir i need day low bullish Engulfing in days low and days High bearish engulf code pls help me
As given by you in the simple example, a 14 EMA crossover gives you a lot of unwanted signals. What if I want to sell on 14EMA crossover if RSI is above 60 and buy on 14EMA crossover, if RSI below 40?
How do I code it and can you also share the backtest result.?
14 EMA crossover will give a lot of buy/sell and you might get chopped when markets are flat.
RSI(Relative Strength Index) as investopedia explains is a technical momentum indicator that compare the magnitude of recent gains to recent losses in an attempt to determine overbought and oversold conditions of an asset. In simple words, RSI ranges from 0 to 100 and typically if the value is more than 70 it is said to be overbought and if lesser than 30 oversold. So according to RSI, it is not a good time to buy if above 70 or to short if below 30.
So what Dip wants to do is, he wants to buy when 14 EMA is crossing over only if RSI is below 40, the RSI condition acts like a secondary condition to filter trades by taking on those crossovers where the contract is close to oversold, but definitely not overbought.
Similarly he wants to sell on a crossover only if RSI above 60, close to being overbought but definitely not oversold.
This additional logic is a good filter to have for someone starting off on technical analysis. The number 40 or 60, you have to decide based on backtesting.
RSI again has a time period to it which Dip has forgot to mention, but since we are looking at 14 EMA, will assume he meant a 14 candle RSI.
For the above example:
Your buy expression would be: Close>EMA(Close,14) AND RSI(Close,14)<40
Your sell expression would be : Close < EMA(Close,14) AND RSI(Close,14) > 60
Your buy exit expression: 0
Your sell exit expression: 0
Basically when you mention a 0 on the buy/sell exit expression, your exit for the buy would be your sell expression and vice versa.
So for example, if your preset order size is 1 lot, if your buy expression gives you a prompt, you buy 1 lot and when the sell expression comes, you sell the 1 lot you are holding and take a fresh selling 1 lot.
You can follow the steps in this blog to save this expression, backtest and take live.
Backtest result for the last 22 days intraday on 1 min candles:
1st trade Short at 5610 , buy at 5509 profit of 101 points.
2nd trade Short at 5629, if you had put a 50 point SL, loss of 50 points.
Net profit of around 50 points, but do note that strategies like these which work on moving averages can be choppy in flat markets.
Hope this helps,
Cheers,
This code is not working. Shows error
Not working
Hello Nitin , I wanted to understand the following points :
1. There was a plugin available from Ami broker to your Trading Terminal Software. Is it still available?
If Yes , how does a user purchase Data , analyze it and back test it in this module?
2. Can a code written in Ami Broker AFL Language be used in your Software Algoz? If not is there any way out possible to do so? Since we have so many codes written and they employ a lot of different charting tools and indicators how do we integrate the two systems?
3. Are you planning on coming up with a Data Subscription for charting software real time as well as past historical data.
Which Language is AlgoZ based on? It is a charting software with features like Amibroker/MT4 etc
Thanks
Dheeraj
DJ,
1. For the AMI plugin, you will have to get in touch with our partners Global data feeds, subscribe to live data from them and analyze/backtest it on amibroker.
2. AFL language would be different compared to what is available on algoZ. algoZ is simpler than AFL, but you will have to code this separately. We will be helping you understand how to write codes on algoZ in the tutorial section. These 2 are separate systems and can’t really be integrated for now.
3. The charting/programming will be available on your trading platform and you will get data by default. In the present beta version, we are giving 22 days intraday data and 1 yr daily historical chart. In the next version you will have 10 months data of intraday and historical to backtest from commencement.
Click here to know the details of the programming language .
Hi Nithin, Is there an update on the 10 months of intraday data being made available? When is this likely tyo
Hari,
This will happen only once our new trading platform is out, we are in the regulatory approval process for that.
I want to find stocks which follow the following criteria.
I)50 day e.m.a above 150 ema
2)macd gives + bias
3)stock candle testing 14 day e.m.a
4)stochastic showing oversold or below the 20%
can it be possible from programming that I am able to find stock from nifty which able to fullfill the above criteria on daily basis
Can you put this up on tradingqna.com
HI Nitin,
i would be required code for below trade
Latest close Crossed above Max( 20,open) ” PRICE JUST CROSSED ABOVE 20 PERIOD HIGH PRICE ”
EMA 2O > EMA 50
EMA 50 > EMA 100
Best post your query here. A fellow forum member may be able to help.
Sir,
Can you help me with a visual basic code to find the number of visits to range low and range highs over last 1 hour
regards,
Sachin
Hey Sachin, best post this here. A fellow forum member may be able to help.
hi sit mMY COAD I RD0288 I USES FOR AMIBROKER FORMULAS
SO PLZ THIS FORMULA TO EDD MY NEST TREDER SOFTWER
FORMULAS ISSSSSSSSS
_SECTION_BEGIN(“SuperTrend”);
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor(“bkcolor”,ColorRGB(0,0, 0)));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor(“Candle UP Color”, colorGreen),IIf(C<=O,ParamColor(“Candle Down Color”, colorRed),colorLightGrey)));
Plot(C,”nPrice”,IIf(C>O,ParamColor(“Wick UP Color”, colorDarkGreen),IIf(C<=O,ParamColor(“Wick Down Color”, colorDarkRed),colorLightGrey)),64,0,0,0,0);
SetTradeDelays(1,1,1,1);
_N(Title = StrFormat(“{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Factor=Param(“Factor”,3,1,10,1);
Pd=Param(“ATR Periods”,10,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;
for (i = 1; i <BarCount; i++) {
TrendUp[i] = Null;
TrendDown[i] = Null;
trend[i]=1;
if (Close[i]>Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;
}
else if (Close[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}
if (trend[i]<0 && trend[i-1]>0) {
flag=1;
}
else {
flag=0;
}
if (trend[i]>0 && trend[i-1]<0) {
flagh=1;
}
else {
flagh=0;
}
if (trend[i]>0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}
if (trend[i]<0 && Up[i]>Up[i-1])
{ Up[i]=Up[i-1];
}
if (flag==1)
{ Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
}
if (flagh==1)
{ Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
Plot(TrendUp,”Trend”,colorGreen);
Plot(TrendDown,”Down”,colorRed);
Buy = trend==1;
Sell=trend==-1;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);
Title = EncodeColor(colorWhite)+ “www.KEWALNIFTY.com” + ” – ” + Name() + ” – ” + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
” – ” + Date() +” – “+”n” +EncodeColor(colorRed) +”Op-“+O+” “+”Hi-“+H+” “+”Lo-“+L+” “+
C+” “+ “Vol= “+ WriteVal(V)+”n”+
EncodeColor(colorLime)+
WriteIf (Buy , ” GO LONG / Reverse Signal at “+C+” “,””)+
WriteIf (Sell , ” EXIT LONG / Reverse Signal at “+C+” “,””)+”n”+EncodeColor(colorYellow)+
WriteIf(Sell , “Total Profit/Loss for the Last Trade Rs.”+(C-BuyPrice)+””,””)+
WriteIf(Buy , “Total Profit/Loss for the Last trade Rs.”+(SellPrice-C)+””,””);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
TrendSL=IIf(trend==1,TrendUp,TrendDown);
for(i=BarCount-1;i>1;i–)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = “BUY”;
sl = TrendSL[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = “SELL”;
entry = C[i];
sl = TrendSL[i];
tar1 = entry – (entry * .0050);
tar2 = entry – (entry * .0112);
tar3 = entry – (entry * .0212);
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == “BUY”, colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), “”, colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), “”, colorGreen, styleLine|styleLine, Null, Null, Offset);
for (i=bars; i <BarCount;i++)
{
PlotText(“”+sig+”@”+entry, BarCount+1,entry,Null,colorBlue);
PlotText(“TARGET 1@”+tar1,BarCount+3,tar1,Null,Clr);PlotText(“TARGET 2@”+tar2,BarCount+3,tar2,Null,Clr);PlotText (“TARGET 3@”+tar3,BarCount+3,tar3,Null,Clr);
}
messageboard = ParamToggle(“Message Board”,”Show|Hide”,1);
if (messageboard == 1 )
{
GfxSelectFont( “Tahoma”, 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( sig ==”BUY”)
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( “pxchartheight” ) ;
xx = Status( “pxchartwidth”);
Left = 1100;
width = 310;
x = 5;
x2 = 290;
y = pxHeight;
GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y – 98, x2, y , 7, 7 ) ;
GfxTextOut( ( “WWW.KEWALNIFTY.COM-TREND”),13,y-100);
GfxTextOut( (” “),27,y-100);
GfxTextOut( (” LAST ” + sig + ” CALL ” + (BarCount-bars-1) * Interval()/60 + ” MNTS AGO “), 13, y-80) ; // The text format location
GfxTextOut( (“” + WriteIf(sig ==”BUY”,sig + ” @ “,sig + ” @”) + ” : ” + entry), 13, y-60);
GfxTextOut( (“TRAILING SL : ” + TrendSL + ” (” + WriteVal(IIf(sig == “SELL”,entry-sl,sl-entry), 2.2) + “)”), 13, y-40);
GfxTextOut( (“CURRENT P/L : ” + WriteVal(IIf(sig == “BUY”,(C-entry),(entry-C)),2.2)), 13, y-22);;
}
_SECTION_END();
_SECTION_BEGIN(“Magnified Market Price”);
FS=Param(“Font Size”,28,11,100,1);
GfxSelectFont(“Arial”, FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor(“Color”,colorViolet) );
Hor=Param(“Horizontal Position”,766,1,1200,1);
Ver=Param(“Vertical Position”,1,1,1,1);
GfxTextOut(“”+C,Hor , Ver );
GfxTextOut( Name(), Hor,Ver-50 );
YC=TimeFrameGetPrice(“C”,inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont(“Arial”, 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor(“Color”,colorViolet) );
GfxTextOut(“”+DD+” (“+xx+”%)”, Hor+5, Ver+45 );
_SECTION_END();
Hai Do You Want Super Trend Copy & Past This AFL on Your AFL Editor This Code Run Properly
/* Done by */
/* Author of Non Repainting Super Trend Indicator */
_SECTION_BEGIN(“SuperTrend”);
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor(“bkcolor”,ColorRGB(0,0, 0)));
GfxSetBkMode(0);
GfxSetOverlayMode(1);
SetBarFillColor(IIf(C>O,ParamColor(“Candle UP Color”, colorGreen),IIf(CO,ParamColor(“Wick UP Color”, colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);
SetTradeDelays(1,1,1,1);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Factor=Param("Factor",4,1,10,0.1);
Pd=Param("ATR Periods",10,1,100,1);
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;
for (i = 1; i Up[i-1]) {
trend[i]=1;
if (trend[i-1] == -1) changeOfTrend = 1;
}
else if (Close[i]<Dn[i-1]) {
trend[i]=-1;
if (trend[i-1] == 1) changeOfTrend = 1;
}
else if (trend[i-1]==1) {
trend[i]=1;
changeOfTrend = 0;
}
else if (trend[i-1]==-1) {
trend[i]=-1;
changeOfTrend = 0;
}
if (trend[i]0) {
flag=1;
}
else {
flag=0;
}
if (trend[i]>0 && trend[i-1]0 && Dn[i]<Dn[i-1]){
Dn[i]=Dn[i-1];
}
if (trend[i]Up[i-1])
{ Up[i]=Up[i-1];
}
if (flag==1)
{ Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
}
if (flagh==1)
{ Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
}
if (trend[i]==1) {
TrendUp[i]=Dn[i];
if (changeOfTrend == 1) {
TrendUp[i-1] = TrendDown[i-1];
changeOfTrend = 0;
}
}
else if (trend[i]==-1) {
TrendDown[i]=Up[i];
if (changeOfTrend == 1) {
TrendDown[i-1] = TrendUp[i-1];
changeOfTrend = 0;
}
}
}
Plot(TrendUp,”Trend”,colorGreen);
Plot(TrendDown,”Down”,colorRed);
Buy = trend==1;
Sell=trend==-1;
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);
ShortPrice=ValueWhen(Short,C);
CoverPrice=ValueWhen(Cover,C);
Title = EncodeColor(colorWhite)+ “RAJESH J ST System” + ” – ” + Name() + ” – ” + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
” – ” + Date() +” – “+”\n” +EncodeColor(colorRed) +”Op-“+O+” “+”Hi-“+H+” “+”Lo-“+L+” “+
“Cl-“+C+” “+ “Vol= “+ WriteVal(V)+”\n”+
EncodeColor(colorLime)+
WriteIf (Buy , ” GO LONG EXIT SHORT / ST Signal at “+C+” “,””)+
WriteIf (Sell , ” GO SHORT EXIT LONG / ST Signal at “+C+” “,””)+”\n”+EncodeColor(colorYellow)+
WriteIf(Sell , “Total Profit/Loss for the Last Trade Rs.”+(C-BuyPrice)+””,””)+
WriteIf(Buy , “Total Profit/Loss for the Last trade Rs.”+(SellPrice-C)+””,””);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
TrendSL=IIf(trend==1,TrendUp,TrendDown);
for(i=BarCount-1;i>1;i–)
{
if(Buy[i] == 1)
{
entry = C[i];
sig = “BUY”;
sl = TrendSL[i];
tar1 = entry + (entry * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
bars = i;
i = 0;
}
if(Sell[i] == 1)
{
sig = “SELL”;
entry = C[i];
sl = TrendSL[i];
tar1 = entry – (entry * .0050);
tar2 = entry – (entry * .0112);
tar3 = entry – (entry * .0212);
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == “BUY”, colorLime, colorRed);
ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));
sl = ssl[BarCount-1];
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), “”, Clr, styleLine|styleDots, Null, Null, Offset);
//Plot(LineArray(bars-Offset, sl, BarCount, sl,1), “”, colorDarkRed, styleLine|styleLine, Null, Null, Offset);
//Plot(LineArray(bars-Offset, entry, BarCount, entry,1), “”, colorGreen, styleLine|styleLine, Null, Null, Offset);
/*
for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount-5,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount-5,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount-5,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount-5,tar3,Null,Clr);
}*/
messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;
y = pxHeight;
GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y – 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "RAJESH J ST System"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + Ref(TrendSL,-1) + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);;
//Magfied Market Price
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",1000,1,1200,1);
Ver=Param("Vertical Position",70,1,830,1);
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
}
_SECTION_END();
_SECTION_BEGIN("Time Left");
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber – int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame – SecsLeft;
x=Param("xposn",15,0,1000,1);
y=Param("yposn",55,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
//GfxRoundRect( x+45, y+40, x-3, y-2, 0, 0 );
//GfxSetBkMode(1);
GfxSelectFont( "Arial", 14, 700, False );
GfxSetTextColor( colorRed );
GfxTextOut( "Time Left :"+SecsToGo+"", x, y );
_SECTION_END();
Is it possible to run in zerodha PI of the supertrend coding given above? If so how?
can we run this code in java or python.
Something similar to quantopian would be of great use to the traders.
Also, could you open a GitHub account to group these scripts?
Not immediately, but eventually we will.
Hi Nithin,
I want a buy signal to be generated if the price moves above 5 days high with heavy volume in five minute candles.
And a sell signal if price moves below 5 days low with heavy selling.
Thanks
Rakesh G R
When Nifty 5800 CE plus 5800 PE is less than Rs. 200, buy the same…please give a code to execute this strategy….its a very simple thing, does not involve any technical but so difficult to keep track of….not sure if AlgoZ is going to execute such strategy because it involve two contracts….
Presently not possible since it involves 2 contracts, algoZ can be used on only 1 scrip at a time.
can i get signal strategy for last red candle’s high is crosses by next green candle’s cmp?
Hi Zerodha,
I want a buy signal to be generated if the price is above 5 days high and sell signal if the price is below 5 days low,please tell us the code and also please introduce price alert in kite.
Thanks
Rakesh
What happens when HHV(20) CROSSES LLV (20) .SHOULD I BUY THAT SHARE.?
i want a code that whenever stock goes below rsi 35
Hi zerodha,
I need both buy and sell code with my strategy ema 10 and ema 20 cross over with adx increase 20.
Check this https://zerodha.com/expert-advisors/, if you still have queries you can post on tradingqna.com under algos.
Hello Nithin, thanks for sharing the link.
I am new to zerodha group… Is PI free tool for zerodha users and algo can be used on that tool.
If possible any link for training available
Thanks
9553511225
Hey Dhawal, Pi is free for use, yes. Check out our YouTube channel for demo of our platforms.
Hello sir,
Can you pls help to code my strategy.
I need 4,5 & 6th candle on time frame of 15 min. Mark the high low of these 3 candles. Whichever side break high or low my trade will execute. My target is difference between high-low of 4,5 & 6th candle. Same will be the SL.
Please help me to coding this.
Thanks
Best post this question here Kamal.
Can we scan multiple things (macd, moving average, star, evening star and etc) in a single code of scanner?
Rising 50 moving average+ lower Bollinger band + candlestick they both come at Same place to generate buy signal.
Sir,
I want to know code for the following strategy,,
Buy when open above first 10 min high
Sell when open below first 10 min low.
Thanks
I want to write my strategy but really have no clue where to start can you do it for me.
I would like to generate buy when a script deviate 2 to 2.5% below Vwap with double volume with stochastic crossover in overbought. Similarly oposite for Sell signal. Please please sir help me you also email me this code
I suggest you check out Streak. The platform allows you to create strategies without coding.
Dear Sir,
I need code for following condition please suggest how to write
Sell
1. Stock current LTP below 200 DMA
2. Macd cross down signal line but cross down should be above 0 line
Please code the following strategy:
BUY when Heikin-Ashi bar (5min or 15min or 1 day) crosses 20 day EMA and MACD gives buy signal
Can someone please help me out with a formula for Supertrend indicator? I want to create a tradescript strategy based on Supertrend, so a formula would help.
USE TREND CLOSE OR VOLUME
plesae suggest code on any 15 min candle trading range breakout trading and also provide list of intraday stock futures margin for mis orders
In watchlist can we add order by sorting on the basis of %. Up and down.. also can you provide filters in which you can filter company on basis of domain means.. agriculture, petroleum, medicine,finance easy to sort. It’s just suggestions from my side.