smTMMS Oscillator

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

smTMMS Oscillator

Postby rch05000 » Sun Aug 11, 2019 8:37 am

Hello,
I use Oscillator "sm TMMS Oscillator" for MT4.
Is it possible to create this Oscillator for TS2?
The smTMMS oscillator is composed of one RSI of 14 periods and two stochastics, one set to 8.3.3 and the other to 14.3.3.
When the oscillator is green, it means that the three indicators are above line 50 and the long-term direction is likely to continue.
If the oscillator is red, it means that the three indicators are below line 50 and the short direction will probably continue in the short term.
Here is the code of this oscillator and an image of it.
Code:
Code: Select all
//+------------------------------------------------------------------+
//|                                       smTMMS Oscillator_vX
//+------------------------------------------------------------------+
#property copyright "Copyright 30.06.2019, SwingMan"
#property strict
#property indicator_separate_window

#property indicator_buffers 6

#property indicator_color1 clrSienna
#property indicator_color2 clrLime
#property indicator_color3 clrDodgerBlue
#property indicator_color4 clrGreen
#property indicator_color5 clrRed
#property indicator_color6 clrDarkGray

#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 3
#property indicator_width5 3
#property indicator_width6 3


//#property indicator_level1 80
//#property indicator_level2 50
//#property indicator_level3 20
#property indicator_level1 30
#property indicator_level2 0
#property indicator_level3 -30
#property indicator_levelcolor clrSilver
#property indicator_levelstyle STYLE_DOT
#property indicator_levelwidth 1

//#property indicator_maximum 100
//#property indicator_minimum 0
#property indicator_maximum 50
#property indicator_minimum -50

//+------------------------------------------------------------------+
sinput string           sRSI="RSI"; //=================================     
input int      RSI_Period=14;
input ENUM_APPLIED_PRICE      RSI_AppliedPrice=PRICE_CLOSE;
//
sinput string           sStochastic="STOCHASTIC"; //=================================   
input int            Stochastic_1_Period_K  = 8;
input int            Stochastic_1_Period_D  = 3;
input int            Stochastic_1_Slowing   = 3;
input ENUM_STO_PRICE Stochastic_1_PriceField = STO_LOWHIGH;
input ENUM_MA_METHOD Stochastic_1_MAmethod   = MODE_SMMA;
input int            Stochastic_2_Period_K  = 14;
input int            Stochastic_2_Period_D  = 3;
input int            Stochastic_2_Slowing   = 3;
input ENUM_STO_PRICE Stochastic_2_PriceField = STO_LOWHIGH;
input ENUM_MA_METHOD Stochastic_2_MAmethod   = MODE_SMMA;
//+------------------------------------------------------------------+

//---- buffers
double bufRSI[],bufStoch1[],bufStoch2[];
double bufHistUP[],bufHistDN[],bufHistNO[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   int iBuff=-1;
   iBuff++; SetIndexBuffer(iBuff,bufRSI);     SetIndexStyle(iBuff,DRAW_LINE);       SetIndexLabel(iBuff,"RSI");
   iBuff++; SetIndexBuffer(iBuff,bufStoch1);  SetIndexStyle(iBuff,DRAW_LINE);       SetIndexLabel(iBuff,"Stochastic ("+Stochastic_1_Period_K+")");
   iBuff++; SetIndexBuffer(iBuff,bufStoch2);  SetIndexStyle(iBuff,DRAW_LINE);       SetIndexLabel(iBuff,"Stochastic ("+Stochastic_2_Period_K+")");
   iBuff++; SetIndexBuffer(iBuff,bufHistUP);  SetIndexStyle(iBuff,DRAW_HISTOGRAM);  SetIndexLabel(iBuff,NULL);
   iBuff++; SetIndexBuffer(iBuff,bufHistDN);  SetIndexStyle(iBuff,DRAW_HISTOGRAM);  SetIndexLabel(iBuff,NULL);
   iBuff++; SetIndexBuffer(iBuff,bufHistNO);  SetIndexStyle(iBuff,DRAW_HISTOGRAM);  SetIndexLabel(iBuff,NULL);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int    i,pos;
   double threshold=50,limit=0;

//---
   if(rates_total<=10)
      return(0);
////--- counting from 0 to rates_total
//   ArraySetAsSeries(bufRSI,false);
//   ArraySetAsSeries(bufStoch1,false);
//   ArraySetAsSeries(bufStoch2,false);
//   ArraySetAsSeries(bufHistUP,false);
//   ArraySetAsSeries(bufHistDN,false);
//   ArraySetAsSeries(bufHistNO,false);
//
////--- preliminary calculation
//   if(prev_calculated>1)
//      pos=prev_calculated-1;
//   else
   pos=0;

//--- main loop of calculations
   for(i=pos; i<rates_total; i++)
     {
      //--- oscillators
      bufRSI[i]=iRSI(Symbol(),Period(),RSI_Period,RSI_AppliedPrice,i);
      bufStoch1[i]=iStochastic(Symbol(),Period(),
                               Stochastic_1_Period_K,Stochastic_1_Period_D,Stochastic_1_Slowing,
                               Stochastic_1_MAmethod,Stochastic_1_PriceField,MODE_MAIN,i);
      bufStoch2[i]=iStochastic(Symbol(),Period(),
                               Stochastic_2_Period_K,Stochastic_2_Period_D,Stochastic_2_Slowing,
                               Stochastic_2_MAmethod,Stochastic_2_PriceField,MODE_MAIN,i);
      bufRSI[i]=bufRSI[i]-threshold;
      bufStoch1[i]=bufStoch1[i]-threshold;
      bufStoch2[i]=bufStoch2[i]-threshold;
                               
      //--- histograms
      bufHistUP[i]=EMPTY_VALUE;
      bufHistDN[i]=EMPTY_VALUE;
      bufHistNO[i]=EMPTY_VALUE;
      if(bufRSI[i]>limit && bufStoch1[i]>limit && bufStoch2[i]>limit)
         bufHistUP[i]=bufStoch2[i];
      else
      if(bufRSI[i]<limit && bufStoch1[i]<limit && bufStoch2[i]<limit)
         bufHistDN[i]=bufStoch2[i];
      else
         bufHistNO[i]=bufStoch2[i];
     }

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

smTMMS Oscillator.JPG


thank you in advance

Best regards
rch05000
 
Posts: 37
Joined: Wed Nov 23, 2011 8:05 am



Return to Indicator and Signal Requests

Who is online

Users browsing this forum: No registered users and 17 guests