以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  高级功能研发区  (http://weistock.com/bbs/list.asp?boardid=5)
----  vbs如何向公式系统传递数组  (http://weistock.com/bbs/dispbbs.asp?boardid=5&id=11482)

--  作者:macro
--  发布时间:2012/5/4 9:42:16
--  vbs如何向公式系统传递数组

vbs中有如下类型数据,如何向金字塔公式系统传递?

dc := 1000;
VARIABLE:openPrice2[dc]=0;
<%

vOpenPrice2 = ffl.vardata("openPrice2")


\'对vOpenPrice2数组中每个元素进行计算处理并赋值

\'......

 

ffl.vardata("openPrice2") = vOpenPrice2

%>

 

请问以上写法正确吗?


--  作者:王锋
--  发布时间:2012/5/4 9:45:06
--  
测试一下不就知道了,用MSGBOX打印看看传递过去的数据是否是数组
--  作者:macro
--  发布时间:2012/5/4 9:52:09
--  

openPrice := open;
highPrice := high;
lowPrice := low;
closePrice := close;
dc := 1000;
VARIABLE:openPrice2[dc]=0,highPrice2[dc]=0,lowPrice2[dc]=0,closePrice2[dc]=0;
<%
vOpenPrice = ffl.vardata("openPrice")
vHighPrice = ffl.vardata("highPrice")
vLowPrice = ffl.vardata("lowPrice")
vClosePrice = ffl.vardata("closePrice")
last = ubound(vOpenPrice)
vo = 0
vh = 0
vl = 0
vc = 0
i = 1
j = 0
dim openPriceArray(1000)
dim highPriceArray(1000)
dim lowPriceArray(1000)
dim closePriceArray(1000)
do while(i <= last)
  if ((vOpenPrice(i) > vClosePrice(i)) and (vOpenPrice(i-1) < vClosePrice(i-1))) then \'前面一根是阳线,后面连续阴线 
  vo = vOpenPrice(i)
  vh = vHighPrice(i)
  vl = vLowPrice(i)
  vc = vClosePrice(i) 
  i = i + 1 
  do until ((vOpenPrice(i+1) < vClosePrice(i+1)) or (i > 1000)) \'连续阴线直到遇到阳线为止
    vc = vClosePrice(i)   
    if (vHighPrice(i) > vh) then
      vh = vHighPrice(i)
    end if   
    if (vLowPrice(i) < vl) then
      vl = vLowPrice(i)
    end if   
    i = i + 1 
  loop 
  openPriceArray(j) = vo
  highPriceArray(j) = vh
  lowPriceArray(j) = vl
  closePriceArray(j) = vc 
  j = j + 1       
  end if
  if ((vOpenPrice(i) < vClosePrice(i)) and (vOpenPrice(i-1) > vClosePrice(i-1))) then \'前面一根是阴线,后面连续阳线 
  vo = vOpenPrice(i)
  vh = vHighPrice(i)
  vl = vLowPrice(i)
  vc = vClosePrice(i) 
  i = i + 1 
  do until ((vOpenPrice(i+1) > vClosePrice(i+1)) or (i > 1000)) \'连续阳线直到遇到阴线为止
    vc = vClosePrice(i)   
    if (vHighPrice(i) > vh) then
      vh = vHighPrice(i)
    end if   
    if (vLowPrice(i) < vl) then
      vl = vLowPrice(i)
    end if   
    i = i + 1 
  loop 
  openPriceArray(j) = vo
  highPriceArray(j) = vh
  lowPriceArray(j) = vl
  closePriceArray(j) = vc 
  j = j + 1       
  end if 
loop
ffl.vardata("openPrice2") = openPriceArray
ffl.vardata("highPrice2") = highPriceArray
ffl.vardata("lowPrice2") = lowPriceArray
ffl.vardata("closePrice2") = closePriceArray
%>
//KLINE(openPrice,highPrice,lowPrice,closePrice,1);
KLINE(openPrice2,highPrice2,lowPrice2,closePrice2,1);

采用这种方式,编译通不过,提示“未定义的变量:OPENPRICE2”!请问问题出在哪儿了?

 


--  作者:王锋
--  发布时间:2012/5/4 18:02:35
--  

你的数组用法是有问题的,因为定义的数组与序列变量还是有些区别

 

openPrice2:=c;
highPrice2:=c;
lowPrice2:=c;
closePrice2:=c;

 

你这样定义这4个变量为序列变量酒可以解决了