3D_Oscilator

Author: Author - Luis Damiani. Ramdass - Conversion only
3D_Oscilator

Okay, here's a breakdown of the MQL4 script's logic in plain English, avoiding technical jargon and code snippets. This explanation focuses on what the script does, not how it's coded.

Overall Purpose

This script creates a custom indicator for a trading chart. It's designed to generate visual signals (arrows) that might suggest potential buying or selling opportunities. The indicator combines elements of Relative Strength Index (RSI), Stochastic Oscillator, and a modified CCI (Commodity Channel Index) to create a unique signal. It aims to smooth out price fluctuations and identify trends.

Input Parameters (What You Can Adjust)

  • D1RSIPer: This controls the period (number of bars) used for the initial RSI calculation. A higher number means a longer lookback period, which can smooth out the RSI but also make it less responsive to recent price changes.
  • D2StochPer: This sets the period for a portion of the calculation that uses a Stochastic Oscillator. Like the RSI period, a higher number smooths the signal.
  • D3tunnelPer: This defines the period used in a modified CCI calculation.
  • hot: This is a weighting factor. It determines how much influence the modified CCI has versus the Stochastic Oscillator in the final signal. A value closer to 1 means the CCI has more influence; a value closer to 0 means the Stochastic Oscillator has more influence.
  • sigsmooth: This controls the amount of smoothing applied to the final signal lines. A higher value results in a smoother, less reactive signal.

How the Indicator Works (Step-by-Step)

  1. Initial Setup: The script first defines how the indicator will be displayed on the chart (line style, colors, arrow placement). It also calculates a "warm-up" period (cs) – a number of bars that the indicator needs to process before it starts generating meaningful signals.

  2. Data Collection and Calculation:

    • The script iterates backward through the chart's data, starting from the most recent bar.
    • For each bar, it calculates:
      • RSI (Relative Strength Index): A measure of the magnitude of recent price changes to evaluate overbought or oversold conditions.
      • Stochastic Oscillator: Another indicator used to identify potential overbought or oversold conditions.
      • Modified CCI (Commodity Channel Index): A calculation that combines the RSI and Stochastic Oscillator, weighted by the hot parameter.
    • The script then calculates a smoothed version of the combined indicator (sig1n, sig2n).
  3. Signal Generation:

    • The script looks for specific patterns in the smoothed signal lines (sig1n, sig2n).
    • Upward Arrow: An upward arrow is placed when sig1n crosses above sig2n and the previous bar had sig1n below sig2n. This suggests a potential buying opportunity.
    • Downward Arrow: A downward arrow is placed when sig1n crosses below sig2n and the previous bar had sig1n above sig2n. This suggests a potential selling opportunity.
  4. Display: The indicator displays the smoothed signal lines on the chart. It also places the upward and downward arrows at specific locations based on the signal patterns.

In essence, this indicator attempts to combine several popular technical analysis tools to generate buy/sell signals based on smoothed price action and potential overbought/oversold conditions. The user can adjust the input parameters to fine-tune the indicator's sensitivity and responsiveness to different market conditions.

Indicators Used
Relative strength indexCommodity channel index
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
3D_Oscilator
//+------------------------------------------------------------------+
//|                                                 3D Oscilator.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Author - Luis Damiani. Ramdass - Conversion only"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Magenta
#property indicator_color2 DarkSlateBlue
#property indicator_color3 GreenYellow
#property indicator_color4 Red
//---- input parameters

extern int D1RSIPer=13;
extern int D2StochPer=8;
extern int D3tunnelPer=8;
extern double hot=0.4;
extern int sigsmooth=4;


//---- buffers
double sig1n[];
double sig2n[];
double upX[],dnX[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,sig1n);
   SetIndexBuffer(1,sig2n);

   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,159);
   SetIndexBuffer(2,upX);
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,159);
   SetIndexBuffer(3,dnX);
//----
   SetIndexDrawBegin(0,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
   SetIndexDrawBegin(1,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
   SetIndexDrawBegin(2,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
   SetIndexDrawBegin(3,D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| CCI_Woodies                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,i2,counted_bars=IndicatorCounted();
   double rsi,maxrsi,minrsi,storsi,E3D,
   sig1,sig2,sk,ss,sk2;
   double cs;
   bool init=true;
   
   //----
   cs= D1RSIPer+D2StochPer+D3tunnelPer+hot+sigsmooth;
   if(Bars<=cs) return(0);

   //if (init)
   //{
   ss=sigsmooth;
   if (ss<2) ss=2;
   sk = 2 / (ss + 1);
   sk2=2/(ss*0.8+1);
   init=false;
   //};

   //---- initial zero
   if(counted_bars<1)
      {
      for(i=1;i<=cs;i++) sig1n[Bars-i]=0.0;
      for(i=1;i<=cs;i++) sig2n[Bars-i]=0.0;
      for(i=1;i<=cs;i++) upX[Bars-i]=0.0;
      for(i=1;i<=cs;i++) dnX[Bars-i]=0.0;
      }
      
   i=Bars-cs-1;
   
   if (counted_bars>=cs) i=300; //i=Bars-counted_bars-1;
   while (i>=0)
      {
      
      rsi=iRSI(NULL,0,D1RSIPer,PRICE_CLOSE,i);
      maxrsi=rsi;
      minrsi=rsi;

      for (i2=i+D2StochPer;i2>=i; i2--)
         {
         rsi=iRSI(NULL,0,D1RSIPer,PRICE_CLOSE,i2);
         if (rsi>maxrsi) maxrsi=rsi;
         if (rsi<minrsi) minrsi=rsi;
         //maxrsi=Maximum(rsi,maxrsi);
         //minrsi=min(rsi,minrsi);
         }
         
      storsi=((rsi-minrsi)/(maxrsi-minrsi)*200-100);
      E3D=hot*iCCI(NULL,0,D3tunnelPer,PRICE_TYPICAL,i)+(1-hot)*storsi;
      sig1n[i]=sk*E3D+(1-sk)*sig1;
      sig2n[i]=sk2*sig1+(1-sk2)*sig2;
      sig1=sig1n[i];
      sig2=sig2n[i];
      
      if (sig1n[i]>sig2n[i] && sig1n[i+1]<sig2n[i+1]) upX[i]=sig2n[i]-15;
      if (sig1n[i]<sig2n[i] && sig1n[i+1]>sig2n[i+1]) dnX[i]=sig2n[i]+15;

      i--;
      }
      
   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 ---