Basics Manual

April 23, 2013

Basics

Following are the indicators that you can use in algoZ to not just study and analyze price data, but also act on them:

  • Accumulative Swing Index
  • Aroon
  • Aroon Oscillator
  • Bollinger Bands
  • Chaikin Money Flow
  • Chaikin Volatility
  • Chande Momentum Oscillator
  • Commodity Channel Index
  • Comparative RSI
  • Detrended Price Oscillator
  • Directional Movement System
  • Ease of Movement
  • Exponential Moving Average
  • Fractal Chaos Bands
  • Fractal Chaos Oscillator
  • High Minus Low
  • High/ Low Bands
  • Historical Volatility
  • Linear Regression Forecast
  • Linear Regression Intercept
  • Linear Regression R-Squared
  • Linear Regression Slope
  • MACD
  • MACD Histogram
  • Mass Index
  • Median Price
  • Momentum Oscillator
  • Money Flow Index
  • Moving Average Envelope
  • Negative Volume Index
  • On Balance Volume
  • Parabolic SAR
  • Performance Index
  • Positive Volume Index
  • Price Oscillator
  • Price ROC
  • Price Volume Trend
  • Prime Number Bands
  • Prime Number Oscillator
  • Rainbow Oscillator
  • Relative Strength Index
  • Simple Moving Average
  • Standard Deviation
  • Stochastic Momentum Index
  • Stochastic Oscillator
  • Swing Index
  • Time Series Moving Average
  • Trade Volume Index
  • Triangular Moving Average
  • TRIX
  • True Range
  • Typical Price
  • Ultimate Oscillator
  • Variable Moving Average
  • Vertical Horizontal Filter
  • VIDYA Moving Average
  • Volume Oscillator
  • Volume ROC
  • Weighted Close
  • Weighted Moving Average
  • Welles Wilder Smoothing
  • Williams %R
  • Williams Accumulation Distribution

Write your own Strategy (Scripts)

Using algoZ, you can create your own strategies using technical indicators discussed above, for buying/selling an instrument. To write your own strategy, Right-click on any chart →  Select “Scripts” → Select  “Add New Script.

The algoZ screen inside the NEST terminal

 

A strategy can be written with four expressions:

  1. Buy Script Expression – to define when a long (buy) position should be taken for a scrip.
  2. Sell Script Expression – to define when a short (sell) position should be taken for a scrip.
  3. Buy Exit Script Expression – to define when to exit a long (buy) position by selling that position.
  4. Sell Exit Script Expression – to define when to exit a short (sell) position by buying that position.

Writing and editing strategy expressions

 

This can be done either by entering the strategy using the edit boxes provided or by using the “Make Expression” function.

Creating expressions with built in vectors and functions

 

Select the required parameters for Vector/Period/Indicator and click on “Update LHS” to update the left-hand side of the final equation. Select a math function and the desired parameters to complete the expression by clicking on Update RHS.

In case you do not wish to set a condition for all expressions, you would have to type in 0 in the edit boxes for those expressions. Only the expression for which you set any condition would generate orders, provided that condition is met. Save your template by entering any name in the Saved Templates option and click on Save. You’re now ready to backtest, go live or edit your strategy.

Back-testing

Back-testing helps you to analyze his strategy and test it out by applying it on historical data before going live with it. If you are not satisfied with the outcome as indicated by the backtest for a particular strategy, you can modify the expression for that strategy and backtest it again until the results appear satisfactory.

To back-test a strategy, right-clickon the chart, click on Scripts, select the script name that you want to back-test and click on Backtest.

Backtesting a strategy

 

It will indicate buy/ sell signals generated (if any) for that script in the chart window. An upward green arrow indicates a Buy signal, while a downward red arrow indicates a Sell signal.

Backtesting results visualized

 

The user can also view comprehensive details of the Back Test, by right-clicking on the Intraday Chart and selecting ‘Back Test Details’. The Back Test Details window, as illustrated below, provides details with respect to the outcome of the strategy entered, evaluated on historical data. Corresponding to the user’s parameters getting triggered the action is taken and profit/ loss calculated, which the user can use as a reference to check whether the back-test was successful, or he would like to use a different methodology.

Backtest analysis results

 

The Backtest Analysis Info section provides details such as the Total number of trades, number of profitable and loss-making trades, largest profit/ loss, net profit/ loss and so on to better help in analysing the applicability of a strategy.

Going Live with your Strategy (Live Script)

“Going live with your strategy” means that whenever your condition as set in the Buy, Sell, Buy Exit, Sell Exit expressions is met, corresponding orders will start getting placed in the Live Market.

In case you’re using algoZ with an Investor Client login, you will be prompted to confirm the order, every time a condition is triggered. Unless you confirm the order to get placed, it will not.

In case you’re using ZT Dealer with a Dealer login, you have the option to select whether the orders are to be placed automatically, or you should be prompted to confirm the order before placing. This is explained further below.

To take your strategy to the live market, right-click on the chart, click on Scripts, select the scrip which you want to go live with, and click on Live.

Taking a Strategy Live

 

You then need to fill in your order details and set order preferences.

Setting Alert Preferences

 

Execution Period can be set to define the Start Time and End Time during which the orders should get placed. Product Type would help to select the product type that has been enabled, similar to placing of normal buy/ sell orders (F1/ F2).

‘Begin With’ field has three options: Any, Buy and Sell. If ‘Any’ is selected, the algo will simply place a buy or sell order, depending on whichever condition gets satisfied first. If ‘Buy’ is selected, the first order that the algo places will by a buy order. That means even if the sell condition gets satisfied, the system will not generate an order until the buy condition gets satisfied. The reverse is for sell.

Product Type field is the same as the normal buy/ sell order entry window. You can select MIS for Intraday or NRML for carry-forward positions in Derivatives or CNC for Delivery-based trades in Equity (in this case, care should be taken to avoid short sell).

Set Interval tells the system at what chart interval the strategy should be evaluated and orders placed. This is configurable, with a base interval of 1 minute.

You need to define the quantity to be placed per opportunity that is whenever a condition is met.

Order Type can be set as Limit/ Market/ Stop Loss as per preference. In case of selecting a Limit order, you can decide a pre-defined limit or let the limit price be determined based on the signal price, which is when the buy/ sell signal was given.

For placing limit orders based on signal price, tick on the check-box  “Place from Signal Price”. Select whether the price should be picked as the ‘Close’, ‘Open’, ‘High’ or ‘Low’ for the interval during which signal was given by selecting the option from the ‘Pick’ drop-down option.

You can also provide an offset that needs to be added to (in case of buy orders) or subtracted from (in case of sell orders) the signal price.

Evaluate as tick is used in conjunction with Set Interval. If the check box for evaluate as tick is checked, the strategy will be evaluated at every tick with the calculation based on the interval entered in Set Interval field. In effect, evaluate as tick tells the system to place orders, even in between the candle based on the strategy, instead of at the close of the candle.

Stop Loss Order trigger price allows the user to enter a trigger percentage for a stop loss order to be sent with the Buy or Sell orders generated by the strategy. This works similar to a cover order.

The dealer can also place orders for the strategy, with the same parameters, for multiple accounts mapped to him. In case of trading for multiple accounts, you can save an account list, by clicking on ‘Save’ and Load this list anytime while going live with any strategy.

Once you click on ‘Submit’, signals will be generated with an alert to act on them whenever the condition specified in the Script is met with.

Controlling a Live Script

You can view details for all scripts that you have gone live with, by clicking on Pulse Running Scripts under the Nest Plus menu. Alternatively, you can right-click on the chart and select ‘Show Running Scripts’. All the scripts that are in ‘Live’ mode will appear as illustrated below:

Viewing the scripts you’ve gone live with your strategy

 

From this window, you can pause/ resume a script, place manual buy/ sell/ square off orders, view reports for all orders placed along with total number of trades, largest profit/ loss, net profit/ loss and so on.

To stop a script, right-click on the ‘Running Scripts’ window, and click on ‘Maximized Mode’ to exit maximized mode. You will be able to view an option to stop the strategy. Click on it to pause an active script, and to resume a paused script.

Stopping a live sript

 

You can also place orders manually overriding the script, by clicking on the Buy or Sell options provided next to the Stop option. In case, you click on Buy, it will get replaced by the Exit option. Similarly, if you click on Sell, it will get replaced by the Exit option to exit any positions taken manually.

Placing orders manually

 

To view details of action taken, right-click on the Running Scripts window and click on ‘Open Report’.

Viewing action report

 

All orders placed in this manner will be visible in the Order Book (F3 window).

Viewing orders in the orderbook

 

You can distinguish orders placed through algoZ from other orders from the ‘Remarks’ column in the Order Book. All Order Book features such as modification, cancellation, order history and so on are applicable to orders placed through algoZ as well.

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


Post a comment




93 comments
  1. Hirak Gupta says:

    Hi Nitin,

    I have developed some custom indicators , Which i already scripted at Tradingview.
    I want to transfer them here and backtest.

    Though the code is in Tradingview I have the base code In the form of C# as well. I can convert it to python

    i have a set of Questions. If you guys can answer me it will be great for me to move forward

    My indicators and trading strategy compares a Higher and a lower timeframe data and executes the buy and sell
    Here from the discussion i understand that a script or piece of code operates in one timeframe only. i do i work around that ?

    In tradingview, That part is manual . I open two windows and run the same chart/script in two timeframes .
    When the higher timeframe gives a message for buy and sell then i wait for message from the smaller timeframe chart. And if i get the message I execute the trade.

    If i have to convert the whole thing to Zerodha then would i have to do the same way ?

    Please let me know

    Thanks,
    Hirak

  2. I kasireddy says:

    Hi
    Can you please help me to write code for the following
    5 ema indicator
    30 minutes candlestick
    Condition- 30 minute candle low should not touch 5 ema, then if next candle crosses low of that candle, sell it
    Stop loss above that crossed candle.
    Target 1:1.2

    For buying opposite conditions

  3. Saugat C says:

    Hi Nitin Can you please help me to write the below-mentioned script
    1. 50 EMA bounce long with confirmation candle ( Buy Signal)
    2. 50 EMA bounce short with confirmation candle ( Sell signal)
    This pattern is used by adam Khoo, I tried to replicate the algorithm but am seriously not able to generate an error-free script. I need your help in this Please

  4. Shivam Dussawar says:

    When slope of MACD Fast Line is equal to zero.

  5. Shivam Dussawar says:

    when colour of MACD HISTOGRAM changes from green to red and vise-versa.

  6. dipak rathod says:

    I want to code ADX DMS in Pi.
    I want to code crossover of DMS DI+ and DMS DI-

  7. Nishchit Jain says:

    Hello, can you please help me with the code for below condition:

    * Buy Signal: If the stock price in TF 15 mins crosses above EMA (HIGH,5) along with Williams %age crosses above -30
    * Sell Signal: If the stock price in TF 15 mins crosses below EMA (LOW,5) along with Williams %age crosses below -70

    Thanks,
    Nish J

    • Matti says:

      Best post this here. A fellow forum member may be able to help.

      • Nishchit Jain says:

        Nobody there to help…Anyone from Zerodha?

      • Nishchit Jain says:

        Hello, can you please help me with the code for below condition:

        * Buy Signal: If the stock price in TF 15 mins crosses above EMA (HIGH,5) along with Williams %R (27) crosses above -30
        * Sell Signal: If the stock price in TF 15 mins crosses below EMA (LOW,5) along with Williams %R (27) crosses below -70

  8. Gautam kacha says:

    Whether coding is possible for point and figure chart

  9. Jagadish Gowda says:

    Hi,
    I want a script for open=low and open=high.

  10. Bhushan says:

    i want to set set variable say ‘CLOSE_PRICES’ with close prices of every minute. How can I do that??

  11. Amiya Adhikary says:

    Help me to find my exit strategy in Zerodha Pi. For buy entry, Exit Order shall be triggered when price falls below the previous two candle’s low. And for sell entry stop loss shall be triggered when price cross above previous two candle’s high.

  12. Jaiganesh says:

    Hi,
    I am using Zeordha – Pi, I need a script for below mentioned point.

    1) How to identify the MACD histogram high and low for the previous range.

  13. Siva says:

    Hai,
    Please bear with my Post. I am new in trading . I wish to know the algo trading techniques.i have zeroda account.

    1. How can I get this software.
    2. How can I trade with the help of algo techniques software.

    Regards,
    Siva.

  14. MANGESH says:

    Sir

    I am using Zerodha Pi

    I want Screener code which follows following conditions

    I want to apply this screener to Nifty Stocks

    Conditions are

    1 Stock CMP ( Current Market Price ) is above last week high

    AND

    2 Stock CMP is below last week low.

    Can we apply above conditions to be satisfied and result is to be displayed.

    i also post in Trading Q&A five day before no one can replay

    Please help
    Mangesh

  15. Vijay says:

    Before scanning the above criteria mentioned it should check if %K line has crossed %D line below minus 40. When this criteria matches and when the %K line is above plus 30 on a 10 minute chart it should signal a BUY.

  16. Vijay says:

    Hi,
    I need a script on stochastic momentum index that is when %K value crosses 30 on a 10 minute chart.

    Thanks

  17. Dipak says:

    I want to write code for stock trading value( price*traded qty) on 5 min or 30 min chart in Pi.
    trading value>50000000
    stock price*traded qty> 5 crore
    suggest code for this

    • Ah, you can’t code this.

      • Dipak says:

        ok & thank you for quick reply…..
        then please provide me another code that crossover of fast Stochastic and slow Stochastic on 30 min chart as well as on 5 min chart.
        buy=fast stoc> slow stoc
        sell=slow stoc>fast stoc

        • algogeek says:

          For the above given requirement

          Buy

          SOPK(9, 3, 9, SIMPLE) > SOPD(9, 3, 9, SIMPLE)

          Sell

          SOPK(9, 3, 9, SIMPLE) < SOPD(9, 3, 9, SIMPLE)

          • Dipak says:

            thank you…
            you are right but I was to mention about another indicator called Stochastic Momentum Index or SMI.
            please provide code for this.

  18. kamlesh soni says:

    not able to edit value in awesome oscillator in kite
    and
    please add awesome oscillator in PI

  19. MARTIN says:

    Sir,

    I am unable to edit the trend or horizontal vertical lines for their values. I am unable to find a solution. Kindly help me out

    • siva says:

      Make sure the version you are using is latest by selecting About Zerodha Pi under Help menu, it should be dated 18/11/2016, If not uninstall this version and install again from back office Q.
      One can double click on any drawing to edit it, if still facing any issue one can write to [email protected].

  20. Amitabh Bhasi says:

    Sir, Can you help me code the following strategy;
    Buy: close > ema 50 and close crosses above ema 5.
    sell: close <ema 50 and close crosses below ema5.

    Thanks

  21. Raam says:

    I haven’t used Z-Connect yet. I’m going to open an account soon. I’m interested in this Algorithmic trading product. I want to know what are the metrics available?

    To be precise, can the following metrics be used in devising our own strategies?

    1) Previous Close
    2) Days’ Open Price
    3) Day High
    4) Day Low
    5) Last traded price
    6) Total traded volume
    7) Offer/Bid Price/Qty

    … Moving weekly / monthly average …

    What more? Can you give a comprehensive list?

    Is there any online documentation for the scripting language/format that you use?

  22. vikas says:

    Hi Sir,
    Is it possible to scan / identify a list of scrips that have a positive or negative EMA slope for x period candle bars on a 1 minute
    chart?

  23. nanda says:

    Dear Sir/Madam,
    I would like to code break-out strategy based on Fractal Chaos Band.

    Please help to me to code the following rules for back test in PI
    1) When high of the candle touches upper band then buy on next Candle if it crosses previous high & Sell exit if there is open sell order
    2) When low of the candle touches lower band then sell on next Candle if it crosses previous low & Buy exit if there is open buy order

  24. Nilesh says:

    Hello Nithin, How can I as a user be sure about user confidentiality? How can I rest assured that my winning strategies when executed on your platform will not be sold by Zerodha to any of Hedge Funds etc for monetary compensation?

    Also kindly provide contractural details in your customer on-boarding form which mention the customer confidentiality

  25. ajay says:

    Hi Sir ,
    I just want to know that currently the back testing of strategy is available for only past 60 days data? and if not, then , what i should do if i want to back test my strategy for more than 60 days , and also i want to see the back test result on charts also.

  26. Nurith says:

    Hi Nithin

    Is it possible to apply a coustomised Indicator.

  27. Sandeep says:

    Hi, I don’t see the option to add or back test strategies when I right click on a chart. I am using the new version of ZT. Attaching screen shot of the same. Pls advise.

  28. Thankachan Y Josemon says:

    Dear Sir

    Plz make a stategy for algoz

    my stategy is

    Exponential MA (3,13,39)
    ADX

    For long

    If EMA39 is Trending UP, EMA (3 &13) crossing up to the EMA 39 and adx above 22 buy signal
    IF EMA (3& 13) crossing down Exit

    For Short

    If EMA39 is trend Down, EMA (3 &13) crossing down the EMA 39 and adx above 22 Sell signal
    IF EMA (3& 13) crossing up Exit

    Sir , Iam waiting for your reply

    Thankachan Y Josemon

  29. S K Kataria says:

    I have been trading on zerodha for two years on my android mobile phone on NOW

    I also have IPad Air which I. Intend to use for trading

    I come across platforms such as Ztrader/NestPlus and Pi

    Can you suggest differences in their features and their adaptability to iPad and android smartphone

    • Pi is our new in house trading platform, but this is a desktop version and we still don’t have a mobile for this. But if you use PI/ZT for desktop, we have mobile apps for both IOS and Android. If you send an email to [email protected], they will migrate you from NOW to ZT/Pi.

  30. J.R.Julius says:

    BUY Rule : Highest Price of Last 20 Candles
    SELL Rule : Lowest Price of Last 20 Candles
    Buy Exit : Lowest Price of Last 10 Candles
    Sell Exit : Highest Price of Last 10 candles

  31. J.R.Julius says:

    Sir, Can i get donchian Channel/Turtle trading codes to back test in 30mins/1hr chart?

  32. Dhawal says:

    Hello Sir,
    As it is mentioned above that,
    “You can also provide an offset that needs to be added to (in case of buy orders) or subtracted from (in case of sell orders) the signal price.”]

    This offset works for “buy” and “sell” ,but this offset doesnt work for “buy exit” and “sell exit”.
    Is their any solution for this???

    • Dhawal,

      Wait for a few more weeks, we are launching our new platform with advanced features, and we can customize a lot of features on that for you.

      • Dhawal says:

        Also I want to ask is it possible to place Cover order in AlgoZ???
        I have tried placing Cover order, but it gives error.
        If not then, will it be possible to place cover order in the new platform with you are going to launch???

  33. Sukesh says:

    Hello,

    My friend and I both trade together on the same account, basically we manage the same strategy and trades together, when I am busy he works on it and when he is busy i do it. Totally we manage to monitor our trades throughout the day.

    Issue is that he logs in from his home and i have to log in from my home to the same account at the same time which gives an error message now if one person has already logged in. Is there a way we both can login to the same account at the same time?

    Thanks

  34. Lijoo says:

    Hello Sir,

    I had some problem with my Chart and Strategy back testing etc. I have called your office and the person attended (one Mr. Sunil ) has made it working very well. Thanks for the support. Keep it up. Lijoo

  35. Nikhil says:

    Hi,

    Can you tell me how can I add several positions to one strategy, instead of doing that individually. It is very time consuming to do one by one.

  36. Chandan says:

    Sir ,
    I want to know about how to add audio alarm to entry and exit signals. So that i can avoid continues watching screen for signals.
    Chandan

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

    • agsuresh says:

      It is strange that this query was not replied. I only got this working and also found the same issue. I had also posted the same question in one of the blogs. So far no one from zerodha has answered it. Perhaps it is due to the Navaratri holidays. But I find that recently lot many queries on these forums / blog are unanswered by zerodha team.

      I think this is basic utility provided by Omnesys to get the traders buy their advanced custom made scripts. Those are the ones they build internally with all the function capabilities.

      The present utility is crude and half baked. The concept of separate script for Buy and Sell itself may not be a not a very good idea. This means you have identify which script you want activate for a given scrip probably based on its trend (up or down). Which means if the scrip reverses the trend on a single day you will have to change the script.

      In any case, unless the multiple conditions are considered, there is no point in wasting any time on this.

  38. Dilip says:

    Hi,
    How to draw Previous day CLOSE,HIGH,LOW lines each day automatically.
    regards
    Dilip

  39. palani kumar says:

    Hi Nithin,

    Please code me for my strategy and this is for 30 min candle chart
    consider 10.30 to 11 clock candle stick
    range = High – low (10.30 to 11 candle)
    buy= High of the 10.30 to 11 candle
    sell = Low of the 10.30 to 11 candle
    Buy Exit(target) = buy + range
    Sell exit(target) = sell – range

  40. Sachin says:

    Hi,

    I am very much new to this automated stuff. So kindly bare with me if the question is way too basic.

    1. I am not able to add the Nifty to watchlist in the ZT

    The Strategy I want to implement:

    On day chart on MACD Crossover: whenever a buy signal is generated I want to buy/sell Nifty options strike which is nearest to the current Nifty. Then have 10 rupees trailing SL on previous days OPEN/CLOSE.

    I want this scrip to run everyday.

    Apart from this I observed there are few more options in the trade window such as bracket, trailing ticks etc etc.

    Any more information about that will be very helpful

    Regards,
    Sachin.

    • Sachin,

      1. Nifty the index can’t be added on the marketwatch presently, you can add the futures though.

      2. You can change the time period buy the expression would be this:

      Buy: MACD(26,12,9,EXPONENTIAL)>MACDSIGNAL(26,12,9,EXPONENTIAL)
      Sell: MACD(26,12,9,EXPONENTIAL)blog.

      4. Presently brackets are still not live on ZT, we will keep you informed about this.

  41. vkeappen says:

    I want to buy when price closes above Bollinger Band and Stochastics above 80 (and %K above %D).
    Also how to code stochastic crossover.

    • Hanan says:

      Here’s the code for your strategy. 🙂

      (CLOSE > BBT(CLOSE, 20, 2, EXPONENTIAL)) and (SOPK(9, 3, 9, SIMPLE) > 80) and (SOPD(9, 3, 9, SIMPLE) > 80) and (SOPK(9, 3, 9, SIMPLE) > SOPD(9, 3, 9, SIMPLE))

  42. vishal says:

    hi Nithin ,
    Could u please help me to code this strategy.
    I need to get alert when price reaches overbought=80 and oversold=20 region in stochastic oscillator.
    stochastic oscillator settings
    %k period :8
    %k slow :4
    %D period:3
    Time frame 5 min.

    • Hanan says:

      Buy:
      SOPK(9, 3, 9, SIMPLE) > 80)

      Sell:

      SOPD(9, 3, 9, SIMPLE) < 20 Another way to interpret the Stochastic Oscillator is to buy when %K rises above %D, and conversely, sell when %K falls below %D. Interval: - My strategy -> go live -> interval -> 5 mins.
      – Please backtest before going live to assess.

  43. balamurugan says:

    hi Nithin Kamath,

    i have my own strategy that is

    i will enter the stock Price is 100

    whenever 101 will come one buy order will be placed automatically
    whenever 99 will come one sell order will be placed automatically

    whenever 105 will come, system should book the loss for that selling order ( 99 sell ) ,
    if the selling order is exist

    whenever 95 will come, system should book the loss for that buying order ( 101 buy ) ,
    if the buying order is exist

    please help me to write the code on AlgoZ for above strategy

  44. Siva says:

    Hi one small suggestion it would be nice if you could put all this in a audio and video format bcoz as beginner its difficult for me to understand all this I feel it would be easy to understand if its in a audio and video format.

  45. tks61 says:

    is back testing is required every time before selecting the code live?

    • Nithin Kamath says:

      Backtesting is not mandatory, but it will make sense to check out if the strategy would have made you money on backtested data.

  46. drsuhask says:

    Dear Sir/Madam,
    I want to write strategy, but I am not able to fit my startegy in this algo. Anybody please let me know how to write this.
    1) I want to buy when closing of the candle is higher than highes of previous 9 candles & sell when closing of candle is lower than lows of previous 9 candles. This will be in hourly TF.
    2) Secondly buy will be only when the trend is uptrend confirmed by cross-over of 8 & 34 EMA in hourly TF. Sell will be vice-versa.
    3) In this system , exit from buy will be when candle closes below the lows of previous 9 candles with closing price below 8 EMA and exit from sell will be when candle closes above highes of previous 9 candles with closing price below 8 EMA.
    Please let me know how to write this strategy?

    Suhas Kothavale

    • Nithin Kamath says:

      Suhas, Will answer this in the blog where I am taking queries on strategies.

      Cheers.

    • Nithin Kamath says:

      Suhas,

      Your strategy:

      Buy expression: CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND EMA(CLOSE,8) > EMA (CLOSE,34)

      Sell expression: CLOSE MINOF(MIN(LOW,8), REF(LOW,9)) AND EMA (CLOSE,8) < EMA (CLOSE,34)

      Buy Exit: CLOSE < MINOF(MIN(LOW,8), REF(LOW,9))AND CLOSE < EMA (CLOSE,8)

      Sell Exit:CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND CLOSE > EMA (CLOSE,8)