Author: neo
percent
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
percent
//+------------------------------------------------------------------+
//|                                                      percent.mq4 |
//|                                                              neo |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "neo"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100

#property indicator_buffers 1
#property indicator_color1 Black

//---- input parameters
extern int N=60;


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


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

   SetIndexDrawBegin(0,N);

   SetIndexBuffer(0,perct);

   SetIndexStyle(0,DRAW_LINE);

   SetIndexLabel(0,"percent");

   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
int start()
  {
   int count=1;

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);

	  
//---- main loop
	 
   for(int i=0; i<Bars-N; i++)
     {
       count = 0;
		 for(int k=1; k<=N; k++)
		   {	 
		     if( Close[i]>=Open[i+k] && Close[i]<=Close[i+k] )   count++; 
		   }
		 perct[i]=1.0*count/N*100;

     }  

//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---