TrendForce_3

Author: Copyright � 2009, Bookkeeper
TrendForce_3
Indicators Used
Moving average indicatorCommodity channel indexMACD HistogramMovement directional indexBulls Power indicator Bears Power indicatorStochastic oscillatorRelative strength indexForce indexMomentum indicatorDeMarker indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
TrendForce_3
//+------------------------------------------------------------------+
//|                                                 TrendForce_3.mq4 |
//+------------------------------------------------------------------+
//| Ðàñ÷åò ñèëû òåíäåíöèè äâèæåíèÿ íà ðûíêå, íàáîð èíäèêàòîðîâ è èõ
//| ïàðàìåòðû ïîëíîñòüþ âçÿòû èç:
//| -----------------------------------------------------------------+
//|                   FerruFx_Multi_info+_light_chart_v1.1-Ndisc.mq4 |
//|                                        Copyright © 2007, FerruFx |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Bookkeeper"
#property link      "yuzefovich@gmail.com"


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  Green
#property indicator_color2  Red

#property indicator_minimum -50
#property indicator_maximum 50
#property indicator_level1 25.0
#property indicator_level2 -25.0

extern int MaxBars = 500;

//---- Indicators parameters
//---- Moving Average Settings
int       FastMAPeriod          = 20;  // Fast Moving Average period
int       MediumMAPeriod        = 50;  // Medium Moving Average period
int       SlowMAPeriod          = 100;  // Slow Moving Average period
int       MAMethod              = MODE_EMA;  // Moving Average method
int       MAPrice               = PRICE_CLOSE;  // Moving Average price
//---- CCI Settings
int       CCIPeriod             =           14;  // Commodity Channel Index  period
int       CCIPrice              =  PRICE_CLOSE;  // CCI price
//---- MACD Settings
int       MACDFast              =           12;  // MACD fast EMA period
int       MACDSlow              =           26;  // MACD slow EMA period
int       MACDSignal            =            9;  // MACD signal SMA period
//---- ADX Settings ===";
int       ADXPeriod             =           14;  // Average Directional movement  period
int       ADXPrice              =  PRICE_CLOSE;  // ADX price
//---- BULLS Settings ===";
int       BULLSPeriod           =           13;  // Bulls Power  period
int       BULLSPrice            =  PRICE_CLOSE;  // Bulls Power price
//---- BEARS Settings ===";
int       BEARSPeriod           =           13;  // Bears Power  period
int       BEARSPrice            =  PRICE_CLOSE;  // Bears Power price
//---- STOCHASTIC Settings ===";
int       STOKPeriod            =            5;  // Stochastic %K  period
int       STODPeriod            =            3;  // Stochastic %D  period
int       STOSlowing            =            3;  // Stochastic slowing
//---- RSI Settings ===";
int       RSIPeriod             =           14;  // RSI  period
//---- FORCE INDEX Settings ===";
int       FIPeriod              =           14;  // Force Index period
int       FIMethod              =     MODE_SMA;  // Force Index method
int       FIPrice               =  PRICE_CLOSE;  // Force Index price
//---- MOMENTUM INDEX Settings ===";
int       MOMPeriod             =           14;  // Momentum period
int       MOMPrice              =  PRICE_CLOSE;  // Momentum price
//---- DeMARKER Settings ===";
int       DEMPeriod             =           14;  // DeMarker  period

double UpForce_Buffer[];
double DnForce_Buffer[];

int TF[7]={PERIOD_D1,
           PERIOD_H4,
           PERIOD_H1,
           PERIOD_M30,
           PERIOD_M15,
           PERIOD_M5,
           PERIOD_M1};

//+------------------------------------------------------------------+
int init()
  {
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,UpForce_Buffer);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,DnForce_Buffer);
   
   ObjectCreate("Trend_text", OBJ_LABEL, 0, 0, 0);
   ObjectSetText("Trend_text","Trend Force",9, "System", Blue);
   ObjectSet("Trend_text", OBJPROP_CORNER, 1);
   ObjectSet("Trend_text", OBJPROP_XDISTANCE, 15);
   ObjectSet("Trend_text", OBJPROP_YDISTANCE, 10);
   
   ObjectCreate("Trend_UP_text", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Trend_UP_text", OBJPROP_CORNER, 1);
   ObjectSet("Trend_UP_text", OBJPROP_XDISTANCE, 50);
   ObjectSet("Trend_UP_text", OBJPROP_YDISTANCE, 30);
   
   ObjectCreate("Trend_UP_value", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Trend_UP_value", OBJPROP_CORNER, 1);
   ObjectSet("Trend_UP_value", OBJPROP_XDISTANCE, 15);
   ObjectSet("Trend_UP_value", OBJPROP_YDISTANCE, 30);
   
   ObjectCreate("Trend_DOWN_text", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Trend_DOWN_text", OBJPROP_CORNER, 1);
   ObjectSet("Trend_DOWN_text", OBJPROP_XDISTANCE, 50);
   ObjectSet("Trend_DOWN_text", OBJPROP_YDISTANCE, 45);
   
   ObjectCreate("Trend_DOWN_value", OBJ_LABEL, 0, 0, 0);
   ObjectSet("Trend_DOWN_value", OBJPROP_CORNER, 1);
   ObjectSet("Trend_DOWN_value", OBJPROP_XDISTANCE, 15);
   ObjectSet("Trend_DOWN_value", OBJPROP_YDISTANCE, 45);
   
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("Trend_text");
   ObjectDelete("Trend_UP_text");
   ObjectDelete("Trend_UP_value");
   ObjectDelete("Trend_DOWN_text");
   ObjectDelete("Trend_DOWN_value");
   return(0);
  }
//+------------------------------------------------------------------+
int start()
{
  if( Period() > PERIOD_D1 ) return(0);
  int i, limit, counted_bars=IndicatorCounted();
  
  if (counted_bars<0) return(-1);
  if (counted_bars>0) counted_bars--;
  limit=Bars-counted_bars+1;
  if(limit>MaxBars) limit=MaxBars;
  //if(limit>Bars-SlowMAPeriod-2) limit=Bars-SlowMAPeriod-2;
  for(i=0;i<=limit;i++)
  {
   int shift, SUM_UP=0, SUM_DOUN=0;
   for(int j=0; j<7; j++)
   {
   int TimeFrame=TF[j];
   if(i==0) shift=0;
   else
   {
      if( Period() == TimeFrame ) shift=i;
      if( Period() < TimeFrame ) shift=iBarShift(NULL,TimeFrame,Time[i],false);
      if( Period() > TimeFrame ) shift=iBarShift(NULL,TimeFrame,Time[i-1],false)+1;
   }
   double FastMA_1 = iMA(NULL,TimeFrame,FastMAPeriod,0,MAMethod,MAPrice,shift);
   double FastMA_2 = iMA(NULL,TimeFrame,FastMAPeriod,0,MAMethod,MAPrice,shift+1);
   if ((FastMA_1 > FastMA_2)) SUM_UP++;
   if ((FastMA_1 < FastMA_2)) SUM_DOUN++;
   double MediumMA_1 = iMA(NULL,TimeFrame,MediumMAPeriod,0,MAMethod,MAPrice,shift);
   double MediumMA_2 = iMA(NULL,TimeFrame,MediumMAPeriod,0,MAMethod,MAPrice,shift+1);
   if ((MediumMA_1 > MediumMA_2)) SUM_UP++;
   if ((MediumMA_1 < MediumMA_2)) SUM_DOUN++;
   double SlowMA_1 = iMA(NULL,TimeFrame,SlowMAPeriod,0,MAMethod,MAPrice,shift);
   double SlowMA_2 = iMA(NULL,TimeFrame,SlowMAPeriod,0,MAMethod,MAPrice,shift+1);
   if ((SlowMA_1 > SlowMA_2)) SUM_UP++;
   if ((SlowMA_1 < SlowMA_2)) SUM_DOUN++;
   double cci=iCCI(NULL,TimeFrame,CCIPeriod,CCIPrice,shift);
   if ((cci > 0)) SUM_UP++;
   if ((cci < 0)) SUM_DOUN++; //
   double MACD_m=iMACD(NULL,TimeFrame,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,shift);
   double MACD_s=iMACD(NULL,TimeFrame,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,shift);
   if ((MACD_m > MACD_s)) SUM_UP++;
   if ((MACD_m < MACD_s)) SUM_DOUN++;
   double ADX_plus=iADX(NULL,TimeFrame,ADXPeriod,ADXPrice,MODE_PLUSDI,shift);
   double ADX_minus=iADX(NULL,TimeFrame,ADXPeriod,ADXPrice,MODE_MINUSDI,shift);
   if ((ADX_plus > ADX_minus)) SUM_UP++;
   if ((ADX_plus < ADX_minus)) SUM_DOUN++;
   double bulls=iBullsPower(NULL,TimeFrame,BULLSPeriod,BULLSPrice,shift);
   if ((bulls > 0)) SUM_UP++;
   if ((bulls < 0)) SUM_DOUN++;
   double bears=iBearsPower(NULL,TimeFrame,BEARSPeriod,BEARSPrice,shift);
   if ((bears > 0)) SUM_UP++;
   if ((bears < 0)) SUM_DOUN++;
   double stoch_m=iStochastic(NULL,TimeFrame,STOKPeriod,STODPeriod,STOSlowing,MODE_SMA,1,MODE_MAIN,shift);
   double stoch_s=iStochastic(NULL,TimeFrame,STOKPeriod,STODPeriod,STOSlowing,MODE_SMA,1,MODE_SIGNAL,shift);
   if (stoch_m >= stoch_s) SUM_UP++;
   if (stoch_m < stoch_s) SUM_DOUN++;
   double rsi=iRSI(NULL,TimeFrame,RSIPeriod,PRICE_CLOSE,shift);
   if (rsi >= 50) SUM_UP++;
   if (rsi < 50) SUM_DOUN++;
   double fi=iForce(NULL,TimeFrame,FIPeriod,FIMethod,FIPrice,shift);
   if (fi >= 0) SUM_UP++;
   if (fi < 0) SUM_DOUN++;
   double momentum=iMomentum(NULL,TimeFrame,MOMPeriod,MOMPrice,shift);
   if (momentum >= 100) SUM_UP++;
   if (momentum < 100) SUM_DOUN++;
   double demarker_0=iDeMarker(NULL,TimeFrame,DEMPeriod,shift);
   double demarker_1=iDeMarker(NULL,TimeFrame,DEMPeriod,shift+1);
   if (demarker_0 >= demarker_1) SUM_UP++;
   if (demarker_0 < demarker_1) SUM_DOUN++;
   }
   double v=100.0*SUM_UP/(SUM_UP+SUM_DOUN);
   if(i==0)
   {
   string Trend_UP=DoubleToStr(v,0);
   string Trend_DOWN=DoubleToStr((100.0-v),0);
   ObjectSetText("Trend_UP_text","UP",10, "System", ForestGreen);
   ObjectSetText("Trend_UP_value",Trend_UP+"%",10, "System", ForestGreen);
   ObjectSetText("Trend_DOWN_text","DOWN",10, "System", Red);
   ObjectSetText("Trend_DOWN_value",Trend_DOWN+"%",10, "System", Red);
   }
   v=v-50.0;
   if(v>0) { UpForce_Buffer[i]=v; DnForce_Buffer[i]=0; }
   else    { UpForce_Buffer[i]=0; DnForce_Buffer[i]=v; }
   }
   
   
   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 ---