dracula0911 發表於 11-11-28 02:46

可以請教各位高手multicharts程式寫法的問題...

各位高手好,小弟剛開始學著寫multicharts程式
有一個問題
不知道如何寫,拜求高手們指導
想法如下
Inputs:FAST(30),SLOW(60);
vars:OK(0);

if Time=0850 then begin
OK=OPEND(0);
FAST=Average(close,FAST);
SLOW=Average(close,SLOW);
end;

//===============Long/Short======================
if OK>FAST and OK>SLOW then goto ==A== ;

if OK<FAST and OK<SLOW then goto ==B== ;

//===============A======================
if marketposition=0 then
buy("Entry_B") next bar market;

if marketposition>0 and close crosses under Average(close,FAST) then
sell("EXIT_B") next bar at market;

goto ==trading End ==

//===============B======================
if marketposition=0 then
sellshort("Entry_S") next bar market;

if marketposition<0 and close crosses above Average(close,SLOW) then
buytocover ("EXIT_S") next bar at market;

goto ==trading End ==

//=================trading End ========================
if time>=1325 then begin
sell next bar at market;
buytocover next bar at market;
end;

請教紅字的部份應該怎麼寫才對?

圖示可能較清楚


先謝謝大家~~

TrendRover 發表於 11-11-28 05:06

本帖最後由 TrendRover 於 11-11-28 05:41 AM 編輯

不知這樣如何?
........................................................
~~~~~~~~~~~~~~~~~~~~~~~~
vars:Direction(0),OrderSendFinish(0);
While OrderFinish= 0 Begin
//===============Long/Short======================
if OK>FAST and OK>SLOW then Direction =1 ;

if OK<FAST and OK<SLOW then Direction=-1 ;

//===============A======================
if marketposition=0and Direction =1 then
buy("Entry_B") next bar market; //add OrderSendFinish=1 here

if marketposition>0 and close crosses under Average(close,FAST)and Direction=1 then
sell("EXIT_B") next bar at market;//add OrderSendFinish=1 here

while OrderSendFinish =1 Begin //開始天下大亂了!!

//===============B======================
if marketposition=0 And Direction =-1 then
sellshort("Entry_S") next bar market;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...........
..................................

TrendRover 發表於 11-11-28 05:31

本帖最後由 TrendRover 於 11-11-28 05:41 AM 編輯

你安排的goto end自己類推:
不要用 fortran BASIC 的老東西把自己綁死!!!
你會很難活,因為goto 早該進博物館冰起來.

TrendRover 發表於 11-11-28 05:34

回復 1# dracula0911

你是DRC/LPE的programmer嗎? dracula 是cadence tool for DRC ?
0911不要亂取 ,USA很敏感.

TrendRover 發表於 11-11-28 05:36

讓我想起了打孔卡的年代很不好玩的年代計算機CDCXXXX
頁: [1]
查看完整版本: 可以請教各位高手multicharts程式寫法的問題...