Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
Volatility_Pivot_AplPrice_mtf
//+------------------------------------------------------------------+
//| Volatility.Pivot.mq4 |
//+------------------------------------------------------------------+
//2008fxtsd mtf; price(0-6)
#property copyright "thanks to S.B.T. (Japan)" //RisenbergVolatilityCapture
#property link "http://sufx.core.t3-ism.net/" //<<< convert this from VT, thanks mate !!!
//----
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 BlueViolet
//---- input parameters
extern double atr_range = 100;
extern double ima_range = 10;
extern double atr_factor = 3;
extern int applied_Price = 0;
extern bool atr_Mode = true;
extern double DeltaPrice = 30;
//extern int MaxBarsToCount = 500;
extern int TimeFrame = 0;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
string IndicatorFileName;
//---- buffers
double TrStop[];
double ATR[];
double PriceBuff[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, TrStop);
SetIndexBuffer(1, ATR);
SetIndexBuffer(2, PriceBuff);
//----
string short_name="RisenbergVolatilityCapture";
IndicatorShortName(short_name);
SetIndexLabel(0,"range base");
IndicatorFileName = WindowExpertName();
if (TimeFrame < Period()) TimeFrame = Period();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int limit,i;
if(counted_bars < 0) return(-1);
if(counted_bars>0) counted_bars--;
limit = Bars-counted_bars;
// limit= MathMin(limit,MaxBarsToCount);
if (TimeFrame != Period())
{
limit = MathMax(limit,TimeFrame/Period());
datetime TimeArray[];
ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
for(i=0,int y=0; i<limit; i++)
{
if(Time[i]<TimeArray[y]) y++;
TrStop[i]= iCustom(NULL,TimeFrame,IndicatorFileName,
atr_range,ima_range,atr_factor,applied_Price,atr_Mode,DeltaPrice,0,y);
}
return(0);
}
double DeltaStop;
//----
for(i=0; i < limit; i ++)
{
PriceBuff[i] = iMA(NULL,0,1,0,MODE_EMA,applied_Price,i);
ATR[i]=iATR(NULL,0,atr_range,i);
}
for(i=limit - 1; i>=0; i --)
{
if (atr_Mode)
{
DeltaStop=iMAOnArray(ATR,0,ima_range,0,MODE_EMA,i) * atr_factor;
//DeltaStop = iATR(NULL,0,atr_range,i) * atr_factor;
}
else
{
DeltaStop=DeltaPrice*Point;
}
if (PriceBuff[i]==TrStop[i + 1])
{
TrStop[i]=TrStop[i + 1];
}
else
{
if (PriceBuff[i+1]<TrStop[i+1] && PriceBuff[i]<TrStop[i+1])
{
TrStop[i]=MathMin(TrStop[i + 1], PriceBuff[i] + DeltaStop);
}
else
{
if (PriceBuff[i+1]>TrStop[i+1] && PriceBuff[i]>TrStop[i+1])
{
TrStop[i]=MathMax(TrStop[i+1], PriceBuff[i] - DeltaStop);
}
else
{
if (PriceBuff[i] > TrStop[i+1]) TrStop[i]=PriceBuff[i] - DeltaStop;
else TrStop[i]=PriceBuff[i] + DeltaStop;
}
}
}
}
//----
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
---