老师你好。帮忙加个条件,谢谢 [文华财经]
-
咨询内容:
Params Numeric Length1(10); Numeric Length2(60); Numeric Lots(1); Numeric TakeProfitSet(90); // 止赢设置 Numeric StopLossSet(20); // 止损设置 Vars NumericSeries MA1; NumericSeries MA2; NumericSeries MinPoint;
Numeric MyExitPrice; // 平仓价格
Numeric MyEntryPrice ; // 平仓价格 Begin
MA1 = AverageFC(Close,Length1); MA2 = AverageFC(Close,Length2); PlotNumeric("MA1",MA1); PlotNumeric("MA2",MA2); If (MA1[1] > MA2[1] and OpenD(1)<CloseD(1)) { Buy(Lots,Open); } If (MA1[1] < MA2[1] and OpenD(1)>CloseD(1)) { SellShort(lots,Open); }
MinPoint = MinMove*PriceScale; MyEntryPrice = AvgEntryPrice; If(MarketPosition==1) // 有多仓的情况 { If(High >= MyEntryPrice + TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice + TakeProfitSet*MinPoint; If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 Sell(0,MyExitPrice); }else if(Low <= MyEntryPrice - StopLossSet*MinPoint)// 止损条件表达式 { MyExitPrice = MyEntryPrice - StopLossSet*MinPoint; If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 Sell(0,MyExitPrice); } }else if(MarketPosition==-1) // 有空仓的情况 { If(Low <= MyEntryPrice - TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint; If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 BuyToCover(0,MyExitPrice); }else if(High >= MyEntryPrice + StopLossSet*MinPoint)// 止损条件表达式 { MyExitPrice = MyEntryPrice + StopLossSet*MinPoint; If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 BuyToCover(0,MyExitPrice); } } End kdj金叉做多不做空。kdj死叉做空不做多。加开仓条件。谢谢来源:程序化99
-
文华技术人员:
参考
Params Numeric Length1(10); Numeric Length2(60); Numeric Lots(1); Numeric TakeProfitSet(90); // 止赢设置 Numeric StopLossSet(20); // 止损设置 Numeric Length(9); Numeric Length3(3); Numeric Length4(3);Vars NumericSeries MA1; NumericSeries MA2; NumericSeries MinPoint; Numeric MyExitPrice; // 平仓价格 Numeric MyEntryPrice ; // 平仓价格 Numeric RSV;Numeric K;Numeric D;Begin RSV = (Close - LLV(Low,Length)) / (HHV(High,Length) - LLV(Low,Length)) * 100;//收盘价与N周期最低值做差,N周期最高值与N周期最低值做差,两差之间做比值定义为RSVK = Sma(RSV,Length3,1);//RSV的移动平均D = Sma(K,Length4,1);//K值的移动平均
MA1 = AverageFC(Close,Length1); MA2 = AverageFC(Close,Length2); PlotNumeric("MA1",MA1); PlotNumeric("MA2",MA2); If (MA1[1] > MA2[1] and OpenD(1)<CloseD(1) && K>D ) { Buy(Lots,Open); } If (MA1[1] < MA2[1] and OpenD(1)>CloseD(1) && K<D) { SellShort(lots,Open); }
MinPoint = MinMove*PriceScale; MyEntryPrice = AvgEntryPrice; If(MarketPosition==1) // 有多仓的情况 { If(High >= MyEntryPrice + TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice + TakeProfitSet*MinPoint; If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 Sell(0,MyExitPrice); }else if(Low <= MyEntryPrice - StopLossSet*MinPoint)// 止损条件表达式 { MyExitPrice = MyEntryPrice - StopLossSet*MinPoint; If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 Sell(0,MyExitPrice); } }else if(MarketPosition==-1) // 有空仓的情况 { If(Low <= MyEntryPrice - TakeProfitSet*MinPoint) // 止赢条件表达式 { MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint; If(Open < MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 BuyToCover(0,MyExitPrice); }else if(High >= MyEntryPrice + StopLossSet*MinPoint)// 止损条件表达式 { MyExitPrice = MyEntryPrice + StopLossSet*MinPoint; If(Open > MyExitPrice) MyExitPrice = Open; // 如果该Bar开盘价有跳空触发,则用开盘价代替 BuyToCover(0,MyExitPrice); } } End
来源: WWW.CXH99.COM
-
文华客服:
谢谢老师,在加个开仓条件。大于前值开多,不然不开。小于前值开空。不然不开。
-
网友回复:
您指的是什么指标值?
是指K和D都判断要大于前一根K线值吗? - 网友回复: 是
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
相关文章
-
没有相关内容