代码编写止盈问题

老师帮我修改下,我想在多单开仓价盈利达9倍ATR后,最高价回撤3倍ATR止盈。我写不知道哪里不对。

Params
    Numeric FastLength(5);// 短期指数平均线参数
    Numeric SlowLength(20);// 长期指数平均线参数
    Numeric len1(250);           //ATR周期
    Numeric Nzy(9);           //ATR止盈倍数
    Numeric Nhc(3);           //ATR回撤倍数
Vars
    Series<Numeric> AvgValue1; 
    Series<Numeric> AvgValue2;
    Numeric myEntryPrice;                    // 开仓价格
    Series<Numeric> preEntryPrice(0);        // 前一次开仓的价格
    Series<Numeric> atr;
    Series<Numeric>N;
Events
       
    OnBar(ArrayRef<Integer> indexs)
    {
        AvgValue1 = AverageFC(Close,FastLength);
        AvgValue2 = AverageFC(Close,SlowLength);
        PlotNumeric("MA1",AvgValue1);
        PlotNumeric("MA2",AvgValue2);        
        
         atr=AvgTrueRange(len1);
         N=atr[1];
        
        If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1])
        {
            myEntryPrice = Open;
            preEntryPrice = myEntryPrice;
            Buy(0,myEntryPrice);
        }
        If(MarketPosition == 1) // 有多仓的情况
        {
            If(H>=preEntryPrice+N*Nzy)
            {
               L<=H-N*Nhc;
               myEntryPrice = Min(H-N*Nhc,O);
               preEntryPrice = myEntryPrice;
               BuyToCover(0,myEntryPrice);
            }    
        }
        
        If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1])
        {
            SellShort(0,Open);
        }    
    }

止盈止损代码编写
代码中止盈止损不起作用
代码编写
编写问题
跨周期代码编写
跟踪止盈
关于止损止盈的写法
账户手工开仓后,怎样利用开拓者平台对该手工仓单进行止盈止损(对于止盈最好能实现浮动止盈)
代码写了固定止损和固定止盈,当盘中出现大K线时,此K线的最高价和最低价同时满足止损和止盈,得怎么办?
请假一个关于代码编写的问题

一个止盈问题有这么复杂吗?这里不能解决吗?客服喊找社区,社区喊找直播。什么情况

复杂的代码问题建议投稿直播讲解