
請問一下,我想寫一隻均線 20ma < 10ma < 5ma 的選股程式,寫完遇到欄位長度不夠。
看了錯誤商品,有些卻有足夠的長度。以下為程式碼。
input: shortlength(5); setinputname(1,"短期均線期數"); input: midlength(10); setinputname(2,"中期均線期數"); input: Longlength(20); setinputname(3,"長期均線期數"); variable: shortaverage(0); variable: midaverage(0); variable: Longaverage(0); variable: shortaverage1(0); variable: midaverage1(0); variable: Longaverage1(0); shortaverage = average(close,shortlength); midaverage = average(close,midlength); Longaverage = average(close,Longlength); shortaverage1 = average(close[1],shortlength); midaverage1 = average(close[1],midlength); Longaverage1 = average(close[1],Longlength); condition1 = shortaverage > midaverage; condition2 = midaverage > Longaverage; condition3 = shortaverage1 < shortaverage; condition4 = midaverage1 < midaverage; condition5 = Longaverage1 < Longaverage; if condition1 and condition2 and condition3 and condition4 and condition5 then ret = 1;
4 評論