[求助]指标编写 (文华财经wh9)

投资者咨询:[求助]指标编写 (文华财经wh9)
来源:文华财经  日期:2018-7-6 20:11
       

老师好,写一个MQ指标:

取当前K线前 N根K线中的最高价H,最低价L,最高收盘价HC,

W=(H+L+2*HC)/4 

R=2W-L
S=2W-H

由每根K线R  S组成类似布林带上下轨的指标, 当前K线总是显示前一根K线的R 、S , 
 
投资者咨询:[求助]指标编写 (文华财经wh9)
来源:文华财经  日期:2018-7-6 20:11
 
技术人员回复
日期:2018-7-6 20:27
Params
Numeric N(10);
Vars
NumericSeries W;
NumericSeries R;
NumericSeries S;

Begin
W=Ref((HHV(High,N)+LLV(Low,N)+2*HHV(Close,N)),1)/4;
R=W-Ref(Low,1)+Close;
S=Close-W+Ref(High,1);

PlotNumeric("R",R);
PlotNumeric("S",S);
End
投资者咨询:[求助]指标编写 (文华财经wh9)
来源:文华财经  日期:2018-7-6 20:11
 R=W-Ref(Low,1)+Close;
S=Close-W+Ref(High,1);



W=(H+L+2*HC)/4 

R=2W-L
S=2W-H

写错了  是2W

技术人员回复
日期:2018-7-6 21:18
 

Params
Numeric N(10);
Vars
NumericSeries W;
NumericSeries R;
NumericSeries S;

Begin
W=Ref((HHV(High,N)+LLV(Low,N)+2*HHV(Close,N)),1)/4;
R=2*W-Ref(Low,1);
S=2*W-Ref(High,1);

PlotNumeric("R",R);
PlotNumeric("S",S);
End

投资者咨询:[求助]指标编写 (文华财经wh9)
来源:文华财经  日期:2018-7-6 20:11
  
MC(MultiCharts)平台上的源码,可以直接在MQ上使用吗

//rb.index,Daily,default param
//i.index,Daily,param=35,0.5,1
inputs: Len(35),Dev(2),type(0);
variables: ma(0),std(0),up(0),down(0);

ma = AverageFC(Close,Len);
std = StandardDev(Close, Len,1); //StandardDev( Close, Period, 1 ) ;
up = ma + Dev * std;
down = ma - Dev * std;

if(type=0) then
begin
    if(marketposition=0 and close>up) then
    begin
        buy("b") next bar at market;
    end;

    if(marketposition=0 and close<down) then
    begin
        sellshort("s") next bar at market;
    end;
    if(marketposition>0 and close<ma) then sell("sp") next bar at market;
    if(marketposition<0 and close>ma) then buytocover("bp") next bar at market;
end
else
begin
    if(marketposition=0) then
    begin
        buy("b2") next bar at up stop;
        sellshort("s2") next bar at down stop;
    end;    
    if(marketposition>0) then sell("sp2") next bar at ma stop;
    if(marketposition<0) then buytocover("bp2") next bar at ma stop;
end;
技术人员回复
日期:2018-7-6 21:34
如下即可

Params
Numeric Len1(35);
Numeric Dev(2);
Numeric type(0);
Vars
NumericSeries MA1;
NumericSeries std1;
NumericSeries up;
NumericSeries down ;
Begin
MA1 = AverageFC(Close,Len1);
std1 = StandardDev(Close, Len1,1); 
up = MA1+ Dev * std1;
down = MA1 - Dev * std1;

if(marketposition==0 and close>up) 
        buy;
    if(marketposition==0 and close<down)
        sellshort;
    if(marketposition>0 and close<MA1) sell;
    if(marketposition<0 and close>MA1)  buytocover;

end