您現(xiàn)在的位置:程序化交易>> 期貨公式>> 交易開(kāi)拓者(TB)>> 開(kāi)拓者知識(shí)>>正文內(nèi)容

求大神看看跨周期使用是那個(gè)地方出現(xiàn)了問(wèn)題! [開(kāi)拓者 TB]

  • 咨詢內(nèi)容: 代碼如下:
    1、我在日線上插入的是
    Vars
            string strkeydate;
            Numeric D1;
            NumericSeries short1;
        NumericSeries short2;
        NumericSeries media1;
        NumericSeries media2;
        NumericSeries long1;
        NumericSeries long2;

    Begin
       
            short1=(xaverage(Close,4)+average(Close,8)+average(Close,16))/3;
        short2=(xaverage(Close,6)+average(Close,12)+average(Close,24))/3;
        media1=(xaverage(Close,9)+average(Close,18)+average(Close,36))/3;
        media2=(xaverage(Close,13)+average(Close,26)+average(Close,52))/3;
        long1=(xaverage(Close,18)+average(Close,36)+average(Close,72))/3;
        long2=(xaverage(Close,24)+average(Close,48)+average(Close,96))/3;
           
            PlotNumeric("short1",short1,0,white);
        PlotNumeric("short2",short2,0,DarkMagenta);
        PlotNumeric("media1",media1,0,Blue);
        PlotNumeric("media2",media2,0,Green);
        PlotNumeric("long1",long1,0,Yellow);
        PlotNumeric("long2",long2,0,Red);
           
                if(MarketPosition<>1&&short1[1] > short2[1] and short2[1] > media1[1] and media1[1] > media2[1] and media2[1] > long1[1] and long1[1] > long2[1])
            {
                    D1=1;
            }
        if(MarketPosition<>1&&short1[1] < short2[1] and short2[1] < media1[1] and media1[1] < media2[1] and media2[1] < long1[1] and long1[1] < long2[1])
        {
                   
                    D1=2;
            }
           
            strkeydate = DateToString(Date);
            SetTBProfileString2File("f:\\r.log",Symbol,"1and2:"+strkeydate,Text(D1));
            PlotNumeric("1and2",D1);
    End

    2、我要調(diào)用的就是上面的D1的值。
    3、在1小時(shí)中執(zhí)行的代碼是這樣的
    Params
            Numeric Length(14) ;
            Numeric OverSold(30) ;
            Numeric OverBought(70) ;

    Vars
            NumericSeries NetChgAvg( 0 );
            NumericSeries TotChgAvg( 0 );
            Numeric SF( 0 );
            Numeric Change( 0 );       
            Numeric ChgRatio( 0 ) ;
            Numeric RSIValue;
        StringSeries strkeydate;
            StringSeries strkeyhour;
            String dayvalue1;
            NumericSeries H1;
            Numeric HH;
    Begin       
            If(CurrentBar <= Length - 1)
            {
                    NetChgAvg = ( Close - Close[Length] ) / Length ;
                    TotChgAvg = Average( Abs( Close - Close[1] ), Length ) ;
            }Else
            {
                    SF = 1/Length;
                    Change = Close - Close[1] ;
                    NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
                    TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;       
            }
           
            If( TotChgAvg <> 0 )
            {
                    ChgRatio = NetChgAvg / TotChgAvg;
            }else
            {
                    ChgRatio = 0 ;
            }       
            RSIValue = 50 * ( ChgRatio + 1 );       
            PlotNumeric("RSI",RSIValue);
            PlotNumeric("超買",OverBought);
            PlotNumeric("超賣",OverSold);
           
            If(date!=date[1])
               strkeydate=DateToString(Date);
            Else
               strkeydate=strkeydate[1];
            If(Hour!=Hour[1])
               strkeyhour=DateToString(Date)+":"+Text(Hour);
            Else
               strkeyhour=strkeyhour[1];

        dayvalue1=GetTBProfileString2File("f:\\r.log","if000","1and2"+strkeydate);
            H1 = Value(dayvalue1);
           
            If(RSIValue>70)
            {
                If(H1==2)
                     {
                        HH=2;
                     }
            }
            If(RSIValue<30)
            {
                 If(H1==1)
                     {
                        HH=1;
                     }
            }
            SetTBProfileString2File("f:\\0.log",Symbol,"1and2:"+strkeyhour,Text(HH));
    End

    4、為什么調(diào)用的結(jié)果卻老是不對(duì),這問(wèn)題糾結(jié)我快半個(gè)月了。救大神幫我解決解決!

     

  • TB技術(shù)人員: 本帖最后由 Allin9999 于 2015-12-8 20:39 編輯

    我不知道你具體是什么調(diào)用結(jié)果不對(duì),粗略看了一下代碼,至少有2個(gè)問(wèn)題:
    (1) 寫入文件和從文件中讀取的代碼沒(méi)有完全對(duì)應(yīng)。
    日線寫入到文件的代碼是:SetTBProfileString2File("f:\\r.log",Symbol,"1and2:"+strkeydate,Text(D1));
    小時(shí)從文件中讀取的代碼是:dayvalue1=GetTBProfileString2File("f:\\r.log","if000","1and2"+strkeydate);
    寫入時(shí),塊名是Symbol,讀取時(shí)的塊名變成了具體的"if000",這樣的公式只適合if000一個(gè)品種。
    然后是鍵名,讀取的代碼少了冒號(hào),"1and2:",這可能是你調(diào)用不到的主要原因。
    (2)存在未來(lái)數(shù)據(jù)調(diào)用,主要是這一段代碼沒(méi)寫對(duì)
             If(date!=date[1])
                strkeydate=DateToString(Date);
             Else
                strkeydate=strkeydate[1];
          正確的寫法應(yīng)該是:
             If(date!=date[1])
                strkeydate=DateToString(Date[1]);
             Else
                strkeydate=strkeydate[1];
    否則的話,你9點(diǎn)-10點(diǎn)那根小時(shí)線可能會(huì)讀到當(dāng)天收盤后的日線數(shù)據(jù)


     

  • TB客服:
    Allin9999 發(fā)表于 2015-12-8 20:36
    我不知道你具體是什么調(diào)用結(jié)果不對(duì),粗略看了一下代碼,至少有2個(gè)問(wèn)題:
    (1) 寫入文件和從文件中讀取的代 ...

    現(xiàn)在15分鐘上能讀取日線的了,但是1小時(shí)的RSI卻讀不出來(lái),檢查了幾遍,不知道問(wèn)題在那里。現(xiàn)在的代碼是這樣的:
    1、日線插入代碼
    Vars
        string strkeydate;
        NumericSeries pubu1;
        NumericSeries pubu2;
        NumericSeries pubu3;
        NumericSeries pubu4;
        NumericSeries pubu5;
        NumericSeries pubu6;

    Begin
       
        pubu1=(xaverage(Close,4)+average(Close,8)+average(Close,16))/3;
        pubu2=(xaverage(Close,6)+average(Close,12)+average(Close,24))/3;
        pubu3=(xaverage(Close,9)+average(Close,18)+average(Close,36))/3;
        pubu4=(xaverage(Close,13)+average(Close,26)+average(Close,52))/3;
        pubu5=(xaverage(Close,18)+average(Close,36)+average(Close,72))/3;
        pubu6=(xaverage(Close,24)+average(Close,48)+average(Close,96))/3;

        strkeydate=DateToString(Date);
        SetTBProfileString("daypubu","daypubu1:"+strkeydate,Text(pubu1));
        SetTBProfileString("daypubu","daypubu2:"+strkeydate,Text(pubu2));
        SetTBProfileString("daypubu","daypubu3:"+strkeydate,Text(pubu3));
        SetTBProfileString("daypubu","daypubu4:"+strkeydate,Text(pubu4));
        SetTBProfileString("daypubu","daypubu5:"+strkeydate,Text(pubu5));
        SetTBProfileString("daypubu","daypubu6:"+strkeydate,Text(pubu6));

        PlotNumeric("pubu1",pubu1,0,white);
        PlotNumeric("pubu2",pubu2,0,DarkMagenta);
        PlotNumeric("pubu3",pubu3,0,Blue);
        PlotNumeric("pubu4",pubu4,0,Green);
        PlotNumeric("pubu5",pubu5,0,Yellow);
        PlotNumeric("pubu6",pubu6,0,Red);
    End

    2、1小時(shí)插入代碼
    Params
            Numeric Length(14) ;
            Numeric OverSold(30) ;
            Numeric OverBought(70) ;

    Vars
            NumericSeries NetChgAvg( 0 );
            NumericSeries TotChgAvg( 0 );
            Numeric SF( 0 );
            Numeric Change( 0 );       
            Numeric ChgRatio( 0 ) ;
            Numeric RSIValue;
        StringSeries strkeydate;

    Begin       
            If(CurrentBar <= Length - 1)
            {
                    NetChgAvg = ( Close - Close[Length] ) / Length ;
                    TotChgAvg = Average( Abs( Close - Close[1] ), Length ) ;
            }Else
            {
                    SF = 1/Length;
                    Change = Close - Close[1] ;
                    NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
                    TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;       
            }
           
            If( TotChgAvg <> 0 )
            {
                    ChgRatio = NetChgAvg / TotChgAvg;
            }else
            {
                    ChgRatio = 0 ;
            }       
            RSIValue = 50 * ( ChgRatio + 1 );       
           
            strkeydate=DateToString(Date)+":"+Text(hour);
            SetTBProfileString("HRSI","HourRSI:"+strkeydate,Text(RSIValue));

            PlotNumeric("HourRSI",RSIValue);
            PlotNumeric("超買",OverBought);
            PlotNumeric("超賣",OverSold);
    End

    3、15分鐘插入代碼
    Vars
            NumericSeries Daypubu1;
        NumericSeries Daypubu2;
        NumericSeries Daypubu3;
        NumericSeries Daypubu4;
        NumericSeries Daypubu5;
        NumericSeries Daypubu6;
            NumericSeries HourRSI;
            StringSeries strkeydate;
        StringSeries strkeyhour;
            String dayvalue1;
            String dayvalue2;
            String dayvalue3;
            String dayvalue4;
            String dayvalue5;
            String dayvalue6;
            String Hourvalue;
    Begin
        If(Date!=Date[1])
               strkeydate=DateToString(Date);
            Else
               strkeydate=strkeydate[1];
            If(Hour!=Hour[1])
               strkeyhour=DateToString(Date)+":"+Text(Hour);
            Else
               strkeyhour=strkeyhour[1];
            //讀取日線
            dayvalue1=GetTBProfileString("daypubu","daypubu1:"+strkeydate);
            dayvalue2=GetTBProfileString("daypubu","daypubu2:"+strkeydate);
            dayvalue3=GetTBProfileString("daypubu","daypubu3:"+strkeydate);
            dayvalue4=GetTBProfileString("daypubu","daypubu4:"+strkeydate);
            dayvalue5=GetTBProfileString("daypubu","daypubu5:"+strkeydate);
            dayvalue6=GetTBProfileString("daypubu","daypubu6:"+strkeydate);
        //讀取小時(shí)線
            Hourvalue=GetTBProfileString("HRSI","HourRSI:"+strkeydate);
           
            Daypubu1=Value(dayvalue1);
            Daypubu2=Value(dayvalue2);
            Daypubu3=Value(dayvalue3);
            Daypubu4=Value(dayvalue4);
            Daypubu5=Value(dayvalue5);
            Daypubu6=Value(dayvalue6);
            HourRSI=Value(Hourvalue);
           
            PlotNumeric("Dpb1",Daypubu1,0,white);
        PlotNumeric("Dpb2",Daypubu2,0,DarkMagenta);
        PlotNumeric("Dpb3",Daypubu3,0,Blue);
        PlotNumeric("Dpb4",Daypubu4,0,Green);
        PlotNumeric("Dpb5",Daypubu5,0,Yellow);
        PlotNumeric("Dpb6",Daypubu6,0,Red);
               PlotNumeric("HRSI",HourRSI);
    End

    4、現(xiàn)在15分鐘上可以顯示和日線上一樣的線,但是1小時(shí)的RSI卻讀不出來(lái)。代碼檢查了幾遍不知道問(wèn)題出在那里。

     

  • 網(wǎng)友回復(fù):
    Allin9999 發(fā)表于 2015-12-8 20:36
    我不知道你具體是什么調(diào)用結(jié)果不對(duì),粗略看了一下代碼,至少有2個(gè)問(wèn)題:
    (1) 寫入文件和從文件中讀取的代 ...

    按你說(shuō)的改成這樣反而和日線上的數(shù)據(jù)不一樣了
            If(date!=date[1])
                strkeydate=DateToString(Date[1]);
             Else
                strkeydate=strkeydate[1];
    按原來(lái)的寫法就和日線的數(shù)據(jù)一樣。現(xiàn)在主要是調(diào)用1小時(shí)的RSI,調(diào)不出來(lái)

     

  • 網(wǎng)友回復(fù):
    xiaokakaren 發(fā)表于 2015-12-9 14:39
    按你說(shuō)的改成這樣反而和日線上的數(shù)據(jù)不一樣了
            If(date!=date[1])
                strkeydate=DateTo ...


    在3#的公式中,如果你的1小時(shí)線也要寫入數(shù)據(jù),并由15分鐘線中讀取。
    那么1小時(shí)的公式中,strkeyhour這個(gè)鍵名是需要繼續(xù)存在的。
    1. strkeyhour=DateToString(Date)+":"+Text(hour);
    2.      SetTBProfileString("HRSI","HourRSI:"+strkeyhour,Text(RSIValue));
    復(fù)制代碼同時(shí),在15分鐘的也得要聲明strkeyhour,并賦值
    1.   strkeyhour=DateToString(Date)+":"+Text(hour);
    2.           //讀取小時(shí)線
    3.          Hourvalue=GetTBProfileString("HRSI","HourRSI:"+strkeyhour);
    復(fù)制代碼就是這個(gè)細(xì)節(jié),改過(guò)來(lái)應(yīng)該就可以取到值了。

 

有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友

可聯(lián)系技術(shù)人員 QQ: 511411198  點(diǎn)擊這里給我發(fā)消息進(jìn)行 有償 編寫!不貴!點(diǎn)擊查看價(jià)格!


【字體: 】【打印文章】【查看評(píng)論

相關(guān)文章

    沒(méi)有相關(guān)內(nèi)容
主站蜘蛛池模板: 国产麻传媒精品国产AV| 最近中文字幕的在线mv视频| 国产三级在线观看完整版| 91精品国产免费久久久久久青草| 日产乱码免费一卡二卡在线| 亚洲国产精品久久久久久| 精品人妻久久久久久888| 日本乱人伦中文在线播放| 亚洲欧美精品成人久久91| 美女黄18以下禁止观看| 国产欧美va欧美va香蕉在线| 久久久噜噜噜久久久午夜| 欧美视频亚洲视频| 午夜视频免费看| 黄在线观看www免费看| 国产综合欧美日韩视频一区| 一级特黄特色的免费大片视频| 最近免费中文字幕大全| 亚洲精品一卡2卡3卡四卡乱码| 美女毛片一区二区三区四区| 国产成人精品午夜视频'| 91香蕉国产线观看免| 小情侣高清国产在线播放| 久久人妻夜夜做天天爽| 欧美一级免费在线观看| 国产三级日产三级韩国三级 | 中文字幕无码无码专区| 最近中字视频在线观看| 亚洲欧美日韩综合久久久久| 精品久久久久国产免费| 国产一级二级在线| 国产精品www| 国产精品正在播放| a级日本片在线观看| 成人国产在线观看高清不卡| 久久午夜无码免费| 榴莲视频app色版| 亚洲日本国产乱码va在线观看| 男人让女人桶爽30分钟| 同学的嫩苞13p| 蜜桃成熟时1997在线观看在线观看|