Author: Copyright � 2012, JJ Newark
JJN-Nugget

The JJN-Nugget is a specialized technical analysis tool designed to identify potential entry points by monitoring the relationship between price momentum and historical averages. It functions by synthesizing multiple layers of moving averages to create a smoothed "summation" value, which then acts as a baseline for identifying market shifts.

Core Logic Breakdown

1. Multi-Layered Data Aggregation The script begins by calculating eight distinct Exponential Moving Averages (EMAs) simultaneously. It uses specific intervals (5, 8, 13, 21, 34, 55, 89, and 144) to capture a wide range of market perspectives—from very short-term fluctuations to longer-term trends.

2. The "ValSum" Baseline Instead of relying on just one average, the script adds all eight values together and divides them by eight. This creates a collective "mean" or "balance point." By averaging these diverse timeframes, the tool seeks to filter out "noise" and provide a more stable representation of where the price should be relative to its history.

3. Pivot Point Detection The script continuously compares this aggregated average against the midpoint of the current price candle (the halfway point between the High and Low). It looks for specific "cross-over" moments:

  • When the aggregate average moves from below the price midpoint to above it.
  • When the aggregate average moves from above the price midpoint to below it.

Whenever these crossovers occur, the script marks those specific candles as significant data points (the "Nuggets").

4. Real-Time Signaling The indicator provides a live visual status on your chart to help with decision-making:

  • Buy Signal: If the current aggregate average is positioned below the current price midpoint, the tool suggests a "BUY" orientation, indicating that momentum is shifting upward. It also displays a specific price level to watch above.
  • Sell Signal: If the aggregate average is positioned above the current price midpoint, it suggests a "SELL" orientation, indicating downward pressure. It identifies a corresponding price level to monitor below.

Summary for Traders

Essentially, this script acts as a sophisticated filter. It gathers data from multiple timeframes to determine the "true" balance of the market. By identifying the moments when the current price breaks away from that balance point, it provides traders with clear visual cues on whether the current momentum is favoring an upward or downward move.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
JJN-Nugget
//+------------------------------------------------------------------+
//|                                                   JJN-Nugget.mq4 |
//|                                      Copyright © 2012, JJ Newark |
//|                                            http:/jjnewark.atw.hu |
//|                                             jjnewark@freemail.hu |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, JJ Newark"
#property link      "http:/jjnewark.atw.hu"


//---- indicator settings
//#property  indicator_separate_window
#property indicator_chart_window
#property  indicator_buffers      1
#property  indicator_color1       DarkOrange
#property  indicator_width1       2


//---- indicator parameters
extern string     __Copyright__               = "http://jjnewark.atw.hu";
extern color      BuyColor                    = YellowGreen;
extern color      SellColor                   = OrangeRed;
extern color      FontColor                   = Black;
extern int        DisplayDecimals             = 4;
extern int        PosX                        = 10;
extern int        PosY                        = 20;


//---- indicator buffers
double     MainVal[];

double ValSum[];


double Vals[8];
double ValSumTemp;
int per[]={5,8,13,21,34,55,89,144};


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_SECTION);
   SetIndexBuffer(0,MainVal);
   SetIndexBuffer(1,ValSum);
      
   SetIndexLabel(0,"MainVal");
   
   ObjectCreate("NuggetIndName",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetIndName",OBJPROP_CORNER,0);
   ObjectSet("NuggetIndName",OBJPROP_XDISTANCE,PosX+12);
   ObjectSet("NuggetIndName",OBJPROP_YDISTANCE,PosY);
   ObjectSetText("NuggetIndName","JJN-Nugget",8,"Lucida Sans Unicode",FontColor);
   
   ObjectCreate("NuggetLine0",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine0",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine0",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine0",OBJPROP_YDISTANCE,PosY+8);
   ObjectSetText("NuggetLine0","------------------",8,"Tahoma",FontColor);
   
   ObjectCreate("NuggetLine1",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine1",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine1",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine1",OBJPROP_YDISTANCE,PosY+10);
   ObjectSetText("NuggetLine1","------------------",8,"Tahoma",FontColor);
    
   ObjectCreate("NuggetDirection",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetDirection",OBJPROP_CORNER,0);
   ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetDirection",OBJPROP_YDISTANCE,PosY+12);
   ObjectSetText("NuggetDirection","Wait ...",28,"Lucida Sans Unicode",FontColor);   
   
   ObjectCreate("NuggetLevel",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLevel",OBJPROP_CORNER,0);
   ObjectSet("NuggetLevel",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetLevel",OBJPROP_YDISTANCE,PosY+50);
   ObjectSetText("NuggetLevel","  -----  ",9,"Lucida Sans Unicode",FontColor);
   
//---- 
   IndicatorShortName("JJN-Nugget");
   
   
//---- initialization done
   return(0);
  }

int deinit()
  {
//----
   ObjectDelete("NuggetLine0");
   ObjectDelete("NuggetLine1");
   ObjectDelete("NuggetIndName");
   ObjectDelete("NuggetDirection");
   ObjectDelete("NuggetLevel");
      
//----
   return(0);
  }

int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 

   for(int i=0; i<limit; i++)
   {
      for(int j=0; j<8; j++)
      {
      Vals[j]=iMA(NULL,0,per[j],0,MODE_EMA,PRICE_CLOSE,i);
      }
   
      ValSumTemp=0;
      for(int k=0; k<8; k++)
      {
      ValSumTemp+=Vals[k];
      }
      ValSum[i]=ValSumTemp/8;
   }
   
   
   for(i=0; i<limit; i++)
   {
   if(ValSum[i]>(High[i]+Low[i])/2 && ValSum[i+1]<(High[i+1]+Low[i+1])/2) 
      { 
      MainVal[i]=High[i]; 
      }
   else if(ValSum[i]<(High[i]+Low[i])/2 && ValSum[i+1]>(High[i+1]+Low[i+1])/2) 
      {
      MainVal[i]=Low[i];
      }
   else MainVal[i]=EMPTY_VALUE;
   }
   
   double lastprice=0;
        
   int found=0;
   int w=0;
      
      while(found<1)
      {
         if(MainVal[w]!=EMPTY_VALUE)
         {
            lastprice=MainVal[w];
            found++;
         }
         w++;
      }
    
    if(ValSum[0]<(High[0]+Low[0])/2)
    { 
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+5);
    ObjectSetText("NuggetDirection","BUY",28,"Lucida Sans Unicode",BuyColor); 
    ObjectSetText("NuggetLevel","above "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",BuyColor);
    }
    else if(ValSum[0]>(High[0]+Low[0])/2)
    {
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+2);
    ObjectSetText("NuggetDirection","SELL",28,"Lucida Sans Unicode",SellColor); 
    ObjectSetText("NuggetLevel","under "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",SellColor); 
    }
    
    
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments