indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Technical > Indicators & Systems

Indicators & Systems Compendium of Code

DPonline
Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-10-2013, 08:52 PM
amit9009 amit9009 is offline
Regular
 
Join Date: Apr 2013
Posts: 15
Thanks: 3
Thanked 6 Times in 4 Posts
amit9009 is on a distinguished road
Default NMA swing with variable SL & profit target for auto trading

PHP Code:
_SECTION_BEGIN(" NMA VARIABLE SL AND PROFIT");
SetChartOptions(1,chartShowArrows|chartShowDates);
RequestTimedRefresh);
GraphXSpace=5;
HaClose = (O+H+L+C)/4;
HaOpen AMARefHaClose, -), 0.8);
HaHigh MaxHMaxHaCloseHaOpen ) );
HaLow MinLMinHaCloseHaOpen ) );
xDiff = (HaHigh Halow) * IIf(StrFind(Name(),"JPY"),100,10000);
barcolor IIf(HaClose >= HaOpen,colorWhite,colorWhite);
if( 
ParamToggle("Plot Heikin-Ashi""No,Yes") )
   
PlotOHLCHaOpenHaHighHaLowHaClose,  Name(), colorWhitestyleCandle );
else
 
PlotC"Regular candles " Name(), colorWhitestyleCandle );
j=Haclose;
//P = ParamField("Price field",-1);
        //PRICE LINE
 
PriceLineColor PriceLineColorcolorCustom11;
PriceLevel C;
Daysback    =  200;
FirstBar    BarCount DaysBack;
YY          IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);
Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleThick,maskAll));
side 1;
dist 0;

//Magfied Market Price
FS=20;
GfxSelectFont("Times New Roman"FS700True );
GfxSetBkModecolorWhite ); 
GfxSetTextColor (colorBrightGreen );
Hor=1;
Ver=8;
GfxTextOut(""+CHor Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman"11700True );
GfxSetBkModecolorBlack ); 
_SECTION_END();


_SECTION_BEGIN("NICK MA Swing");
EnableTextOutput(False);
SetChartOptions(0chartShowDates);
RequestTimedRefresh(1);
Filename StrLeft(_DEFAULT_NAME(),StrLen(_DEFAULT_NAME())-2);
_N(Title Filename StrFormat(" - {{DATE}} \nOpen %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " " {{VALUES}}"OHLCSelectedValueROCC)) ));
//VarPfx = "Btn1"; // some var that reflects the trading file
SetBarsRequired(200,0);
GraphXSpace 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
=  Optimize("K",Param("K",2.5,0.25,5,0.25),0.25,5,0.25);
PerOptimize("atr",Param("atr",20,3,20,1),3,20,1);
 
//=======================================================================================================================
//=========================Indicator==============================================================================================
f=ATR(15);
 
rfsctor WMA(H-LPer);
 
revers rfsctor;
 
Trend 1
NW[0] = 0
NW[BarCount-1] = Null
 
 
for(
1BarCount-1i++)
{
 if(
Trend[i-1] == 1)               
 {
  if(
j[i] < NW[i-1])                
  {
   
Trend[i] = -1;                  
   
NW[i] = j[i] + Revers[i];       
  }
  else                             
  {
   
Trend[i] = 1;
   if((
j[i] - Revers[i]) > NW[i-1])
   {
    
NW[i] = j[i] - Revers[i];
   }
   else
   {
    
NW[i] = NW[i-1];
   }
  }
 }
 if(
Trend[i-1] == -1)              
 {
  if(
j[i] > NW[i-1])               
  {
   
Trend[i] = 1;                   
   
NW[i] = j[i] - Revers[i];       
  }
  else                             
  {
   
Trend[i] = -1;
   if((
j[i] + Revers[i]) < NW[i-1])
   {
    
NW[i] = j[i] + Revers[i];
   }
   else
   {
    
NW[i] = NW[i-1];
   }
  }
 }
}
 
Plot(NW""IIf(Trend == 1274), 4);


_SECTION_BEGIN("Breakout Setting");
beginTradeTimeParamTime"No trade B4 ""091500" );
endTradeTimeParam("End Time",151000,151000,233000,10);

EndDay ParamTime"No trade after ""15:09:00" );
EndDay2 ParamTime"close position ""15:09:00" );

tn TimeNum();
dn DateNum();
Exit = 
Reftn EndDay2, -) AND ( tn >= EndDay2 OR dn Refdn) );

Buy Sell Short Cover 0;

Buy=NW<HACLOSE;
//Cover=NW<HACLOSE;
//Sell=NW>HACLOSE;
Short=NW>HACLOSE;


//Buy=Cross(J,NW);

//Short=Cross(NW,J);


Buysetup=Flip(J,NW);
Shortsetup=Flip(NW,J);

Sell=Shortsetup OR exit;
Cover=Buysetup OR exit;

Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);

Sell=ExRem(Sell,Cover);
Cover=ExRem(Cover,Sell);

BuyPrice1=Max(Ref(C,-1),O)+0.5;// 0.5 - for better fill
ShortPrice1=Min(Ref(C,-1),O)+0.5;

sellPrice1=Min(Ref(C,-1),O)+0.5;
CoverPrice1=Max(Ref(C,-1),O)+0.5;

BuyPrice ValueWhen(Buy,BuyPrice1); bp=NumToStr(BuyPrice,1.2);
ShortPrice ValueWhen(Short,shortPrice1); shp=NumToStr(ShortPrice,1.2);
SellPrice ValueWhen(Sell,sellPrice1);
CoverPrice ValueWhen(Cover,coverPrice1);

PlotShapesIIfBuyshapeUpArrowshapeNone ), 43layer 0,yposition Lowoffset = -20);
PlotShapesIIfShortshapeDownArrowshapeNone ), colorRedlayer 0yposition Highoffset = -20); //shapeSmallCircle

//PlotShapes( IIf(Cover, shapeHollowUpArrow,shapeNone), colorAqua, layer = 0,yposition = Low, offset = 30);
//PlotShapes( IIf(Sell,shapeHollowDownArrow,shapeNone), colorPink, layer = 0, yposition = High, offset = -30);

StopLevel Param"Stop Loss (%)"0.060.01100.01 );
TgtLevel Param"Profit target (%)"0.250.01100.01 );

ApplyStopstopTypeLossstopModePercentStopLevelTrue );
ApplyStopstopTypeProfitstopModePercentTgtLevelTrue );

Equity1);

sellcond1=Sell==1covercond1=Cover==1;
sellcond2=Sell==2covercond2=Cover==2;
sellcond3=Sell==3covercond3=Cover==3;


//PlotShapes(IIf(sellcond1,shapeSmallDownTriangle,sh apeNone),colorOrange,0,H,-25);
PlotShapes(IIf(sellcond3,shapeHollowDownArrow,shapeNone),colorOrange,0,H,-15);
PlotShapes(IIf(sellcond2,shapeStar,shapeNone),colorOrange,0,H,-15);

//PlotShapes(IIf(covercond1,shapeSmallUpTriangle,sha peNone),colorLime,0,L,-25);
PlotShapes(IIf(covercond3,shapeHollowUpArrow,shapeNone),colorAqua,0,L,-25);
PlotShapes(IIf(covercond2,shapeStar,shapeNone),colorAqua,0,L,-25);

WriteIfSell == 1"Regular exit",WriteIfSell == 3"Profit Tgt",WriteIfSell == 2"Max stop""" ) ));
WriteIfCover == 1"Regular exit",WriteIfCover == 3"Profit Tgt",WriteIfCover == 2"Max stop""" ) ));

GraphXSpace=10;

_SECTION_END();


_SECTION_BEGIN("MASSAGE BOARD"); 
 
for(
i=BarCount-1;i>1;i--)
{
if(
Buy[i]  == 1)
{
entry C[i];
sig "BUY";
sl Ref(NW,-1);
tar1 entry + (entry .00354);
tar2 entry + (entry .0092);
tar3 entry + (entry .0179);
  
bars i;
0;
}
if(
Short[i] == 1)
{
sig "SELL";
entry C[i] ;
sl Ref(NW,-1);
tar1 entry - (entry .00354);
tar2 entry - (entry .0092);
tar3 entry - (entry .0179);
  
  
bars i;
0;
}
}
Offset 20;
Clr IIf(sig == "BUY"colorLimecolorRed);
ssl IIf(bars == BarCount-1NW[BarCount-1], Ref(NW, -1));
sl ssl[BarCount-1];
 
Plot(LineArray(bars-Offsettar1BarCounttar1,1), ""ClrstyleLine|styleDotsNullNullOffset);
Plot(LineArray(bars-Offsettar2BarCounttar2,1), ""ClrstyleLine|styleDotsNullNullOffset);
Plot(LineArray(bars-Offsettar3BarCounttar3,1), ""ClrstyleLine|styleDotsNullNullOffset);
 
 
Plot(LineArray(bars-OffsetslBarCountsl,1), ""colorDarkRedstyleLine|styleLineNullNullOffset);

Plot(LineArray(bars-OffsetentryBarCountentry,1), ""colorYellowstyleLine|styleLineNullNullOffset);


messageboard ParamToggle("Message Board","Show|Hide",1);
if (
messageboard == )
{
GfxSelectFont"Tahoma"13100 );
GfxSetBkMode);
GfxSetTextColorcolorWhite );
  
if ( 
sig =="BUY")
{
GfxSelectSolidBrushcolorDarkGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrushcolorRed ); // this is the box background color
}
pxHeight Status"pxchartheight" ) ;
xx Status"pxchartwidth");
Left 1100;
width 310;
5;
x2 290;
  
pxHeight;
  
GfxSelectPencolorGreen1); // broader color
GfxRoundRectx98x27) ;
GfxTextOut( ( "NMA Trading System"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " sig " Signal came " + (BarCount-bars-1) * Interval()/60 " mins ago"), 13y-80) ; // The text format location
GfxTextOut( ("" WriteIf(sig =="BUY",sig " @ ",sig " @") + " : " entry), 13y-60);
GfxTextOut( ("Trailing SL : " sl " (" WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13y-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)), 13y-22);
 
}
 
_SECTION_END(); 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 3 Users Say Thank You to amit9009 For This Useful Post:
  #2 (permalink)  
Old 04-10-2013, 10:04 PM
sr114's Avatar
sr114 sr114 is offline
Regulars
 
Join Date: Aug 2010
Location: INDIA
Posts: 353
Thanks: 367
Thanked 661 Times in 247 Posts
sr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the rough
Default


Hi

how to use this in auto trade - simply putting in the afl editor and using it or some more coding required?

rgds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to sr114 For This Useful Post:
  #3 (permalink)  
Old 05-10-2013, 09:49 AM
amit9009 amit9009 is offline
Regular
 
Join Date: Apr 2013
Posts: 15
Thanks: 3
Thanked 6 Times in 4 Posts
amit9009 is on a distinguished road
Default

Originally Posted by sr114 View Post
Hi

how to use this in auto trade - simply putting in the afl editor and using it or some more coding required?

rgds

Hi,

This AFL is normal NMA swing with buy sell signal, beside this it has additional variable target based buy sell hollow arrows which is set to 0.25% for nifty future which is 15 points approx. You can change it from settings as per your targets and there is variable stop loss also, showing * signal which is set to 0.06%. For auto trading just drag drop or paste auto trading plugin after this afl and auto trade

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-10-2013, 11:38 AM
sr114's Avatar
sr114 sr114 is offline
Regulars
 
Join Date: Aug 2010
Location: INDIA
Posts: 353
Thanks: 367
Thanked 661 Times in 247 Posts
sr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the rough
Default

Originally Posted by amit9009 View Post
Hi,

This AFL is normal NMA swing with buy sell signal, beside this it has additional variable target based buy sell hollow arrows which is set to 0.25% for nifty future which is 15 points approx. You can change it from settings as per your targets and there is variable stop loss also, showing * signal which is set to 0.06%. For auto trading just drag drop or paste auto trading plugin after this afl and auto trade

Good luck.

Hi

applystop typeprofit of 0.5% is used to get out of the trade along with the target ( tar1,tar2,tar3). now which is the best way to get out of the trade - 0.5% profit target [via applystop profit type] or tar1/tar2/tar3 which is some
multiple of the entry price.

is this done deliberately or compilation eror?

rgds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-10-2013, 12:50 PM
amit9009 amit9009 is offline
Regular
 
Join Date: Apr 2013
Posts: 15
Thanks: 3
Thanked 6 Times in 4 Posts
amit9009 is on a distinguished road
Default

This variable target system works perfectly with auto trading, to control your greed. tar1,tar2,tar3 are for manual trading. most of the time this tar1,tar2,tar3 are not reached
and you end your trade with loss
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 05-10-2013, 01:09 PM
sr114's Avatar
sr114 sr114 is offline
Regulars
 
Join Date: Aug 2010
Location: INDIA
Posts: 353
Thanks: 367
Thanked 661 Times in 247 Posts
sr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the roughsr114 is a jewel in the rough
Default

Originally Posted by amit9009 View Post
This variable target system works perfectly with auto trading, to control your greed. tar1,tar2,tar3 are for manual trading. most of the time this tar1,tar2,tar3 are not reached
and you end your trade with loss

if tar1/tar2/tar3 r for manual trading then why r they coded in auto traded afl?

this afl is like some khichidi afl - all stuff r there - which 1 to choose is the main problem?

also how to trade it auto? where is the api part? is it missing or we have to code it?

also - the 0.06% sl - its too shallow as the sl - sl will be triggered.
also the sl or the profit target is not in confirmation to the price level means - the price will be like some 52 paisa or 44 paisa and itt will not be accepted by the exchange

pls make it multiple of 0.05 paisa



rgds

Last edited by sr114; 05-10-2013 at 01:20 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following 2 Users Say Thank You to sr114 For This Useful Post:
  #7 (permalink)  
Old 05-10-2013, 06:04 PM
amit9009 amit9009 is offline
Regular
 
Join Date: Apr 2013
Posts: 15
Thanks: 3
Thanked 6 Times in 4 Posts
amit9009 is on a distinguished road
Default

This system is for those people who r already doing auto trading in nifty future with nest api

Last edited by amit9009; 05-10-2013 at 06:27 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to amit9009 For This Useful Post:
  #8 (permalink)  
Old 17-03-2014, 02:42 PM
boss boss is offline
Regular
 
Join Date: Mar 2014
Posts: 31
Thanks: 0
Thanked 8 Times in 8 Posts
boss is on a distinguished road
Default

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 18-03-2014, 05:15 PM
nTP's Avatar
nTP nTP is offline
Flash Crash
 
Join Date: Dec 2013
Location: kolkata
Posts: 2,110
Thanks: 7,945
Thanked 2,349 Times in 1,404 Posts
nTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud of
Default

__________________
thx
nTuple

Disclaimer: I am not a Research Analyst and not registered with any regulating authority. All posts are for educational purpose only.

Consider us a dumb -dumble guy in this analysis, any type of real time example will be quick-learn approach.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

indiTraders - Forum for the Active Indian Trader > Technical > Indicators & Systems


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


DPonline

All times are GMT +5.5. The time now is 10:18 AM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2