谁能帮我做个wrosc指标?
发布网友
发布时间:2022-05-10 18:49
我来回答
共1个回答
热心网友
时间:2023-10-22 19:05
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_width1 2
#property indicator_width2 2
#property indicator_level1 25
#property indicator_level2 75
//
//
//
//
//
extern int PeriodRSV = 13;
extern int PeriodStoch= 8;
extern int PeriodSK = 5;
extern int PeriodSD = 5;
// 0 = MA
// 1 - EMA
// 2 - SMMA
// 3 - LWMA
extern int MAMode=0;
//
//
//
//
//
double SK[];
double SD[];
double StoRSV[];
double RSV[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexBuffer(0,SK);
SetIndexBuffer(1,SD);
SetIndexBuffer(2,StoRSV);
SetIndexBuffer(3,RSV);
IndicatorShortName("WROSC ("+PeriodRSV+","+PeriodStoch+","+PeriodSK+","+PeriodSD+")");
return(0);
}
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i,limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit=Bars-counted_bars;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
double dMaxHigh=High[Highest(NULL,0,MODE_HIGH,PeriodRSV,i)];
double dMinLow=Low[Lowest(NULL,0,MODE_LOW,PeriodRSV,i)];
RSV[i]=-100*(dMaxHigh-Close[i])/(dMaxHigh-dMinLow);
double LLV = RSV[ArrayMinimum(RSV,PeriodStoch,i)];
double HHV = RSV[ArrayMaximum(RSV,PeriodStoch,i)];
if ((HHV-LLV)!=0)
StoRSV[i] = 100.0*((RSV[i] - LLV)/(HHV - LLV));
else StoRSV[i] = 0;
}
for(i=limit; i>=0; i--) SK[i]=iMAOnArray(StoRSV,0,PeriodSK,0,MAMode,i);
for(i=limit; i>=0; i--) SD[i]=iMAOnArray( SK,0,PeriodSD,0,MAMode,i);
return(0);