5、250指数移动平均线死叉未平仓

双均线策略,死叉未平仓,不知道什么原因?

改为单边的金叉进死叉平仓
MACD金叉死叉
如何表达MACD死叉平仓价格
金死叉开仓的公式,改成只做单边死叉开空
ma平均线240分钟和15分钟,金叉做多,死叉做空,怎么写程序。
请帮忙改成均线死叉进场
macd 金叉死叉周期确认
MACD金叉死叉的分别
适应性移动平均线指标
请教macd金叉死叉问题

你的平仓分支条件里有5个表达式,除了不太可能出问题的marketposition和barssinentry,还有双均线判断,剩下两个条件,你确定满足么?

这个最低价小于opint1减一跳,满足了么?目测好像没有满足吧?

EMA双均线如何逆解?

...我的视频里应该说过了,这是个数学问题,解方程式然后重新列算式...

ema我没有推导过,不太清楚。你如果需要反函数自己试试推导下

Opint1  //逆解交叉点值

这个值确定是对的吗

用EMA了,还是调整回ma


有EMA均线交叉的逆解算法吗

你在说啥

我这个是直接复制了你的代码

只增加了一个,把你Opint1 的值plot出来的语句

解析正确

//------------------------------------------------------------------------
// 简称: L_DualMoving5To250
// 名称: 5上穿250做多
// 类别: 策略应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
    Numeric EFast(5);       //短均线周期参数
    Numeric ESlow(250);      //长均线周期参数 
    Numeric PostionLots(1);//头寸 
Vars
    Series<Numeric> MAEFast;    //短均线
    Series<Numeric> MAESlow;    //长均线  
   
    Series<Numeric> Opint1;     // 逆解交叉点值     
    Series<Numeric> PreProtectStopPrice_L;  //保护性止损价初值
    Series<Numeric> ProtectStopPrice_L;  //保护性止损价
    Series<Numeric> PreTrailStopPrice_L;    //跟踪性止损价初值 
    Series<Numeric> TrailStopPrice_L;    //跟踪性止损价 
    Series<Numeric> PreMyEntryPrice_L;  // 开仓价格初赋值 
    Series<Numeric> MyEntryPrice_L;  // 开仓价格    
    Series<Bool> IsPriceLimit;  //涨跌停判断,
    Series<Numeric> MP;  //持仓状态    
        
Events
    OnInit()
    {
        Range[0:DataCount - 1]
        {
            AddDataFlag(Enum_Data_RolloverBackWard());   //设置后复权
            AddDataFlag(Enum_Data_RolloverRealPrice());  //真实价格
            AddDataFlag(Enum_Data_AutoSwapPosition());  //自动换仓
            AddDataFlag(Enum_Data_IgnoreSwapSignalCalc());  //忽略换仓信号计算
        }
    }
    OnBar(ArrayRef<Integer> indexs)
    {
        MAEFast = XAverage(Close, EFast); //短均线
        MAESlow = XAverage(Close, ESlow); //长均线 
        
        Opint1 = ((ESlow - 1) * XAverage(Close[1], ESlow - 1) * EFast - (EFast - 1) * XAverage(Close[1], EFast - 1) * ESlow) / (ESlow - EFast);  //逆解交叉点值
              
        PreMyEntryPrice_L = Max(Open,opint1);
        
        
        IsPriceLimit = (High[1] == Low[1]) Or (High[2] == Low[2]);
       
        Range[0:DataSourceSize() - 1]
        {
            PlotNumeric("MAEFast", MAEFast);
            PlotNumeric("MAESlow", MAESlow);                
        }        
        
        If(MarketPosition <> 1 and MAEFast[1]<MAESlow[1] and High >= Opint1 And !IsPriceLimit)  //金叉
        {
            Buy(PostionLots, Max(Open, Opint1));     //金叉开多单
            ProtectStopPrice_L = PreProtectStopPrice_L;
            MyEntryPrice_L = PreMyEntryPrice_L;
            PlotString("d1","d1",Low,Red);
        }
        
        If(MarketPosition <> 1 And Low[1] <= Opint1[1] And Close[1] >= Opint1[1] And High >= Opint1 And !IsPriceLimit)       //过滤假死叉(考虑收盘价最低的情况)
        {
            Buy(PostionLots, Max(Open, Opint1));
            ProtectStopPrice_L = PreProtectStopPrice_L;
            MyEntryPrice_L = PreMyEntryPrice_L;
            PlotString("d2","d2",Low,Red);
        }
        
        If(MarketPosition == 1 And BarsSinceEntry > 0 And MAEFast[1] >= MAESlow[1] And Low <= Opint1-MinMove*PriceScale And !IsPriceLimit)
        {   
            Sell(PostionLots, Min(Open, Opint1-MinMove*PriceScale));
            PlotString("平1","平1",Low,Red);
        }
        If(MarketPosition == 1 And BarsSinceEntry > 0 And High[1] >= Opint1[1] And Close[1] < Opint1[1] And Low <= Opint1-MinMove*PriceScale)     //过滤假金叉
        {
            Sell(PostionLots, Min(Open, opint1-MinMove*PriceScale));
            PlotString("假金","假金",Low,Red);
        }       
   
        
    } 

    

//------------------------------------------------------------------------
// 编译版本    2025/8/7 155040
// 版权所有    winter110
// 更改声明    TradeBlazer Software保留对TradeBlazer平台
//            每一版本的TradeBlazer策略修改和重写的权利
//------------------------------------------------------------------------