Code your Technical Analysis strategy

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