//+------------------------------------------------------------------+ //| Repulse.mq4 | //| FCognet | //| | //+------------------------------------------------------------------+ //mod2009fxtsd #property copyright "Eric Lefort" #property link "http://www.pro-at.com" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Gray #property indicator_color2 Yellow #property indicator_color3 Aqua //---- input parameters extern int RepulsePeriod1=1; extern int RepulsePeriod2=5; extern int RepulsePeriod3=15; extern int TimeFrame = 0; extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; //---- buffers double RepulseBuffer1[]; double RepulseBuffer2[]; double RepulseBuffer3[]; double PosBuffer[]; double NegBuffer[]; string IndicatorFileName; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexBuffer(0,RepulseBuffer1); SetIndexBuffer(1,RepulseBuffer2); SetIndexBuffer(2,RepulseBuffer3); SetIndexBuffer(3,PosBuffer); SetIndexBuffer(4,NegBuffer); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); SetLevelValue(0,0); SetLevelStyle(STYLE_DOT,0,DimGray); TimeFrame = MathMax(TimeFrame,Period()); string short_name; short_name="Repulse("+RepulsePeriod1+", "+RepulsePeriod2+", "+RepulsePeriod3+") M"+TimeFrame ; IndicatorShortName(short_name); IndicatorFileName = WindowExpertName(); //---- return(0); } //+------------------------------------------------------------------+ //| iteration function | //+------------------------------------------------------------------+ int start() { double forceHaussiere, forceBaissiere; int index = 0; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit = Bars - counted_bars; if (TimeFrame != Period()) { limit = MathMax(limit,TimeFrame/Period()); for(index=0, int y=0; index<limit; index++) { y = iBarShift(NULL,TimeFrame,Time[index]); RepulseBuffer1[index] = iCustom(NULL,TimeFrame,IndicatorFileName,RepulsePeriod1,RepulsePeriod2,RepulsePeriod3,0,y); RepulseBuffer2[index] = iCustom(NULL,TimeFrame,IndicatorFileName,RepulsePeriod1,RepulsePeriod2,RepulsePeriod3,1,y); RepulseBuffer3[index] = iCustom(NULL,TimeFrame,IndicatorFileName,RepulsePeriod1,RepulsePeriod2,RepulsePeriod3,2,y); } return(0); } // Repulse1 //for(index=0;index<Bars;index++) for(index=limit; index>=0; index--)if(Close[index]!=0){ PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod1))-Open[index])/Close[index])*100); NegBuffer[index] = (((Open[index]+(2*getHigh(index, RepulsePeriod1))-(3*Close[index]))/Close[index])*100); } //for(index=0;index<limit;index++) { for(index=limit; index>=0; index--){ forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod1 * 5, 0, MODE_EMA, index); forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod1 * 5, 0, MODE_EMA, index); RepulseBuffer1[index]=forceHaussiere-forceBaissiere; } // Repulse2 //for(index=0;index<limit;index++) { for(index=limit; index>=0; index--)if(Close[index]!=0){ PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod2))-Open[index+RepulsePeriod2])/Close[index])*100); NegBuffer[index] = (((Open[index+RepulsePeriod2]+(2*getHigh(index, RepulsePeriod2))-(3*Close[index]))/Close[index])*100); } //for(index=0;index<limit;index++) { for(index=limit; index>=0; index--){ forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod2 * 5, 0, MODE_EMA, index); forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod2 * 5, 0, MODE_EMA, index); RepulseBuffer2[index]=forceHaussiere-forceBaissiere; } // Repulse3 //for(index=0;index<limit;index++) { for(index=limit; index>=0; index--)if(Close[index]!=0) { PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod3))-Open[index+RepulsePeriod3])/Close[index])*100); NegBuffer[index] = (((Open[index+RepulsePeriod3]+(2*getHigh(index, RepulsePeriod3))-(3*Close[index]))/Close[index])*100); } //for(index=0;index<limit;index++) { for(index=limit; index>=0; index--){ forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod3 * 5, 0, MODE_EMA, index); forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod3 * 5, 0, MODE_EMA, index); RepulseBuffer3[index]=forceHaussiere-forceBaissiere; } return(0); } //+------------------------------------------------------------------+ double getLow(int from, int period) { double low = 9999999999; for (int index=from; index<=from+period; index++) { if (low > Low[index]) { low = Low[index]; } } return (low); } double getHigh(int from, int period) { double high = 0; for (int index=from; index<=from+period; index++) { if (high < High[index]) { high = High[index]; } } return (high); }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Series array that contains open prices of each bar
Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
IndicatorFileName
Order Management characteristics:
Other Features: