交易危机

 找回密码
 快捷注册(禁q号)

QQ登录

只需一步,快速开始

搜索
广告位
查看: 7000|回复: 6
打印 上一主题 下一主题

[系统] 求助!有没有懂编程的大佬帮我改一下

[复制链接]

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
跳转到指定楼层
楼主
发表于 2023-4-22 10:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我想在图表中有信号的地方显示文字或者箭头都可以,但是图表中一直都没有任何的显示,也没有任何的报错,不知道是哪里的问题 求教大佬帮忙改一下
#property indicator_chart_window
#property copyright "Copyright 2023, Your Name"
#property link "https://www.yourwebsite.com"
//property version "1.00"

//input ENUM_TIMEFRAMES Timeframe = PERIOD_H1;

extern bool ShowBBY = true;
extern bool ShowSSL = true;
extern bool ShowEveningStar = true;
extern bool ShowThreeInsideUp = true;
extern bool ShowThreeInsideDown = true;

extern color BBY_Color = clrRed;
extern color SSL_Color = clrLime;
extern color EveningStar_Color = clrYellow;
extern color ThreeInsideUp_Color = clrBlue;
extern color ThreeInsideDown_Color = clrMagenta;

string BBY_Signal = "BBY";
string SSL_Signal = "SSL";
string EveningStar_Signal = "EveningStar";
string ThreeInsideUp_Signal = "ThreeInsideUp";
string ThreeInsideDown_Signal = "ThreeInsideDown";

double ExtMapBuffer1[];

void DrawSignal(string signal, double price, color signal_color, int shift)
{
    int signalObj = ObjectCreate(signal + "_" + TimeToStr(Time[shift], TIME_DATE | TIME_MINUTES), OBJ_TEXT, 0, Time[shift], price);
    ObjectSet(signalObj, OBJPROP_CORNER, 2);
    ObjectSet(signalObj, OBJPROP_XDISTANCE, 10);
    ObjectSet(signalObj, OBJPROP_YDISTANCE, 20);
    ObjectSet(signalObj, OBJPROP_COLOR, signal_color);
    ObjectSetText(signalObj, "", 0, "Arial", signal_color);
    ObjectSetText(signalObj, signal + ": " + DoubleToStr(price, Digits()), 10, "Arial", signal_color);
}

bool isEveningStar(int shift)
{
    double firstCandleClose = Close[shift + 2];
    double firstCandleOpen = Open[shift + 2];
    double secondCandleClose = Close[shift + 1];
    double secondCandleOpen = Open[shift + 1];
    double thirdCandleClose = Close[shift];
    double thirdCandleOpen = Open[shift];
    bool firstCandleBullish = firstCandleClose > firstCandleOpen;
    bool secondCandleSmallBullish = secondCandleClose > secondCandleOpen && (secondCandleClose - secondCandleOpen) < (secondCandleOpen - secondCandleClose) * 0.5;
    bool thirdCandleBearish = thirdCandleClose < thirdCandleOpen;
    bool noOverlap = secondCandleClose > firstCandleClose && secondCandleOpen < firstCandleOpen && thirdCandleOpen < secondCandleClose && thirdCandleClose < secondCandleOpen;
    return firstCandleBullish && secondCandleSmallBullish && thirdCandleBearish && noOverlap;
}

bool isThreeInsideUp(int shift)
{
    double firstCandleClose = Close[shift + 2];
    double firstCandleOpen = Open[shift + 2];
    double secondCandleClose = Close[shift + 1];
    double secondCandleOpen = Open[shift + 1];
    double thirdCandleClose = Close[shift];
    double thirdCandleOpen = Open[shift];
    bool firstCandleBearish = firstCandleClose < firstCandleOpen;
    bool secondCandleBearish = secondCandleClose < secondCandleOpen;
    bool thirdCandleBullish = thirdCandleClose > thirdCandleOpen;
    bool noOverlap = secondCandleClose < firstCandleClose && secondCandleOpen > firstCandleOpen && thirdCandleOpen > secondCandleClose && thirdCandleClose > secondCandleOpen;
    bool gap = secondCandleOpen > firstCandleClose && secondCandleOpen < firstCandleOpen && thirdCandleOpen > secondCandleClose && thirdCandleClose > secondCandleOpen;
    return firstCandleBearish && secondCandleBearish && thirdCandleBullish && noOverlap && gap;
}

bool isThreeInsideDown(int shift)
{
    double firstCandleClose = Close[shift + 2];
    double firstCandleOpen = Open[shift + 2];
    double secondCandleClose = Close[shift + 1];
    double secondCandleOpen = Open[shift + 1];
    double thirdCandleClose = Close[shift];
    double thirdCandleOpen = Open[shift];   
    bool firstCandleBullish = firstCandleClose > firstCandleOpen;
    bool secondCandleBullish = secondCandleClose > secondCandleOpen;
    bool thirdCandleBearish= thirdCandleClose < thirdCandleOpen;
    bool noOverlap = secondCandleClose > firstCandleClose && secondCandleOpen < firstCandleOpen && thirdCandleOpen < secondCandleClose && thirdCandleClose < secondCandleOpen;
    bool gap = secondCandleOpen < firstCandleClose && secondCandleOpen > firstCandleOpen && thirdCandleOpen < secondCandleClose && thirdCandleClose < secondCandleOpen;
    return firstCandleBullish && secondCandleBullish && thirdCandleBearish && noOverlap && gap;
}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
    IndicatorShortName("ZZS Indicator");
    SetIndexBuffer(0, ExtMapBuffer1);
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    int start = 0;
    if(prev_calculated > 0) start = prev_calculated - 1;

    for(int i = start; i < rates_total; i++)
    {
        if(ShowBBY)
        {
            if (ExtMapBuffer1[i] == 1) //如果有买入信号
            {
                DrawSignal("BBY", Close[i], BBY_Color, i);
            }
        }

        if(ShowSSL)
        {
            if (ExtMapBuffer1[i] == -1) //如果有卖出信号
            {
                DrawSignal("SSL", Close[i], SSL_Color, i);
            }
        }

        if(ShowEveningStar && isEveningStar(i))
        {
            DrawSignal(EveningStar_Signal, Close[i], EveningStar_Color, i);
        }

        if(ShowThreeInsideUp && isThreeInsideUp(i))
        {
            DrawSignal(ThreeInsideUp_Signal, Close[i], ThreeInsideUp_Color, i);
        }

        if(ShowThreeInsideDown && isThreeInsideDown(i))
        {
            DrawSignal(ThreeInsideDown_Signal, Close[i], ThreeInsideDown_Color, i);
        }
        
    }
    return(rates_total);

}

//+------------------------------------------------------------------+
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 支持支持 保留保留

33

主题

4565

积分

0

精华

高级操盘手

金钱
4565 美元
权重
9
沙发
发表于 2023-4-22 13:49 | 只看该作者
我是真不会

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
板凳
 楼主| 发表于 2023-4-23 09:36 | 只看该作者
自己顶一下

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
地板
 楼主| 发表于 2023-4-24 09:34 | 只看该作者
路过      

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
5
 楼主| 发表于 2023-4-26 16:40 | 只看该作者
自己路过

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
6
 楼主| 发表于 2023-4-28 11:03 | 只看该作者
自己路过

2

主题

223

积分

0

精华

见习操盘手

金钱
223 美元
权重
0
7
 楼主| 发表于 2023-5-3 21:42 | 只看该作者
别沉啊     
您需要登录后才可以回帖 登录 | 快捷注册(禁q号)

本版积分规则

QQ|黄金吧|黄金论坛|手机版|指标下载|非农|目录|交易危机

版权所有: ©2014-2021 fx3q.com Powered by Discuz! X3
皖ICP备: 2024050410号-2

风险提示:杠杆风险高,交易要谨慎 声明:坛友发言和回复均为个人观点,不代表论坛立场。
若有侵权请联系fx3q@qq.com删除

快速回复 返回顶部 返回列表