外汇论坛 外兔财经

开启左侧

请问有编程高手能帮一下吗?

[复制链接]
发表于 2005-7-12 01:41 | 显示全部楼层 |阅读模式
https://www.y2cn.com
我有个在mt3.83上的自编指标,在mt4.0上调不出来了,哪位高手能帮我一下吗?先谢过了

指标如下:
/*[[
Name := RSI MA
Author := Copyright ?2003, Fostar
Link := fostar_fx@yahoo.com
Separate Window := Yes
First Color := Lime
First Draw Type := Line
First Symbol := 217
Use Second Data := Yes
Second Color := Red
Second Draw Type := Line
Second Symbol := 218
]]*/

Inputs:
RsiPeriod(14),
Price_C_O_H_L_M_T_W(0), //0..6
/*
PRICE_CLOSE - 0
PRICE_OPEN - 1
PRICE_HIGH - 2
PRICE_LOW - 3
PRICE_MEDIAN - 4
PRICE_TYPICAL - 5
PRICE_WEIGHTED - 6
*/


MAPeriod(8),
MAType_Simp_E_Smo_W(0), //0..3

/*
MODE_SMA - 0
MODE_EMA - 2
MODE_SMMA - 2
MODE_WMA - 3
*/


MAShift(0),
BarsCount(300);

Variable : shift(0), value(0), sum(0), n(0), MA(0), bars_(0), smconst(0), prev(0);
Variable: weight(0), linear(0);

SetLoopCount(0);

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

smconst = 2 / (1 + MAPeriod);


For shift = bars_-1 Downto 0 Begin

value = iRSIEx(RsiPeriod, 1, Price_C_O_H_L_M_T_W, MODE_FIRST, shift);

SetIndexValue(shift, value);

if (shift < bars_ - (RsiPeriod + MAPeriod + MAShift)) and (MAPeriod > 1) then begin

Switch MAType_Simp_E_Smo_W
Begin
case 0://Simple
sum = 0;
for n = 0 to MAPeriod -1 begin
sum = sum + GetIndexValue(shift + n + MAShift);
end;
MA = sum/MAPeriod;
SetIndexValue2(shift, MA);

case 1://Exponential
prev = GetIndexValue2(shift + 1 - MAShift);
MA = smconst * (value - prev) + prev;
SetIndexValue2(shift - MAShift, MA);

case 2://Smoothed
If shift = bars_ - MAPeriod Then Begin
sum = 0;
For n = 0 To MAPeriod-1 Begin
sum = sum + GetIndexValue(shift+n + MAShift);
End;
End
Else Begin
prev = GetIndexValue2(shift + 1);
sum = prev*MAPeriod - prev + GetIndexValue(shift + MAShift);
End;
MA = sum/MAPeriod;
SetIndexValue2(shift, MA);

case 3: //Linear weighted
sum = 0; weight = 0; linear = MAPeriod;
For n = 0 To MAPeriod-1 Begin
sum = sum + GetIndexValue(shift + n + MAShift) * linear;
weight = weight + linear;
linear = linear - 1;
End;
MA = sum/weight;
SetIndexValue2(shift, MA);

default://Simple
sum = 0;
for n = 0 to MAPeriod -1 begin
sum = sum + GetIndexValue(shift + n + MAShift);
end;
MA = sum/MAPeriod;
SetIndexValue2(shift, MA);
end;

end;
End;

[ 本帖最后由 bluse1 于 2005-7-12 01:46 编辑 ]。
 楼主| 发表于 2005-7-12 11:52 | 显示全部楼层
顶一下,哪位高手能帮我改一下呀~~~~。

本版积分规则

QQ|手机版 Mobile Version|Archiver|关于我们 About Us|联系我们 Contact Us|Y2外汇论坛 外兔财经

GMT+8, 2025-8-18 14:50 , Processed in 0.035960 second(s), 23 queries .

Powered by Discuz! X7.2

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表