开拓者期货期权程序化系统交易论坛

标题: 均线模型编写求助,多谢! [打印本页]

作者: ludiqiu    时间: 2019-1-19 14:28:54     标题: 均线模型编写求助,多谢!

本帖最后由 ludiqiu 于 2019-1-21 10:22 编辑

开多条件:
EMA  5 10  15  20  25  30  35  40  45  50  55  60    多头排列  即  EMA5>EMA10......>EMA60
平多条件    EMA  5 10  15  20  25  30  35  40  45  50  55  60   空头排列 即   EMA5<EMA10......<EMA60

开空条件:
EMA  5 10  15  20  25  30  35  40  45  50  55  60    空头排列  即  EMA5<EMA10......<EMA60
平空条件    EMA  5 10  15  20  25  30  35  40  45  50  55  60   多头排列 即  EMA5>EMA10......>EMA60

做多、做空分开写。
作者: ludiqiu    时间: 2019-1-21 10:21:27

唉,想文华转TB,可惜TB售后不帮忙写策略,求助无门,只有到论坛求助。
作者: 小米    时间: 2019-1-21 14:23:29

ludiqiu 发表于 2019-1-21 10:21
唉,想文华转TB,可惜TB售后不帮忙写策略,求助无门,只有到论坛求助。


TB的售后?TB好象没有售前售后一说呢。
TB与其它软件不一样,没有年费制的, 也没有说象其它软件一样付费后才能进论坛提问的。。
所以确实人员精力有限,没法满足每一个人交易者提出的写策略的需求呢。。

给您以多头开仓为例,大概写了一下。。(仅以4条线为例,更多的EMA线可自行添加)
  1. Params
  2.         Numeric Length1(5);
  3.         Numeric Length2(10);
  4.         Numeric Length3(15);
  5.         Numeric Length4(20);
  6. Vars
  7.         NumericSeries EMA5;
  8.         NumericSeries EMA10;
  9.         NumericSeries EMA15;
  10.         NumericSeries EMA20;
  11. Begin
  12.         EMA5 = XAverage(Close, Length1);
  13.         EMA10 = XAverage(Close, Length1);
  14.         EMA15 = XAverage(Close, Length1);
  15.         EMA20 = XAverage(Close, Length1);
  16.         PlotNumeric("EMA1",EMA5);       
  17.         PlotNumeric("EMA2",EMA10);
  18.         PlotNumeric("EMA3",EMA15);
  19.         PlotNumeric("EMA4",EMA20);
  20.        
  21.         If(MarketPosition!=1)
  22.         {
  23.                 If(EMA5[1] >EMA10[1] && EMA10[1]>EMA15[1] && EMA15[1]>EMA20[1])
  24.                 {
  25.                         Buy(1,OPEN);
  26.                 }
  27.         }
  28.         If(MarketPosition==1)
  29.         {
  30.                 If(EMA5[1]<EMA10[1] && EMA10[1]<EMA15[1] && EMA15[1]<EMA20[1])
  31.                 {
  32.                         Sell(1,open);
  33.                 }
  34.         }
  35. End
复制代码

作者: ludiqiu    时间: 2019-1-21 23:00:47

多谢小米老师!
作者: ludiqiu    时间: 2019-1-22 19:24:33

请问小米老师:这么写对吗?
Params
        Numeric Length1(5);
        Numeric Length2(10);
        Numeric Length3(15);
        Numeric Length4(20);
        Numeric Length5(25);
        Numeric Length6(30);
        Numeric Length7(35);
        Numeric Length8(40);
        Numeric Length9(45);
        Numeric Length10(50);
        Numeric Length11(55);
        Numeric Length12(60);

Vars
        NumericSeries EMA5;
        NumericSeries EMA10;
        NumericSeries EMA15;
        NumericSeries EMA20;  
        NumericSeries EMA25;
        NumericSeries EMA30;
        NumericSeries EMA35;
        NumericSeries EMA40;
        NumericSeries EMA45;
        NumericSeries EMA50;
        NumericSeries EMA55;
        NumericSeries EMA60;


Begin
        EMA5 = XAverage(Close, Length1);
        EMA10 = XAverage(Close, Length1);
        EMA15 = XAverage(Close, Length1);
        EMA20 = XAverage(Close, Length1);
        EMA25 = XAverage(Close, Length1);
        EMA30 = XAverage(Close, Length1);
        EMA35 = XAverage(Close, Length1);
        EMA40 = XAverage(Close, Length1);
        EMA45 = XAverage(Close, Length1);
        EMA50 = XAverage(Close, Length1);
        EMA55 = XAverage(Close, Length1);
        EMA60 = XAverage(Close, Length1);
        PlotNumeric("EMA1",EMA5);        
        PlotNumeric("EMA2",EMA10);
        PlotNumeric("EMA3",EMA15);
        PlotNumeric("EMA4",EMA20);
        PlotNumeric("EMA5",EMA25);        
        PlotNumeric("EMA6",EMA30);
        PlotNumeric("EMA7",EMA35);
        PlotNumeric("EMA8",EMA40);
        PlotNumeric("EMA9",EMA45);        
        PlotNumeric("EMA10",EMA50);
        PlotNumeric("EMA11",EMA55);
        PlotNumeric("EMA12",EMA60);


        If(MarketPosition!=1)
        {
                If(EMA5[1] >EMA10[1] && EMA10[1]>EMA15[1] && EMA15[1]>EMA20[1]&& EMA20[1]>EMA25[1]  && EMA25[1]>EMA30[1] && EMA30[1]>EMA35[1]  &&  EMA35[1]>EMA40[1] && EMA40[1]>EMA45[1]  && EMA45[1]>EMA50[1] && EMA50[1]>EMA55[1]  && EMA55[1]>EMA60[1])


                            {
                        Buy(1,OPEN);
                }
        }
        If(MarketPosition==1)
        {
                If(EMA5[1]<EMA10[1] && EMA10[1]<EMA15[1] && EMA15[1]<EMA20[1] &&EMA20[1]<EMA25[1] && EMA25[1]<EMA30[1] && EMA30[1]<EMA35[1] && EMA35[1]<EMA40[1] && EMA40[1]<EMA45[1]&& EMA45[1]<EMA50[1] && EMA50[1]<EMA55[1] && EMA55[1]<EMA60[1])



{
                        Sell(1,open);
                }
        }

               
               
                If(MarketPosition!=1)
        {
                 If(EMA5[1]<EMA10[1] && EMA10[1]<EMA15[1] && EMA15[1]<EMA20[1] &&EMA20[1]<EMA25[1] && EMA25[1]<EMA30[1] && EMA30[1]<EMA35[1] && EMA35[1]<EMA40[1] && EMA40[1]<EMA45[1]&& EMA45[1]<EMA50[1] && EMA50[1]<EMA55[1] && EMA55[1]<EMA60[1])



                            {
                        Sell(1,OPEN);
                }
        }
        If(MarketPosition==1)
        {
               If(EMA5[1] >EMA10[1] && EMA10[1]>EMA15[1] && EMA15[1]>EMA20[1]&& EMA20[1]>EMA25[1]  && EMA25[1]>EMA30[1] && EMA30[1]>EMA35[1]  &&  EMA35[1]>EMA40[1] && EMA40[1]>EMA45[1]  && EMA45[1]>EMA50[1] && EMA50[1]>EMA55[1]  && EMA55[1]>EMA60[1])




{
                        Sell(1,open);
                }
        }
               
               
               
               
               
                End





欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2