Volatility Pivot

Author: thanks to S.B.T. (Japan)
Volatility Pivot
Indicators Used
Indicator of the average true rangeMoving average indicator
Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
Volatility Pivot
//+------------------------------------------------------------------+
//|                                             Volatility.Pivot.mq4 |
//+------------------------------------------------------------------+
#property copyright "thanks to S.B.T. (Japan)"
#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 DarkSeaGreen

//---- input parameters
extern double     atr_range  = 100;
extern double     ima_range  = 10;
extern double     atr_factor = 3;
extern int        Mode       = 0;
extern double     DeltaPrice = 30;


//---- buffers
double TrStop[];
double ATR[];


int init()
  {

   IndicatorBuffers(2);
   SetIndexBuffer(0, TrStop); SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(1, ATR);    SetIndexLabel(1,"range base");

   string short_name = "!! RisenbergVolatilityCapture";
   IndicatorShortName(short_name);
   
   return(0);
  }

int deinit() { return(0);}

int start()
  {
   double DeltaStop;
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=MathMin(Bars-counted_bars,Bars-1);
   
   for(i = limit; i >=0; i--) ATR[i] = iATR(NULL,0,atr_range,i);
   for(i = limit; i >=0; i--)
   {
   if (Mode == 0) {
   DeltaStop = iMAOnArray(ATR,0,ima_range,0,MODE_EMA,i) * atr_factor;
   } else {
   DeltaStop = DeltaPrice*Point;
   }
   if (Close[i] == TrStop[i + 1]) {
   TrStop[i] = TrStop[i + 1];
   } else {
   if (Close[i+1]<TrStop[i+1] && Close[i]<TrStop[i+1]) {
   TrStop[i] = MathMin(TrStop[i + 1], Close[i] + DeltaStop);
   } else {
   if (Close[i+1]>TrStop[i+1] && Close[i]>TrStop[i+1]) {
   TrStop[i] = MathMax(TrStop[i+1], Close[i] - DeltaStop);         
   } else {
   if (Close[i] > TrStop[i+1]) TrStop[i] = Close[i] - DeltaStop; else TrStop[i] = Close[i] + DeltaStop;
   }
  }
 }
}

   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 ---