Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
_PerkyAsctrend1WPR_mtf
//+------------------------------------------------------------------+
//| _PerkyAsctrend1WPR_mtf.mq4 |
//| Copyright © 2005, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_minimum 0.00
#property indicator_maximum 100.00
#property indicator_level1 50.00
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 1
extern int RISK = 4;
extern int MTF.Period = 0;
extern string Reffer.Indicator.Name = "_PerkyAsctrend1WPR_mtf";
double val1buffer[];
//+------------------------------------------------------------------+
//| global variables |
//+------------------------------------------------------------------+
int up = 0;
int dn = 0;
string G_sReffer.Indicator.Name = "_PerkyAsctrend1WPR_mtf";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int nArrowNum = 0;
int nPeriod = 0;
//----
IndicatorBuffers(1);
if(MTF.Period <= 0)
{
nPeriod = Period();
}
else
{
nPeriod = MTF.Period;
}
IndicatorShortName("PAT_WPR( " + nPeriod + " )");
SetLevelValue(2, (33 - RISK));
SetLevelValue(3, (67 + RISK));
//---- indicators
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, val1buffer);
SetIndexDrawBegin(0, (3 + RISK * 2));
SetIndexEmptyValue(0, EMPTY_VALUE);
SetIndexLabel(0, "PAT_WPR");
//----
G_sReffer.Indicator.Name = StringTrimRight(Reffer.Indicator.Name);
if(StringLen(G_sReffer.Indicator.Name) <= 0)
{
G_sReffer.Indicator.Name = WindowExpertName();
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ArrayInitialize(val1buffer, EMPTY_VALUE);
WindowRedraw();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
//----
if(counted_bars < 0)
{
return(-1);
}
// other timeframe function
if((MTF.Period <= 0) || (MTF.Period == Period()))
{
this.timeframe();
}
// same timeframe function
else if(MTF.Period != Period())
{
other.timeframe();
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| set this chart timeframe |
//+------------------------------------------------------------------+
void this.timeframe()
{
double value10 = 10;
double value11;
int TrueCount;
int counter;
int MRO1;
int MRO2;
double Range;
double AvgRange;
int counted_bars = IndicatorCounted();
value10 = 3 + RISK * 2;
value11 = value10;
//----------------------------
if(counted_bars < 0) return (-1);
if(counted_bars > 0) counted_bars--; //last bar recounted
int i;
int shift = Bars - counted_bars - 1;
for(i=shift ; i >= 0 ; i--)
{
counter = i;
Range = 0;
AvgRange = 0;
for(counter = i ; counter <= i + 9 ; counter++)
{
AvgRange = AvgRange + MathAbs(High[counter] - Low[counter]);
}
Range = AvgRange / 10;
counter = i;
TrueCount = 0;
while (counter < i + 9 && TrueCount < 1)
{
if(MathAbs(Open[counter] - Close[counter+1]) >= Range * 2.0 )
TrueCount++;
counter++;
}
if(TrueCount >= 1)
MRO1 = counter ;
else
MRO1 = -1;
counter = i;
TrueCount = 0;
while (counter < i + 6 && TrueCount < 1)
{
if(MathAbs(Close[counter + 3] - Close[counter]) >= Range * 4.6)
{
TrueCount++;
}
counter++;
}
if(TrueCount >= 1)
MRO2 = counter;
else
MRO2 = -1;
if(MRO1 > -1)
value11 = 3;
else
value11 = value10;
if(MRO2 > -1)
value11 = 4;
else
value11 = value10;
val1buffer[i] = 100 - MathAbs(iWPR(NULL, 0, value11, i));
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| set other chart timeframe |
//+------------------------------------------------------------------+
void other.timeframe()
{
int i, j;
int counted_bars = IndicatorCounted();
int max_bars = Bars;
int limit = max_bars - counted_bars;
//----
datetime TimeArray[];
//----
limit = MathMax(limit, (MTF.Period / Period()));
ArrayCopySeries(TimeArray, MODE_TIME, Symbol(), MTF.Period);
for(i = 0, j = 0; i <= limit ; i++)
{
// initialized current buffer
if(Time[i] < TimeArray[j]) j++;
//val1buffer[i] = iCustom(Symbol(), MTF.Period, G_sReffer.Indicator.Name, 0, j);
val1buffer[i] = iCustom(Symbol(), MTF.Period
, G_sReffer.Indicator.Name
, RISK
, MTF.Period
, Reffer.Indicator.Name
, 0
, j);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---