_TRO_Decimals

Download script
_TRO_Decimals

This tool is designed to analyze and visualize price action by focusing on the relationship between current market prices and specific mathematical thresholds. It operates primarily by tracking how often price remains within a defined "active zone" versus how often it drifts toward the outer boundaries of a set range.

Core Logic and Behavior

Threshold Monitoring The script establishes a boundary system based on a user-defined percentage (the threshold). It calculates whether the current market price is staying within a specific middle range or if it is moving into the "outer" zones. This allows you to see at a glance how much of the recent price history has behaved in a controlled manner compared to more volatile behavior.

Price Normalization To ensure the logic works accurately regardless of whether you are trading assets with high values (like gold or indices) or lower values (like forex pairs), the script automatically adjusts its calculations. It identifies the "point" value of your specific asset and scales the price into a consistent format, ensuring that the threshold detection remains uniform across different markets.

Visual Data Representation The indicator populates a separate window on your chart with four distinct visual elements:

  • Boundary Lines: It draws steady horizontal lines representing the upper and lower limits of your chosen percentage zone.
  • Historical Tracking: The script scans back through a set number of recent bars to perform these calculations.
  • Summary Totals: If enabled, the tool provides a running tally that counts exactly how many times the price stayed within your target zone versus how many times it exceeded it over the specified period.
  • Visual Markers: It utilizes specific icons and line styles to distinguish between the "active" data points and the summary totals, making it easier to identify trends visually.

Summary of Functionality

Instead of just showing you where the price is, this script tells you how much the price prefers to stay within a certain range. It filters out the noise of the market to highlight whether price action is currently staying "centralized" or if it is trending toward the extremes of your defined threshold.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
_TRO_Decimals
//+------------------------------------------------------------------+
//|       _TRO_Open                                                  |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Aqua 
#property indicator_color2 White
#property indicator_color3 Magenta
#property indicator_color4 Aqua  

// indicators parameters

extern bool ShowTotals = false;
extern int myMaxBars = 100;
extern double myThreshold = 0.05 ;

//---- buffers
double P1Buffer[];
double P2Buffer[];
double P3Buffer[];
double P4Buffer[]; 

double xPrice ;
int myStyle  = 2 ;

int myWingDing  = 250 ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

   SetIndexBuffer(0, P1Buffer);
   SetIndexBuffer(1, P2Buffer);
   SetIndexBuffer(2, P3Buffer);
   SetIndexBuffer(3, P4Buffer); 

SetIndexArrow(0, myWingDing); 
SetIndexArrow(1, myWingDing);
SetIndexArrow(2, myWingDing);
SetIndexArrow(3, myWingDing); 

SetIndexStyle(0, DRAW_LINE, myStyle, 1);
SetIndexStyle(1, DRAW_LINE, myStyle, 1);
SetIndexStyle(2, DRAW_ARROW, myStyle, 1);
SetIndexStyle(3, DRAW_LINE, myStyle, 1);  

   
SetIndexEmptyValue(0,0); 
SetIndexEmptyValue(1,0);
SetIndexEmptyValue(2,0);
SetIndexEmptyValue(3,0);
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   
   
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int i, dayi, counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;  
//   int limit = Bars - counted_bars;
   
   int limit = myMaxBars ;
//----   


int xA = 0, xB = 0, xE = 0 ;


   for(i = limit - 1; i >= 0; i--)
     {
      
     if ( Point == 0.01 )  {xPrice = MathMod(Close[i],1.00) ; P3Buffer[i] =  xPrice * 100 ;}
     else { xPrice = MathMod(100*Close[i],1.00)*0.01  ;  P3Buffer[i] =  xPrice * 10000 ;} 
      
     if ( xPrice > myThreshold && xPrice < (1 - myThreshold ) ) xA = xA + 1 ;
     else xE = xE + 1 ;
     
     
        P1Buffer[i] =  myThreshold * 100;   
        P4Buffer[i] =  100 - myThreshold*100 ; 
        
        if (ShowTotals) {    P2Buffer[i] =  xE ; P3Buffer[i] =  xA ; }       
         
     } // for 
 
   return(0);

  } // start

Comments