Light Style© by Fisana

Перейти к содержимому


РАММ сервис NordFx: копируй сделки лучших трейдеров форекс


NordFX

Фотография

индикатор Трендового цикла Шафф ( STC )


  • Пожалуйста, авторизуйтесь, чтобы ответить
2 ответов в этой теме

#1 Tэд

Tэд

    живет тут

  • Пользователи ST test (off)
  • PipPipPipPipPip
  • 1 211 сообщений

Опубликовано 20 Июль 2009 - 11:44

Всем привет! помогите, пожалуйста, перевести на человеческий язык алгоритм данного индикатора, мне необходимо перепрограммировать его на язык метастока.



//+------------------------------------------------------------------+
//| Schaff Trend Cycle.mq4 |
//| Ramdass - Conversion only |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, FostarFX."
#property link "mail: fostar_fx@yahoo.com"

#property indicator_separate_window
#property indicator_minimum -10
#property indicator_maximum 110
#property indicator_buffers 1
#property indicator_color1 DarkOrchid

//---- input parameters
extern int MAShort=23;
extern int MALong=50;
extern double Cycle=10;
extern int CountBars=300;
//---- buffers
double MA[];
double ST[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
// string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexBuffer(0, MA);
SetIndexBuffer(1, ST);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,DarkOrchid);

//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Schaff Trend Cycle |
//+------------------------------------------------------------------+
int start()
{
SetIndexDrawBegin(0,Bars-CountBars+MALong+MAShort+1);
int shift,u,counted_bars=IndicatorCounted();
double MCD, LLV, HHV, MA_Short, MA_Long, sum ,prev, smconst;
int n, i, s;
bool check_begin=false, check_begin_MA=false;
double MCD_Arr[100];

if(Bars<=MALong) return(0);
if (CountBars==0) CountBars=Bars;
//---- initial zero
if(counted_bars<MALong+MAShort)
{
for(i=1;i<=MALong;i++) MA[Bars-i]=0.0;
for(i=1;i<=MALong;i++) ST[Bars-i]=0.0;
}
//----
shift=CountBars-MALong-1;
// if(counted_bars>=MALong) shift=Bars-counted_bars-1;

check_begin = false;
check_begin_MA = false;
n = 1;
s = 1;
smconst = 2 / (1 + Cycle/2);

while(shift>=0)
{
MA_Short = iMA(NULL,0,MAShort,0, MODE_EMA, PRICE_TYPICAL, shift);
MA_Long = iMA(NULL,0,MALong,0, MODE_EMA, PRICE_TYPICAL, shift);
MCD_Arr[n] = MA_Short - MA_Long;
MCD = MA_Short - MA_Long;

if (n >= Cycle)
{
n = 1; check_begin = true; } else {n = n + 1;}

if (check_begin)
{
for (i = 1; i<=Cycle; i++)
{
if (i == 1) {LLV = MCD_Arr;}
else {
if (LLV > MCD_Arr) LLV = MCD_Arr;
}

if (i == 1) {HHV = MCD_Arr;}
else {
if (HHV < MCD_Arr) HHV = MCD_Arr;
}
}
ST[shift] = ((MCD - LLV)/(HHV - LLV))*100 + 0.01;
s = s + 1;
if (s >= (Cycle)/2)
{
s = 1;
check_begin_MA = true;
}
} else {ST[shift] = 0;}
if (check_begin_MA) {
prev = MA[shift + 1];
MA[shift] = smconst * (ST[shift] - prev) + prev; }

shift--;
}

return(0);
}
//+------------------------------------------------------------------+
удача улыбается подготовленному рассудку. /Гамелуш В.А./
С уважением, Эдуард.
malabaev_eduard-skype

#2 fxxx

fxxx

    пробегал

  • Пользователи
  • Pip
  • 1 сообщений

Опубликовано 22 Сентябрь 2009 - 04:38

немного о сути (от автора)
+хотя должна быть куча описаний в нете

Releasing the Code to the Schaff Trend Cycle
By Doug Schaff, CEO FX-Strategy.com

Вложенные файлы


Сообщение изменено: fxxx, 22 Сентябрь 2009 - 04:41 .


#3 ZIGANI

ZIGANI

    пробегал

  • Пользователи
  • Pip
  • 2 сообщений

Опубликовано 03 Апрель 2010 - 10:28

Код написан с ошибками не if (i == 1) {LLV = MCD_Arr;} а if (i == 1) {LLV = MCD_Arr[i];} // и так везде без [i].

Размещенное изображение


Индикаторы для MetaStock - Oscillator - Schaff Trend Cycle by Jose Silva
hxxp://www.virtuosclub.ru/main/ind/M/macdoscillatorschafftrendcyclebyjosesilva

/*[[
	Name := Schaff Trend Cycle
	Author := Copyright © 2004, FostarFX
	link := "mail: fostar_fx@yahoo.com"
	Separate Window := Yes
	First Color := Lime
	First Draw Type := Line
	First Symbol := 217
	Use Second Data := No
	Second Color := Red
	Second Draw Type := Line
	Second Symbol := 218
	Minimum Chart Limits := -10.000000
	Maximum Chart Limits := 110.000000	
]]*/

Inputs: MAShort(23), MALong(50), Cycle(10), BarsCount(300);

Variable : 
	shift(0), 
	MCD(0), LLV(0), HHV(0), 
	n(0), i(0), s(0), 
	MA_Short(0), MA_Long(0), ST(0), 
	
	check_begin(false), 
	check_begin_MA(false), 
		
	sum(0), MA(0), prev(0), 
	smconst(0), 
	bars_(0);
	
Array : MCD_Arr[100](0); 

SetLoopCount(0);

check_begin = false;
check_begin_MA = false;
n = 1;
s = 1;
smconst = 2 / (1 + Cycle/2);

if BarsCount > 0 then {
	if BarsCount > Bars then {bars_ = Bars;}
	else {bars_ = BarsCount;}
}
else {bars_ = Bars;};

For shift= bars_ Downto 0 Begin
	MA_Short = iMAEx(MAShort, MODE_EMA, 0, PRICE_TYPICAL, shift);
	MA_Long = iMAEx(MALong, MODE_EMA, 0, PRICE_TYPICAL, shift);
	MCD_Arr[n] = MA_Short - MA_Long;
	MCD = MA_Short - MA_Long;

	if n >= Cycle then 
	Begin	
		n = 1;
		check_begin = true;
	end else 
		n = n + 1;
	
	if check_begin then 
	begin
		for i = 1 to Cycle 
		Begin	
			if i = 1 then LLV = MCD_Arr[i]
			else begin
				if LLV > MCD_Arr[i] then LLV = MCD_Arr[i];
			end;
			
			if i = 1 then HHV = MCD_Arr[i]
			else begin
				if HHV < MCD_Arr[i] then HHV = MCD_Arr[i];
			end;					
		end;
		ST = ((MCD - LLV)/(HHV - LLV))*100 + 0.01;
		s = s + 1;
		if s >= (Cycle)/2 then 
		Begin 
			s = 1;
			check_begin_MA = true;
		end;
	end
	else ST = 0;
	if check_begin_MA then begin	
		prev = GetIndexValue(shift + 1);
		MA = smconst * (ST - prev) + prev;	
		SetIndexValue(shift, MA);
	end;
End;

Сообщение изменено: ZIGANI, 03 Апрель 2010 - 10:34 .





Посетителей, читающих эту тему: 0

0 пользователей, 0 гостей, 0 анонимных пользователей

Рейтинг брокеров форекс: кто лидер, кто аутсайдер и почему?




Masterforex-V NordFX

Rambler's Top100

Принимаем Z-Payment