Code your Technical Analysis strategy

April 23, 2013

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.

India's largest broker trusted by 1.3+ crore investors.


Post a comment




1,292 comments
  1. Dhaval Kumar Solanki says:

    I want screener of those stocks of which price touches 200,50 Day EMA line & pattern finder also.

    Regards,
    Solanki Dhavalkumar K.

  2. Required instigator SSL HYBRID & QQE MOD says:

    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

  3. Ambrish Kumar Pandey says:

    Add SSL hybrid indicator in zerodha app. immediately.

  4. Joe Vishal says:

    i have the source code how to apply and automate the trade in Zerodha?

  5. Mahesh Hegde says:

    sir,

    I need to access “ssl hybrid indicator’ in zerodha. it is not shown in ChartIQ and as well as TradingView. pls help me

  6. Rupesh ogale says:

    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

  7. Kuwar says:

    on 5 min chart
    candle close price >vwap
    supertrend buy signal
    volume > 2x (20days SMA volume)
    rsi > 60
    OI < (20 days SMA OI)

  8. Gandham Rajesh says:

    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

    • Harsh Deepak Dalvi says:

      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

  9. sudarshan says:

    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.

  10. Kalyan says:

    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 😊

  11. Suriya says:

    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
    ..
    .
    .

  12. Deepak Nader says:

    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?

  13. Prafulla says:

    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.

  14. Fighter79 says:

    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,

  15. Ranganath Shirur says:

    Buy shares or option when the RSI goes above 60 and sell when the RSI downtrends..

  16. Rupali karle says:

    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

  17. Prakash Kranthi says:

    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

  18. ARJUN SINGH BISHT says:

    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)

  19. Maniyar says:

    example code in python when candle(close) crosses 20 SMA moving average

  20. Kumar says:

    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

  21. Khushbu says:

    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

  22. Khushbu says:

    Sir i want to sell over 70 , RSI 14, with TSL of past 3rd 15 min candle high… please guide

  23. Algo trading says:

    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.

  24. Hrishi says:

    i want a supertrend + macd + rsi

  25. bharat says:

    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

  26. Fidelis Mgbodim says:

    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.

  27. Divye says:

    I need the code for,

    Ehler Fisher (10) crosses Ehler Fisher Trigger (10), on a monthly time frame

  28. Pratik Uday says:

    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.

  29. Deepak Nigam says:

    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

  30. Jinesh Jain says:

    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

  31. prafulla bhople says:

    Dear Sir,
    I need Kligner Vol Oscillator script for zerodha backtest
    please help

    Prafulla Bhople

  32. Antony says:

    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…?

    • Matti says:

      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.

  33. SAURABH SHARMA says:

    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 .

  34. Namrata Tawade says:

    Can I use scanner for more than 1 line conditions?

  35. Sudhakara says:

    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

  36. Shikher Kanwar says:

    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

  37. Aaron says:

    Hi Anyone?
    How to code offset moving average?

  38. yaswanth says:

    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.

  39. BHAGYARAJ says:

    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?

  40. PRAMOD UPASANI says:

    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.

  41. shubham says:

    Could you provide code for hammer and inverted hammer candlestick?

  42. sulthan IS says:

    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

    • Zerodha Social says:

      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.

  43. Varun Joshi says:

    Hi! Sir, If i have to make strategy based on cande vidya crossover on Nifty can i make ?

  44. RAM says:

    how to transfer amount equity to commodity accounts

  45. rajveer says:

    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

  46. JAYESH PRAJAPATI says:

    i would like to backtest vwap in bank nifty for 15 min chart so pls code me in this testing

  47. MANISH says:

    how sell of 1% above the purchase value can be scripted please help me for this

  48. Hrishikesh PAtel says:

    Hi Team,

    I am looking forward to get the codes for McGinley Dynamic.

    Regards

    Hrishikesh

  49. Ketan Khopkar says:

    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

  50. sankar singh says:

    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.

  51. Pankaj says:

    Alert when 5 period EMA crosses 20 period EMA and Supertrend is on uptrend and vice a versa for sell order.

  52. Nishith says:

    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.

  53. Alok says:

    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

  54. Yash Joshi says:

    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

  55. Abdul says:

    Hi ,

    I need a coding with combination of supertrend and SMA. can some help me please?

  56. ananya says:

    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

  57. PRITISH HALDER says:

    Is it possible to give supertrend indicator with fields Open/High/Low/Close etc?

    • Raju says:

      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

  58. swapnil arvind kshirsagar says:

    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

  59. Paras Dutta says:

    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.

  60. hilesh says:

    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

  61. NARESH MEHTA says:

    Sir,

    i required donchian channel buy/sell code , buy msg show if crosses above 20 channels & sell if crosses below channel , will help please..

  62. Kamal Bhola says:

    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

  63. SATRUGHAN says:

    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.

  64. omkar katkar says:

    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.

  65. srikanta says:

    How PI scanner generate alert…only color highlighting?
    or SOUND/ MAIL/ SMS ?

  66. Maddy says:

    Hi, did you stop Pi Backtesting facility??
    It’s continuously giving error.

    Is it like, now backtesting should be done only on streak??

  67. Anit says:

    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

  68. praveens says:

    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

  69. Varun Ramesh Gidh says:

    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.

  70. Prakhar says:

    I want to get alerted whenever volume becomes twice the simple average volume of last 50 candles.

  71. Ganesh says:

    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

  72. SHAKTI KUMAR JINDAL says:

    HI
    HOW TO BACKTEST IN PI USING SUPER TREND STRATEGY?

  73. Latha George says:

    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

  74. Rajat says:

    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.

  75. Sakthi says:

    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.

  76. PRAVEEN VERMA says:

    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

  77. Amit Bakshi says:

    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.

  78. Nazir Hussain says:

    I want the Opening Range Breakout ( 15 minutes) Expert Advisor ,so kindly help in this.

  79. zv0721 says:

    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

  80. Prashant Jain says:

    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

  81. Harshal Desai says:

    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?

  82. krishna says:

    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 )

  83. Jeeva says:

    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

  84. Mehul Faldu says:

    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

  85. Jitendra Rathore says:

    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 🙂

  86. abcd says:

    what if i want first 15 minute high and first 15 minute low ?? I would want a pi code for the same.please help

  87. Abu says:

    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

  88. Chengappa says:

    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)

  89. Kalpesh says:

    Hi,

    want code for Pi:

    Buy: when SuperTrend + Heiken ashi = both are bullish (green)
    Sell: when SupreTrend + HeiKen ashi = both are bearish (red)

  90. Vettanu Pawar says:

    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.

  91. venkat nagam says:

    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’)

  92. yashpal says:

    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

  93. SANDEEP says:

    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?

  94. YASH says:

    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

    • Zerodha Social says:

      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!

  95. Sathish says:

    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 .

  96. RAMESH says:

    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)?

    • Matti says:

      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.

  97. fisherman8 says:

    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.

  98. VIVEK DV4166 says:

    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

  99. GANGARAJU says:

    todays open greater than yesterdays high
    todays open lesser than yesterdays low.
    please code this for scanning the stocks @9.20 am

  100. Niteen says:

    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

  101. saurabh says:

    Do u have Gannhilo Studies indicator in zerodha

  102. DIVYESH says:

    Hi,
    Can u pls give me a AFL code for ZERODHA ATR TRAILING STOP.

  103. Ramalingam S says:

    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.

  104. Devendra Verma says:

    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

  105. mahadev valekar says:

    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

  106. Ankur Gupta says:

    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.

  107. Anuraag Kochhar says:

    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.

      • Anuraag Kochhar says:

        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.

          • Anuraag Kochhar says:

            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?

  108. Abdulla PM says:

    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

  109. Manish says:

    Hello sir,
    Is there super trend scanner available in zerodha pi.

    • Akshay.A says:

      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

  110. ZO2577 says:

    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??

    • Akshay.A says:

      Hi The below link should help you saving a scanner.
      check this

      • ZO2577 says:

        Dear Akshay,
        I already followed all the steps given in the link. Unfortunately, it didn’t help.

    • ZO2577 says:

      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.

  111. H. R. Shah says:

    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

  112. Ranjeet Kumar says:

    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

  113. Stalin Kant says:

    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

  114. aljo says:

    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

  115. ravindrakumar says:

    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.

  116. Sahaj Pal Singh says:

    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

  117. jkakbari says:

    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.

  118. Piyush Agarwal says:

    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.

  119. sanjay says:

    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?

  120. Sudheer says:

    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

  121. Ganesh Keer says:

    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

  122. Tanveer says:

    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

  123. manoj kumar pingolia says:

    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

  124. manoj kumar pingolia says:

    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

  125. rakbot says:

    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

  126. NILESH says:

    Hii ,
    i want buy and sell codes for supertrend crossover for 15 min and 5 min charts , parameters – default (7,3)

  127. VIRAL says:

    Hi

    Need code for

    Buy : When 15 SMA Crosses Above 50 SMA.
    Sell : When 50 SMA Crosses Below 15 SMA.

  128. Puneet says:

    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.

  129. Vishwa says:

    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.

  130. Sandeep Uttam says:

    sir
    piz help mi STR buy&sell coode

  131. MITHILESH SINHA says:

    Can you please insert ZIg in Pi-terminal as you are having many indicators in built.This will help a lot.
    with thanks
    Mksinha

  132. Kinjan Shah says:

    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

  133. Rajendra Damor says:

    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);
    //////////////////////////////////////

  134. RAJU says:

    Dear Sir,

    i need a trade script for super trend . kindly help

  135. Siddhartha says:

    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

  136. chandrajeet says:

    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

  137. Anshuman sharma says:

    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

      • Anshuman sharma says:

        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

  138. Tej says:

    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.

  139. YASHPAL says:

    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

  140. siva says:

    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

  141. Hi,

    Can you please help me for expert adviser script for super trend.

  142. nitin jose says:

    Code for stock goes above R3

  143. jaideep says:

    my strategy …..
    will buy if price is greater than 20 ema?
    please code this

  144. Nilesh says:

    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

  145. Akash says:

    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

  146. DINESH says:

    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.

  147. Pawan Kumar Singh says:

    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

  148. Harshit Chauhan says:

    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)

  149. Shankar Shanmugam says:

    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.

  150. Ravi Kumar says:

    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

  151. DT0850 says:

    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?

  152. S RAJASHEKAR says:

    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

  153. Kuldeep Mishra says:

    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.

  154. Sheersh Jain says:

    may i know the code forbuy and sell using supertrend indicator to be used in Expert Advice .

  155. Anshuman sharma says:

    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.

  156. Nayan says:

    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

  157. Tejas desai says:

    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.

  158. Nimesh says:

    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)

  159. Shailendra says:

    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….

  160. Shrinivas Kamath says:

    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.

  161. Bharat says:

    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 .

  162. Bharath says:

    Hi Nithin,

    How to set Fibonacci setting in Pi.

    Thanks,
    Bharath

  163. Himakar Reddy says:

    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.

  164. Parshuram Desai says:

    What is the script to find Average True Range? Like I want to write a script to find ATR for 100 candles.

  165. NSikder says:

    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

  166. bipin gautam says:

    sir what would be the code for 14 d rsi + 5 day sma for both going long and short.

  167. Sunil Patel says:

    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….

  168. zk120121 says:

    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

  169. sushil261 says:

    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.

  170. Rinku Rathod says:

    Dear Sir,
    I want to make custom indicator for my PI, so is that possible???

  171. ushrikant says:

    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

  172. Harisha M G says:

    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

  173. shoban babu m says:

    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.

  174. thulasee says:

    Hi,

    How to code the below strategy:

    Buy and Sell: based on the crossover of ‘Ehlers Fisher transform indicator’?

    Please advise.

    Regards,
    Thulasee

  175. marshal says:

    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.

  176. shirish_78 says:

    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

  177. 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.

    • Venu says:

      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.

  178. pawan kumar singh says:

    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

  179. 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!

  180. RAJESH J says:

    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

  181. PR0854 says:

    Sir
    How to get mobile trading app login and pwd

  182. PR0854 says:

    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

  183. rahul kumar says:

    to sir mai kaise janunga ki kaunsa signal true hai jaise backtest me show karta hai

  184. rahul kumar says:

    trend buster

    CROSSOVER(CLOSE,REF(HHV(30),1))

    CROSSOVER(REF(LLV(30),1),CLOSE)

    plz tell me what is wronge with me

  185. rahul kumar says:

    see

  186. rahul kumar says:

    in pi backtest result and live result are different in same timeframe. what should i do?

    • Venu says:

      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.

  187. DN0680 says:

    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?

  188. Amin says:

    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?

  189. gaurav says:

    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

  190. jawaharraj says:

    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

  191. DV0367 says:

    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

  192. ashirwadmittal says:

    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!

  193. da5903 says:

    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

  194. manish lambat says:

    can i get the coding done for generating buying signal when 20 days ema crosing 20 days sma ?

  195. […] 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 … […]

  196. sreespg says:

    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?

  197. msreddy says:

    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.

  198. Prashant Mali says:

    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.

  199. HARI RAO says:

    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

  200. Abhishek Mishra says:

    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.

  201. chintamani says:

    CAN WE CODE MULTITIMEFRAME STRATEGIES IN pi.
    Simple :
    1 hour chart c>sma 200
    and
    5 minute chart c<sma200

    Please inform.Thanks.

  202. chirjeev singh arneja says:

    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.

  203. KANWAL says:

    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.

  204. Rabi says:

    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

  205. shivasrinivas says:

    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

  206. Madhujeet says:

    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)

  207. GANESH says:

    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

  208. Nikhil Zelawat says:

    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)

  209. K.Narayana says:

    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

  210. K.Narayana says:

    Sir
    Thank you for your reply, and

    I need code for automatic buy and sell signals for above EMA cross overs

  211. K.Narayana says:

    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.

  212. subhash says:

    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

  213. shailendra says:

    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.

  214. Mukul says:

    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.

  215. Guru says:

    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)

  216. trader-001 says:

    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.

  217. trader-001 says:

    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.

  218. renjithppaul says:

    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

  219. Amit says:

    what is best stratergy for trading nifty future 1 hour time period

  220. Bose says:

    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.

    • Bose says:

      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.

  221. Bose says:

    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.

  222. Bose says:

    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. 😀

    • Bose says:

      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.

  223. bose says:

    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);
    }

  224. Rahul Shah says:

    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.

  225. CT says:

    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.

  226. manoj says:

    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.

  227. […] 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… […]

  228. Pallavi Deoghare says:

    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

  229. kapil says:

    how to view bid/ask lines in ami broker charts or pi charts not the ltp line

  230. AshishM says:

    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.

      • AshishM says:

        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.

          • AshishM says:

            Noted. Did not understand the technicals but got the logic of your explanation. If possible, pl do inform.
            Thanks

  231. Deepak P says:

    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.

  232. prakash says:

    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

  233. prakash says:

    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!

  234. VNS Kodukula says:

    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,

  235. Karunaithi Thangavel says:

    Hi Nithin,

    I need some sample code for Bank Nifty (Future)

  236. Ravi says:

    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

  237. saravanan says:

    Hi Nitin sir
    How to Create Expert Advisor

  238. Ravi says:

    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

  239. Ravi says:

    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.

  240. Muthu Shunmugam says:

    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

  241. Nitesh sharma says:

    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

  242. DS4666 says:

    what is the code for single candle divergence?

  243. […] programming language used on pi is called tradescript, and this post has around 300+ queries answered and the manual, should help you get […]

  244. jitendra says:

    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.

  245. Prakash says:

    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.

  246. Shantanu1981 says:

    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.

    • Andrewman says:

      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

  247. Ramkrishna says:

    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?

  248. chetan says:

    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

  249. Nitesh sharma says:

    Hi Nithin

    Can i backtest few strategies on the current trading platform

  250. […] 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… […]

  251. radhey says:

    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.

  252. radhey says:

    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..

  253. radhey says:

    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

  254. radhey says:

    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

  255. Harcharan Singh says:

    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)]

    • Hanan says:

      We’ve just gotten word from our strategy coders and they’ve said that unfortunately this cannot be coded on algoZ.

      • Anshuman Sharma says:

        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

  256. tvsreelatha says:

    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

    • Hanan says:

      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.

  257. Saurabbh says:

    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.

  258. D.omprakash says:

    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….

  259. saranya says:

    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.

  260. sujay1803 says:

    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

  261. Prabhakar says:

    Is it possible to code strategy based on Heiken Ashi calculations, HAOpen, HAHigh, HALow and HAClose and their moving average?

  262. tirumal says:

    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

  263. praviny says:

    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.

  264. SiddharthG says:

    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

  265. 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.

  266. agsuresh says:

    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.

  267. agsuresh says:

    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

  268. Guilherme says:

    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

  269. Satya Dani says:

    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

  270. santoshpadhy says:

    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.

  271. santoshpadhy says:

    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.

  272. santoshpadhy says:

    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

  273. Ashish says:

    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.

  274. currencyandnifty.com says:

    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………..

  275. currencyandnifty.com says:

    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.

  276. RAJESH J says:

    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

  277. RAJESH J says:

    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

  278. Satya Dani says:

    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.

      • Satya Dani says:

        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.

        • Satya Dani says:

          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??

      • Satya Dani says:

        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.

  279. APM says:

    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

  280. J.R.Julius says:

    @Nitin Ji,
    Thank You.

  281. J.R.Julius says:

    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

  282. Aquif says:

    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.

  283. Aquif says:

    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?

  284. J.R.Julius says:

    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.

  285. J.R.Julius says:

    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

  286. mani says:

    Dear Sir can U Suggest Low Whipsaw Positional Stragedy?

  287. RAJESH J says:

    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:

  288. Deepak says:

    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

  289. DM0121 says:

    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)))

  290. m.rajendra says:

    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)

    • m.rajendra says:

      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

  291. Guilherme says:

    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?

      • Guilherme says:

        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.

        • Guilherme says:

          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.

  292. tvsreelatha says:

    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)

  293. Devendra says:

    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)))

  294. Kamlesh B. Lokhande says:

    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.

  295. GOPI says:

    i have idea
    in zerodha ADX IN 15 MIN AND AVERAGE PERIOD IS 1 THEN HOW TO PLACE BUY NAD SELL IN ALGOZ

  296. m.rajendra says:

    Can someone please share successfull back tested strategies for Equity day trading?

  297. m.rajendra says:

    ok thanks Nithin

  298. m.rajendra says:

    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

      • buchi says:

        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.

  299. Sibi Chakravarthy says:

    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?

  300. radhey says:

    if specific candle pattern is not possible right now , pls code rest of strategy of mine…………ma crossover + stch+ rsi+ camrilla

  301. radhey says:

    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.

  302. m.rajendra says:

    Nithin,

    Error message is “BackTest Script Error:Error:Scripts generated no trades” and it occurs when I backtested.

  303. m.rajendra says:

    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

  304. newbie says:

    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?

    • newbie says:

      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

  305. praneet says:

    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?

  306. Manas says:

    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

  307. rohits8829 says:

    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.

  308. Pradip says:

    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.

      • NIr says:

        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.

  309. sruthi says:

    hi sir,
    how to fully automate my trades and what are the required approvals ?

  310. ksjoseph says:

    Hello Nithin,

    Would like to know how to set up the Greek Market Watch settings in Nest Trader?

    • Hanan says:

      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.

  311. nath says:

    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.

  312. nath says:

    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?

  313. Guilherme says:

    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.

  314. Charles says:

    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

  315. ksjoseph says:

    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.

  316. sohil says:

    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

  317. sohil says:

    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

  318. 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.

  319. chintamani says:

    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

  320. rajesh says:

    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

  321. Saeed Rahman says:

    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.

  322. Shiva Kumar says:

    hi nitin

    could you program my strategy

    Buy=EMA(C,13)>EMA(EMA(C,13),9) AND Cross (C,Peak(C,2,1));

  323. Ramickey says:

    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?

      • Ramickey says:

        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

  324. Ramickey says:

    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

  325. Ramickey says:

    Can we use algoZ for trading NF in Bracket order?

  326. radhey says:

    I m desirous to code my strategy……how to do that pls help

  327. David says:

    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.

  328. chirag007 says:

    can you publish function signature of all the indicators available in algoz?

  329. David says:

    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).

  330. kars says:

    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.

    • kars says:

      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

    • kars says:

      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.

      • subhojit says:

        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.

  331. ksjoseph says:

    Thank You Nithin will do so.

  332. ksjoseph says:

    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

  333. Rohit says:

    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.

  334. ksjoseph says:

    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.

  335. Akshay says:

    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.

  336. akshay says:

    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

  337. Varun says:

    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 ???

  338. milind2754 says:

    displaced moving average indicator is there in nesttrader ?

  339. milind2754 says:

    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 ?

  340. milind2754 says:

    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 ?

  341. varunsingh1234 says:

    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 ???

  342. Akshay says:

    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))

  343. Soumyajit says:

    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.

  344. velappan periasamy says:

    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

  345. 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))

  346. Arti Mittal says:

    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.

  347. Ravikumar says:

    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.

  348. ksjoseph says:

    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.

  349. currencyandnifty.com says:

    when will you launch your new platform for trading,?

  350. sharan says:

    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.

  351. kam.tngr says:

    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,

  352. Chandranath Jain says:

    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

  353. amitagsk says:

    hi
    can we use supertrend indicator !

  354. niftytrader says:

    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

  355. amthangamani says:

    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

  356. sharan says:

    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.

      • sharan says:

        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.?

  357. Aditya says:

    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.

      • Aditya says:

        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 🙂

  358. ksjoseph says:

    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

      • Mak_T says:

        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

  359. Devis says:

    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

  360. devis says:

    _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();

  361. ksjoseph says:

    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)

  362. SAMEER KUTTI says:

    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

  363. PRADEEP says:

    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

  364. SAMEER KUTTI says:

    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

  365. vishal says:

    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

    • Hanan says:

      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.

  366. vishal says:

    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

  367. SAMEER KUTTI says:

    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

  368. SAMEER KUTTI says:

    THANX NITIN JI

  369. SAMEER KUTTI says:

    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

      • Piyush says:

        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.

  370. SAMEER KUTTI says:

    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.

  371. Govindaraju Y says:

    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)

    • Hanan says:

      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.

  372. Dinesh says:

    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,

    • Hanan says:

      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.

  373. Dharam says:

    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..

  374. chethan icc says:

    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.

    • chethan icc says:

      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.

  375. Mareeswaran6 says:

    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.

  376. DM0969 says:

    Hi Team,

    Can you please help with the

    Buy Expression for:
    When the stock closes above its 3 month high candle

    Thanks,
    Mahesh

    • DM0969 says:

      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

  377. drmdave says:

    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.

    • Hanan says:

      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.

  378. Mareeswaran6 says:

    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.

    • Mareeswaran6 says:

      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

      • Mareeswaran6 says:

        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

  379. mohmed says:

    please give me code for this…
    Buy : prime number oscillator 7

    i tried following but its not working
    Buy : PNO(CLOSE)7

    • Hanan says:

      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.

  380. Dinesh says:

    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);
    }

    • Hanan says:

      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.

      • Dinesh says:

        Hi Hanan, I am just trying to use the camarilla statergy 🙂 Hope you understand now.

        • Hanan says:

          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.

          • Dinesh says:

            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,

  381. sonaimana says:

    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..

    • Hanan says:

      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.

  382. sonaimana says:

    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 w