Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

NMA AFL Code Analysis

13 sec read

Nifty Daily NMA Charts

Parameter used : k=2,ATR=20
Problem Facing : Entry is good and Exit is poor so far in case of Daily NMA Charts


[wp_ad_camp_5]

 
Signals and Results of Long only trades with Daily NMA after post election rally

SymbolTradeDatePriceEx. dateEx. PriceProfit% ProfitSharesPosition valueCum. Profit
NIFTYLong6/29/20094390.957/7/20094202.15-429.98-4.30%2.2774110000-429.98
NIFTYLong7/15/20094233.58/7/20094481.4560.395.86%2.260559570.02130.41
NIFTYLong8/14/20094580.058/17/20094387.9-425.01-4.20%2.2118610130.41-294.59
NIFTYLong8/24/20094642.89/2/20094608.35-72.02-0.74%2.090429705.41-366.61
NIFTYLong9/7/20094782.910/6/20095027.4492.465.11%2.014139633.39125.85
NIFTYLong10/14/20095118.210/21/20095063.6-108.02-1.07%1.978410125.8517.83
NIFTYLong11/6/20094796.1511/27/20094941.75304.123.04%2.0887210017.83321.94
NIFTYLong12/2/20095123.2512/16/20095042.05-163.6-1.58%2.0147310321.94158.35
NIFTYLong12/23/20095144.61/13/20105233.95176.431.74%1.9745710158.35334.78
NIFTYOpen Long2/16/20104855.753/31/20105249.1837.198.10%2.1283610334.771171.96
Statistics
All tradesLong tradesShort trades
Initial capital100001000010000
Ending capital11171.9611171.9610000
Net Profit1171.961171.960
Net Profit %11.72%11.72%0.00%
Exposure %51.82%51.82%0.00%
Net Risk Adjusted Return %22.62%22.62%N/A
Annual Return %13.00%13.00%0.00%
Risk Adjusted Return %25.09%25.09%N/A
All trades1010 (100.00 %)0 (0.00 %)
Avg. Profit/Loss117.2117.2N/A
Avg. Profit/Loss %1.20%1.20%N/A
Avg. Bars Held12.412.4N/A
Winners5 (50.00 %)5 (50.00 %)0 (0.00 %)
Total Profit2370.582370.580
Avg. Profit474.12474.12N/A
Avg. Profit %4.77%4.77%N/A
Avg. Bars Held1818N/A
Max. Consecutive220
Largest win837.19837.190
No of bars in largest win29290
Losers5 (50.00 %)5 (50.00 %)0 (0.00 %)
Total Loss-1198.61-1198.610
Avg. Loss-239.72-239.72N/A
Avg. Loss %-2.38%-2.38%N/A
Avg. Bars Held6.86.8N/A
Max. Consecutive220
Largest loss-429.98-429.980
# bars in largest loss770
Max. trade drawdown-588.82-588.820
Max. trade % drawdown-5.84%-5.84%0.00%
Max. system drawdown-977.95-977.950
Max. system % drawdown-9.22%-9.22%0.00%
Recovery Factor1.21.2N/A
CAR/MaxDD1.411.41N/A
RAR/MaxDD2.722.72N/A
Profit Factor1.981.98N/A
Payoff Ratio1.981.98N/A
Standard Error254.47254.470
Risk-Reward Ratio3.823.82N/A
Ulcer Index4.014.010
Ulcer Performance Index1.891.89N/A
Sharpe Ratio of trades1.051.050
K-Ratio0.06740.0674-1.#IND

NMA Weekly Charts

NMA Weekly Charts indicating long term buy signal in weekly charts since last week.

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

NMA Buy/Sell Signal Update for Nifty

Charts shows that buy signal which started on 6th July remains valid till now without breaking the trailing stop loss line, And the current...
Rajandran R
9 sec read

Nifty GANN FAN, NMA Signal, Ichimoku Charts Overview

Long term GANN Fan Charts of Nifty shows that it is trading currently between the long term resistance line 5400 and the long...
Rajandran R
17 sec read

5 EMA Weekly Trading View for Nifty

Applying 5EMA(Low-High) rule to the nifty weekly chart we could find that the recent nifty weekly candle got housed between the 5EMA high...
Rajandran R
22 sec read

14 Replies to “NMA AFL Code Analysis”

  1. Respected Sir,

    Pls also check if v use k=5 & atr=20 in Hourly chart. In this we will have minimum of 80 points in every trade.

    Regards,

    Dipak

  2. Hi rajanderan try the undermentioned formulae on EOD charts

    For NIFTY 01 year it gives NET 65.23 % profit ( 31 MAR 2009 to Mar 2010 )

    For BANKNIFTY 01 year it gives NET 79 % profit ( 31 MAR 2009 to Mar 2010 )

    Really amazing !

    following is the code

    _SECTION_BEGIN(“Price”);
    SetChartOptions(0,chartShowArrows|chartShowDates);
    _N(Title = StrFormat(“{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    Plot( C, “Close”, ParamColor(“Color”, colorBlack ), styleNoTitle | ParamStyle(“Style”) | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN(“MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 8, 2, 200, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();

    _SECTION_BEGIN(“Mid MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 34, 2, 300, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();

    _SECTION_BEGIN(“Long MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 200, 2, 400, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();
    _SECTION_END();

    _SECTION_BEGIN(“SAR”);
    acc = Param(“Acceleration”, 0.02, 0, 1, 0.001 );
    accm = Param(“Max. acceleration”, 0.2, 0, 1, 0.001 );
    Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”, styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
    _SECTION_END();
    RSIperiod = 15; // Param(“RSI p”,3,14,30,1);
    Percent = 5; // Param(“ZIG %”,8,9,15,1);
    EMAperiod = 5; //Param(“EMA p”,4,5,10,1);
    HHVperiod = 8; //Param(“HHV p”,3,5,10,1);
    NumLine = 2; //Param(“Num Lines”,3,1,20,1);

    Base = DEMA(RSI(RSIperiod),EMAperiod);

    for( i = 1; i <= numline; i++ )
    {
    ResBase = LastValue(Peak(Base,Percent,i));
    SupBase = LastValue(Trough(Base,Percent,i));
    Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
    Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
    }
    Title = Name() + "; " + Date() + ": Support & Resistance Levels using RSI: " + /*EncodeColor(colorGreen)+ "Support Levels are Green; "+EncodeColor(colorRed)+ "Resistance Levels are Red: "+EncodeColor(colorBlack)+*/ "Num lines ="+WriteVal(numline,1) ;

    _SECTION_BEGIN("heikin");

    // Calculate Moving Average
    MAPeriod = Param("MA Period", 15, 1, 100);
    MAOpen = EMA(Open, MAPeriod);
    MAHigh = EMA(High, MAPeriod);
    MALow = EMA(Low, MAPeriod);
    MAClose = EMA(Close, MAPeriod);

    HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
    HaOpen = AMA(Ref(HaClose, -1), 0.5);

    // for graph collapse
    for(i = 0; i <= MAPeriod; i++) HaClose[i] = Null;
    /*
    // same
    // HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
    HaOpen[ 0 ] = HaClose[ 0 ];
    for(i = 1; i < BarCount; i++) {
    HaOpen[i] = (HaOpen[i – 1] + HaClose[i – 1]) / 2;
    }
    */

    HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
    HaLow = Min(MALow, Min(HaClose, HaOpen));

    // outs comments
    "BarIndex = " + BarIndex();
    "Open = " + Open;
    "High = " + High;
    "Low = " + Low;
    "Close = "+ Close;
    "HaOpen = " + HaOpen;
    "HaHigh = " + HaHigh;
    "HaLow = " + HaLow;
    "HaClose = "+ HaClose;

    /* **********************************

    Code to automatically identify pivots

    ********************************** */

    // — what will be our lookback range for the hh and ll?
    farback=Param("How Far back to go",100,50,5000,10);
    nBars = Param("Number of bars", 12, 5, 40);

    // — Create 0-initialized arrays the size of barcount

    aHPivs = H – H;

    aLPivs = L – L;

    // — More for future use, not necessary for basic plotting

    aHPivHighs = H – H;

    aLPivLows = L – L;

    aHPivIdxs = H – H;

    aLPivIdxs = L – L;

    nHPivs = 0;

    nLPivs = 0;

    lastHPIdx = 0;

    lastLPIdx = 0;

    lastHPH = 0;

    lastLPL = 0;

    curPivBarIdx = 0;

    // — looking back from the current bar, how many bars

    // back were the hhv and llv values of the previous

    // n bars, etc.?

    aHHVBars = HHVBars(H, nBars);

    aLLVBars = LLVBars(L, nBars);

    aHHV = HHV(H, nBars);

    aLLV = LLV(L, nBars);

    // — Would like to set this up so pivots are calculated back from

    // last visible bar to make it easy to "go back" and see the pivots

    // this code would find. However, the first instance of

    // _Trace output will show a value of 0

    aVisBars = Status("barvisible");

    nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

    _TRACE("Last visible bar: " + nLastVisBar);

    // — Initialize value of curTrend

    curBar = (BarCount-1);

    curTrend = "";

    if (aLLVBars[curBar] <

    aHHVBars[curBar]) {

    curTrend = "D";

    }

    else {

    curTrend = "U";

    }

    // — Loop through bars. Search for

    // entirely array-based approach

    // in future version

    for (i=0; i<farback; i++) {

    curBar = (BarCount – 1) – i;

    // — Have we identified a pivot? If trend is down…

    if (aLLVBars[curBar] lastHPIdx) {

    // — Bar and price info for candidate pivot

    candIdx = curBar – aHHVBars[curBar];

    candPrc = aHHV[curBar];

    if (

    lastHPH lastLPIdx AND

    candIdx < curBar) {

    // — OK, we'll add this as a pivot…

    aHPivs[candIdx] = 1;

    // …and then rearrange elements in the

    // pivot information arrays

    for (j=0; j candPrc AND

    candIdx > lastHPIdx AND

    candIdx < curBar) {

    // — OK, we'll add this as a pivot…

    aLPivs[candIdx] = 1;

    // …and then rearrange elements in the

    // pivot information arrays

    for (j=0; j<nLPivs; j++) {

    aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

    aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

    }

    aLPivLows[0] = candPrc;

    aLPivIdxs[0] = candIdx;

    nLPivs++;

    }

    }

    // — Dump inventory of high pivots for debugging

    /*

    for (k=0; k<nHPivs; k++) {

    _TRACE("High pivot no. " + k

    + " at barindex: " + aHPivIdxs[k] + ", "

    + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

    DateTime(), 1), formatDateTime)

    + ", " + aHPivHighs[k]);

    }

    */

    // — OK, let's plot the pivots using arrows

    PlotShapes(

    IIf(aHPivs==1, shapeDownArrow, shapeNone), colorRed, 0,

    High, Offset=-15);

    PlotShapes(

    IIf(aLPivs==1, shapeUpArrow , shapeNone), colorBrightGreen, 0,

    Low, Offset=-15);

    AlertIf( aLPivs==1, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( aHPivs==1, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );

    Buy=(aLPivs==1);
    Cover=(aLPivs==1);
    Sell=(aHPivs==1);
    Short=(aHPivs==1);
    SellPrice=ValueWhen(Sell,C,1);
    BuyPrice=ValueWhen(Buy,C,1);
    Long=Flip(Buy,Sell);
    Shrt=Flip(Sell,Buy );
    _SECTION_END();
    //=================TITLE============================ ================================================== ==================
    _SECTION_BEGIN("Title");
    if( Status("action") == actionIndicator )
    (
    Title = EncodeColor(colorLightBlue)+ "Heikin-Ashi pivot + NMA Swing system – Boxed arrows NMA buy-sell – Normal Arrows Heikin Pivot Buy-Sell" + " – " + Name() + " – " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
    " – " + Date() +" – "+"
    " +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
    "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"
    "+
    EncodeColor(colorRed)+
    WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
    WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"
    "+EncodeColor(colorWhite)+
    WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
    WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
    WriteIf(Long AND NOT Buy, "Trade : Long – Entry price Rs."+(BuyPrice),"")+
    WriteIf(shrt AND NOT Sell, "Trade : Short – Entry price Rs."+(SellPrice),"")+"
    "+
    WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
    WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
    AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
    _SECTION_END();

  3. Dear sandhu348, I`m also getting error in my AB 5.29. It says : error 31. Syntex error, expecting ‘)’ or ‘,’. Please post a solution or the afl.
    Piash

  4. Hi Mr. Sandhu348,

    Want to try ur AFL but contains lot of errors. Can u please rectify and repost..

    Thanks
    Shree

  5. _SECTION_BEGIN(“MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 8, 2, 200, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();

    _SECTION_BEGIN(“Mid MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 34, 2, 300, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();

    _SECTION_BEGIN(“Long MA”);
    P = ParamField(“Price field”,-1);
    Periods = Param(“Periods”, 200, 2, 400, 1 );
    Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”) | styleNoRescale );
    _SECTION_END();
    _SECTION_END();

    _SECTION_BEGIN(“SAR”);
    acc = Param(“Acceleration”, 0.02, 0, 1, 0.001 );
    accm = Param(“Max. acceleration”, 0.2, 0, 1, 0.001 );
    Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( “Color”, colorCycle ), ParamStyle(“Style”, styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
    _SECTION_END();
    RSIperiod = 15; // Param(“RSI p”,3,14,30,1);
    Percent = 5; // Param(“ZIG %”,8,9,15,1);
    EMAperiod = 5; //Param(“EMA p”,4,5,10,1);
    HHVperiod = 8; //Param(“HHV p”,3,5,10,1);
    NumLine = 2; //Param(“Num Lines”,3,1,20,1);

    Base = DEMA(RSI(RSIperiod),EMAperiod);

    for( i = 1; i <= numline; i++ )
    {
    ResBase = LastValue(Peak(Base,Percent,i));
    SupBase = LastValue(Trough(Base,Percent,i));
    Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorRed, styleLine);
    Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorGreen, styleLine);
    }
    Title = Name() + "; " + Date() + ": Support & Resistance Levels using RSI: " + /*EncodeColor(colorGreen)+ "Support Levels are Green; "+EncodeColor(colorRed)+ "Resistance Levels are Red: "+EncodeColor(colorBlack)+*/ "Num lines ="+WriteVal(numline,1) ;

    _SECTION_BEGIN("heikin");

    // Calculate Moving Average
    MAPeriod = Param("MA Period", 15, 1, 100);
    MAOpen = EMA(Open, MAPeriod);
    MAHigh = EMA(High, MAPeriod);
    MALow = EMA(Low, MAPeriod);
    MAClose = EMA(Close, MAPeriod);

    HaClose = (MAOpen + MAHigh + MALow + MAClose) / 4;
    HaOpen = AMA(Ref(HaClose, -1), 0.5);

    // for graph collapse
    for(i = 0; i <= MAPeriod; i++) HaClose[i] = Null;
    /*
    // same
    // HaOpen = (Ref(HaOpen, -1) + Ref(HaClose, -1)) / 2;
    HaOpen[ 0 ] = HaClose[ 0 ];
    for(i = 1; i < BarCount; i++) {
    HaOpen[i] = (HaOpen[i – 1] + HaClose[i – 1]) / 2;
    }
    */

    HaHigh = Max(MAHigh, Max(HaClose, HaOpen));
    HaLow = Min(MALow, Min(HaClose, HaOpen));

    // outs comments
    "BarIndex = " + BarIndex();
    "Open = " + Open;
    "High = " + High;
    "Low = " + Low;
    "Close = "+ Close;
    "HaOpen = " + HaOpen;
    "HaHigh = " + HaHigh;
    "HaLow = " + HaLow;
    "HaClose = "+ HaClose;

    /* **********************************

    Code to automatically identify pivots

    ********************************** */

    // — what will be our lookback range for the hh and ll?
    farback=Param("How Far back to go",100,50,5000,10);
    nBars = Param("Number of bars", 12, 5, 40);

    // — Create 0-initialized arrays the size of barcount

    aHPivs = H – H;

    aLPivs = L – L;

    // — More for future use, not necessary for basic plotting

    aHPivHighs = H – H;

    aLPivLows = L – L;

    aHPivIdxs = H – H;

    aLPivIdxs = L – L;

    nHPivs = 0;

    nLPivs = 0;

    lastHPIdx = 0;

    lastLPIdx = 0;

    lastHPH = 0;

    lastLPL = 0;

    curPivBarIdx = 0;

    // — looking back from the current bar, how many bars

    // back were the hhv and llv values of the previous

    // n bars, etc.?

    aHHVBars = HHVBars(H, nBars);

    aLLVBars = LLVBars(L, nBars);

    aHHV = HHV(H, nBars);

    aLLV = LLV(L, nBars);

    // — Would like to set this up so pivots are calculated back from

    // last visible bar to make it easy to "go back" and see the pivots

    // this code would find. However, the first instance of

    // _Trace output will show a value of 0

    aVisBars = Status("barvisible");

    nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

    _TRACE("Last visible bar: " + nLastVisBar);

    // — Initialize value of curTrend

    curBar = (BarCount-1);

    curTrend = "";

    if (aLLVBars[curBar] <

    aHHVBars[curBar]) {

    curTrend = "D";

    }

    else {

    curTrend = "U";

    }

    // — Loop through bars. Search for

    // entirely array-based approach

    // in future version

    for (i=0; i<farback; i++) {

    curBar = (BarCount – 1) – i;

    // — Have we identified a pivot? If trend is down…

    if (aLLVBars[curBar] lastHPIdx) {

    // — Bar and price info for candidate pivot

    candIdx = curBar – aHHVBars[curBar];

    candPrc = aHHV[curBar];

    if (

    lastHPH lastLPIdx AND

    candIdx < curBar) {

    // — OK, we'll add this as a pivot…

    aHPivs[candIdx] = 1;

    // …and then rearrange elements in the

    // pivot information arrays

    for (j=0; j candPrc AND

    candIdx > lastHPIdx AND

    candIdx < curBar) {

    // — OK, we'll add this as a pivot…

    aLPivs[candIdx] = 1;

    // …and then rearrange elements in the

    // pivot information arrays

    for (j=0; j<nLPivs; j++) {

    aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

    aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

    }

    aLPivLows[0] = candPrc;

    aLPivIdxs[0] = candIdx;

    nLPivs++;

    }

    }

    // — Dump inventory of high pivots for debugging

    /*

    for (k=0; k<nHPivs; k++) {

    _TRACE("High pivot no. " + k

    + " at barindex: " + aHPivIdxs[k] + ", "

    + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

    DateTime(), 1), formatDateTime)

    + ", " + aHPivHighs[k]);

    }

    */

    // — OK, let's plot the pivots using arrows

    PlotShapes(

    IIf(aHPivs==1, shapeDownArrow, shapeNone), colorRed, 0,

    High, Offset=-15);

    PlotShapes(

    IIf(aLPivs==1, shapeUpArrow , shapeNone), colorBrightGreen, 0,

    Low, Offset=-15);

    AlertIf( aLPivs==1, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( aHPivs==1, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );

    Buy=(aLPivs==1);
    Cover=(aLPivs==1);
    Sell=(aHPivs==1);
    Short=(aHPivs==1);
    SellPrice=ValueWhen(Sell,C,1);
    BuyPrice=ValueWhen(Buy,C,1);
    Long=Flip(Buy,Sell);
    Shrt=Flip(Sell,Buy );
    _SECTION_END();
    //=================TITLE============================ ================================================== ==================
    _SECTION_BEGIN("Title");
    if( Status("action") == actionIndicator )
    (
    Title = EncodeColor(colorLightBlue)+ "Heikin-Ashi pivot + NMA Swing system – Boxed arrows NMA buy-sell – Normal Arrows Heikin Pivot Buy-Sell" + " – " + Name() + " – " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
    " – " + Date() +" – "+"
    " +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
    "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"
    "+
    EncodeColor(colorRed)+
    WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
    WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"
    "+EncodeColor(colorWhite)+
    WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
    WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
    WriteIf(Long AND NOT Buy, "Trade : Long – Entry price Rs."+(BuyPrice),"")+
    WriteIf(shrt AND NOT Sell, "Trade : Short – Entry price Rs."+(SellPrice),"")+"
    "+
    WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
    WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
    AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
    _SECTION_END();

  6. still the error begins from this line upper side is ok no problem till this lines
    pls rectify the same thanks

    // — Have we identified a pivot? If trend is down…

    if (aLLVBars[curBar] lastHPIdx) {

    // — Bar and price info for candidate pivot

    candIdx = curBar – aHHVBars[curBar];

    candPrc = aHHV[curBar];

    if (

    lastHPH >lastLPIdx AND

    candIdx lastHPIdx AND

    candIdx < curBar) {

    // — OK, we'll add this as a pivot…

    aLPivs[candIdx] = 1;

    // …and then rearrange elements in the

    // pivot information arrays

    for (j=0; j<nLPivs; j++) {

    aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

    aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

    }

    aLPivLows[0] = candPrc;

    aLPivIdxs[0] = candIdx;

    nLPivs++;

    }

    }

    // — Dump inventory of high pivots for debugging

    /*

    for (k=0; k<nHPivs; k++) {

    _TRACE("High pivot no. " + k

    + " at barindex: " + aHPivIdxs[k] + ", "

    + WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

    DateTime(), 1), formatDateTime)

    + ", " + aHPivHighs[k]);

    }

    */

    // — OK, let's plot the pivots using arrows

    PlotShapes(

    IIf(aHPivs==1, shapeDownArrow, shapeNone), colorRed, 0,

    High, Offset=-15);

    PlotShapes(

    IIf(aLPivs==1, shapeUpArrow , shapeNone), colorBrightGreen, 0,

    Low, Offset=-15);

    AlertIf( aLPivs==1, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( aHPivs==1, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );

    Buy=(aLPivs==1);
    Cover=(aLPivs==1);
    Sell=(aHPivs==1);
    Short=(aHPivs==1);
    SellPrice=ValueWhen(Sell,C,1);
    BuyPrice=ValueWhen(Buy,C,1);
    Long=Flip(Buy,Sell);
    Shrt=Flip(Sell,Buy );
    _SECTION_END();
    //=================TITLE============================ ================================================== ==================
    _SECTION_BEGIN("Title");
    if( Status("action") == actionIndicator )
    (
    Title = EncodeColor(colorLightBlue)+ "Heikin-Ashi pivot + NMA Swing system – Boxed arrows NMA buy-sell – Normal Arrows Heikin Pivot Buy-Sell" + " – " + Name() + " – " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
    " – " + Date() +" – "+"
    " +EncodeColor(colorYellow) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
    "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"
    "+
    EncodeColor(colorRed)+
    WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
    WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"
    "+EncodeColor(colorWhite)+
    WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
    WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
    WriteIf(Long AND NOT Buy, "Trade : Long – Entry price Rs."+(BuyPrice),"")+
    WriteIf(shrt AND NOT Sell, "Trade : Short – Entry price Rs."+(SellPrice),"")+"
    "+
    WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
    WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
    AlertIf( Buy, "SOUND C:\\Windows\\Media\\Windows XP Startup.wav", "Audio alert", 2 );
    AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ringin.wav", "Audio alert", 2 );
    _SECTION_END();

  7. Dear Rajandran sir
    I am using NMA signals. It is working fine and getting maximum points in nifty , my settings are ATR=4 and K=1 . Chances of whipsaws r more but that is OK for me .

  8. Yeah amol 1,4 can be used for short term bias. I am using 2,20 to guage the overal trend. As the whipsaws are minimum and 2,20 supports medium term bias

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More