//+------------------------------------------------------------------+ //| Stochastic 4H.mq4 | //| Copyright © 2007, lukas1 | //| Àâòîðñêîå ïðàâî: Ëóêàøóê Âèêòîð Ãåííàäüåâè÷ //| Stochastic from all timeframe //| 16 ôåâðàëÿ 2007ã. âåðñèÿ v.02 èñïðàâëåí ðàñ÷åò ñðåäíåé //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, lukas1" //---- indicator settings #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 MediumPurple #property indicator_color2 Red #property indicator_width1 2 //---- indicator parameters extern int KPeriod=5; extern int DPeriod=3; extern int Slowing=3; extern int Mode_ma = 0; // Ìåòîä óñðåäíåíèÿ /*MODE_SMA 0 Ïðîñòîå ñêîëüçÿùåå ñðåäíåå MODE_EMA 1 Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå MODE_SMMA 2 Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå MODE_LWMA 3 Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå */ extern int VarPeriod=240; //old timeframe //PERIOD_M5 5 5 minutes //PERIOD_M15 15 15 minutes //PERIOD_M30 30 30 minutes //PERIOD_H1 60 1 hour //PERIOD_H4 240 4 hours //PERIOD_D1 1440 1 day //PERIOD_W1 10080 1 week //PERIOD_MN1 43200 1 month extern int AppliedPrice=0;//Îäíà èç ñëåäóþùèõ âåëè÷èí: 0-Low/High èëè 1-Close/Close. //---- indicator buffers double Buffer0[],Buffer1[]; int p; // current period int k; // repetition factor old timeframe //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetIndexStyle(0, DRAW_LINE); SetIndexStyle(1, DRAW_LINE); SetIndexStyle(2, 12); SetIndexStyle(3, 12); SetIndexDrawBegin(0, DPeriod); SetIndexDrawBegin(1, DPeriod); IndicatorDigits(Digits + 1); //---- indicator buffers mapping SetIndexBuffer(0, Buffer0); SetIndexBuffer(1, Buffer1); //---- name for DataWindow and indicator subwindow label IndicatorShortName("Stoch 4H (" + KPeriod + "," + DPeriod + "," + Slowing + ", " + VarPeriod + "min)"); SetIndexLabel(0, "Stoch 4H(" + VarPeriod + ")"); SetIndexLabel(1, "Signal 4H(" + VarPeriod + ")"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Stochastic for old timeframe | //+------------------------------------------------------------------+ int start() { int i, limit; int counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); if(counted_bars <= DPeriod) limit = Bars - DPeriod ; else limit = Bars - counted_bars; p = Period(); k = VarPeriod/p; // repetition factor old timeframe i=limit-1; while (i>=0) { int bb=HighBar(Symbol(), 0, i, VarPeriod); // definition of HighBar, having symbol, lowTF, // and bar's number in lowTF, calculated highTF; // (symbol, lowTF, bar's number, highTF) if (bb==-1) continue; Buffer0[i] =iStochastic(Symbol(),VarPeriod,KPeriod,DPeriod,Slowing,Mode_ma,AppliedPrice,0,bb); Buffer1[i]=iStochastic(Symbol(),VarPeriod, KPeriod,DPeriod,Slowing,Mode_ma,AppliedPrice,1,bb); i--; } //---- done return(0); } //+------------------------------------------------------------------+ int HighBar(string symbol,int TFLow,int BarLow,int TFHigh) // definition of HighBar, having symbol, lowTF, // and bar's number in lowTF, calculated highTF; // (symbol, lowTF, bar's number, highTF) { datetime BarTimeLow=iTime(symbol, TFLow, BarLow); // time's value of bar means in BarLow int error=GetLastError(); if(error==4066) return (-1); int res=iBarShift(symbol, TFHigh, BarTimeLow, false);// displacement of bar means in BarTimeLow error=GetLastError(); if(error==4066) return (-1); return (res); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type 12
Indicators Used:
Stochastic oscillator
Custom Indicators Used:
Order Management characteristics:
Other Features: