均线策略

这个是怎么回事??


代码如下:

[Description("5日均线向上突破10日均线做多")]

[Version(1)]


// 输入参数

Inputs:

   ShortTermMA(5),

   LongTermMA(10),

   StopLossPercent(2),

   TakeProfitPercent(5);


// 变量声明

Vars:

   PositionOpen(False),

   EntryPrice(0),

   HighestSinceEntry(0),

   LowestSinceEntry(0);


// 计算移动平均线

Plot1(MA(Close, ShortTermMA), "5日均线");

Plot2(MA(Close, LongTermMA), "10日均线");


// 开仓条件:5日均线上穿10日均线

If (MA(Close, ShortTermMA) Crosses Above MA(Close, LongTermMA)) and not PositionOpen then

begin

   Buy("Buy") Next Bar at Market;

   PositionOpen = True;

   EntryPrice = Close;

   HighestSinceEntry = Close;

end;


// 平仓逻辑

If PositionOpen then

begin

   // 更新最高价和最低价

   If Close > HighestSinceEntry then HighestSinceEntry = Close;

   If Close < LowestSinceEntry or LowestSinceEntry = 0 then LowestSinceEntry = Close;


   // 止损:亏损2%

   If Close <= EntryPrice * (1 - StopLossPercent / 100) then

   begin

       Sell("StopLoss") Next Bar at Market;

       PositionOpen = False;

   end;


   // 止盈:从最高位回撤5%

   If HighestSinceEntry > 0 and Close <= HighestSinceEntry * (1 - TakeProfitPercent / 100) then

   begin

       Sell("TakeProfit") Next Bar at Market;

       PositionOpen = False;

   

双均线策略问题
均线策略的开平价格
双均线策略涨跌停设置不开仓
双均线策略做多做空合并及拆分问题
“把双均线策略改写成A函数报单”的意义是什么呢?
如何运用Spyder运行官网的双均线策略进行历史回测?
均线策略
均线策略出错
跨周期均线策略
日内均线策略

ai写的,不应该问ai吗?

什么叫程序主体,不存在是什么意思?