Rejoindre la communauté
banner_forum
Devenez membre de la plus grande
communauté francophone sur le Forex
Partagez, échangez et apprenez en gagnant des crédits sur votre compte de trading

Programmer une Alerte sur un indicateur

  • Picaban

    Bonjour à tous

    Je ne suis pas certain que se soit la bonne rubrique j'hesites avec les EA mais je pense quand meme que c'est ici que ce topic a sa place.

    Je souhaiterais avoir de l'aide pour programmer une alerte sur un indicateur Fisher , je ne sais pas faire et j'aimerais donc avoir une petite formation en programmation si c'est accessible à un novice de mon genre.
  • wimz01

    C'est quoi que tu cherche, tu veux qu'il te fasse une alerte à chaque fois que le signal s'inverse ?
  • Picaban

    Oui quand il s'inverse et si possible quand les 2 indicateurs concordent aussi.
    Mais si on arrive à faire l'un ou l'autre cela m'ira aussi.
  • wimz01

    T'as regarder si il n'existait pas déjà un idicateur fisher alert ? Tu peux poster le code de l'indique sur le thread pour pouvoir regarder les lignes du programme correspondant à tes signaux stp, tu poste l’intégralité.
  • Picaban

    J'ai cherché oui et je n'ai pas trouvé.

    Pour le code , je ne sais pas comment te le donner , j'ai cru qu'il fallait ouvrir le fichier correspondant à l'indicateur mais cela ne m'affichait que des signes du type %+= à tout vas.

    Pourrais tu me dires comment te l'envoyer ?
  • wimz01

    tu as le fichier MQ4 de l'indicateur ou que le ex4 ?
  • Picaban

    Ah oui je n'y avais pas pensé.

    Le Voici

    Code
    #property copyright "Copyright © 2005, Yura Prokofiev" #property link "[email protected]" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Black #property indicator_color2 Lime #property indicator_color3 Red extern int period=10; double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; int init() { SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Lime); SetIndexStyle(2,DRAW_HISTOGRAM); IndicatorDigits(Digits+1); SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); IndicatorShortName("Fisher"); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); return(0); } int start() { //int period=10; int limit; int counted_bars=IndicatorCounted(); double prev,current,old; double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0; double price; double MinL=0; double MaxH=0; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)]; MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)]; price = (High[i]+Low[i])/2; Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1; Value=MathMin(MathMax(Value,-0.999),0.999); ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1; Value1=Value; Fish1=ExtBuffer0[i]; } bool up=true; for(i=limit-2; i>=0; i--) { current=ExtBuffer0[i]; prev=ExtBuffer0[i+1]; if (((current<0)&&(prev>0))||(current<0)) up= false; if (((current>0)&&(prev<0))||(current>0)) up= true; if(!up) { ExtBuffer2[i]=current; ExtBuffer1[i]=0.0; } else { ExtBuffer1[i]=current; ExtBuffer2[i]=0.0; } } return(0); }
    Modifié le 2013-06-11 12:56:24 par AliX
  • wimz01 — en réponse à Picaban dans son message #78101

    Essaye avec ça, par compte ça te déclenche une petite mitraillette d'alerte c'est pas trés grave mais si JJ passe par là ou un autre codeur, vous avez peut-être une astuce

    Code
    //+------------------------------------------------------------------+ //| fisher.mq4 | //| Copyright 2013, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Black #property indicator_color2 Lime #property indicator_color3 Red extern int period=10; double ExtBuffer0[]; double ExtBuffer1[]; double ExtBuffer2[]; int init() { SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,Red); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,Lime); SetIndexStyle(2,DRAW_HISTOGRAM); IndicatorDigits(Digits+1); SetIndexBuffer(0,ExtBuffer0); SetIndexBuffer(1,ExtBuffer1); SetIndexBuffer(2,ExtBuffer2); IndicatorShortName("Fisher"); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); return(0); } int start() { //int period=10; int limit; int counted_bars=IndicatorCounted(); double prev,current,old; double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0; double price; double MinL=0; double MaxH=0; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)]; MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)]; price = (High[i]+Low[i])/2; Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1; Value=MathMin(MathMax(Value,-0.999),0.999); ExtBuffer0[i]=0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1; Value1=Value; Fish1=ExtBuffer0[i]; } bool up=true; for(i=limit-2; i>=0; i--) { current=ExtBuffer0[i]; prev=ExtBuffer0[i+1]; if (((current<0)&&(prev>0))||(current<0)) up= false; if (((current>0)&&(prev<0))||(current>0)) up= true; if (i==0) { if ((current<0)&&(prev>0)) Alert(" sell ", Close[0],"!!!"); if ((current>0)&&(prev<0)) Alert(" buy ", Close[0],"!!!"); } if(!up) { ExtBuffer2[i]=current; ExtBuffer1[i]=0.0; } else { ExtBuffer1[i]=current; ExtBuffer2[i]=0.0; } } return(0); }
  • wimz01

    J'ai simplement rajouter

    Code
    if (i==0) { if ((current<0)&&(prev>0)) Alert(" sell ", Close[0],"!!!"); if ((current>0)&&(prev<0)) Alert(" buy ", Close[0],"!!!"); }
    Modifié le 2013-06-11 15:29:32 par wimz01
  • Picaban

    Je te remercie.

    Donc là je vais voir si j'ai bien réussit à l'installer dans le bon fichier.
    Concretement l'alarme se déclenchera à quel moment ?

    Je confirme que sa marche mais que comme tu l'as dit quand s'est lancé ça ne s'arrete plus du tout mdrr.
    Comment je peux faire pour l'arreter (là à l'instant sa vient de s'arreter après plusieurs dizaines d'alarmes)

    En tout cas merci beaucoup de ton aide.
    Modifié le 2013-06-11 17:07:29 par AliX
  • wimz01

    essaye de mettre ça à la place

    Code
    if (i==1) { if ((current<0)&&(prev>0)) Alert(" sell ", Close[0],"!!!"); if ((current>0)&&(prev<0)) Alert(" buy ", Close[0],"!!!"); }
  • Picaban

    Je te remercie.
  • Yougo76

    Est-ce que vous savez où je pourrait trouver un indicateur CCI avec une alerte lorsque celui-ci croise le niveau 0 ? J'ai cherché partout sur internet et ceux que je trouve, soit ils ne marchent pas, soit l'alerte ne se produit pas ou elle se produit mais juste avec le sont (c'est à dire sans la petite fenêtre indiquant sur quelle paire le croisement est intervenu)

    Merci
  • furynick

    Si tu as le code de ton indic avec le son uniquement tu peux très simplement ajouter la fonction Alert("le CCI vient de croiser";); juste après la fonction PlaySound(xxx); et le tour est joué.
  • forexensemble

    Voici le code générant une alarme sonore que j'ai créé pour mes besoins et que j'utilise dans mes indicateurs

    Remplace [Test croisement lignes à la hausse] et [Test croisement lignes à la baisse] par le test nécessité par ton indicateur
    Code
    // Code générique pour déchancher des alerts dans des indicateurs // ALERT_BuySell est un parametre extern que j'utilise pour activer/désactiver l'alerte lors du lancement de l'indicateur if(ALERT_BuySell=true) { //variables gardées en mémoire pour éviter que l'alerte ne se reproduise à chaque tick static int iFlag,iFlagSound; if([Test croisement lignes à la hausse]&&iFlag!=1) { iFlag=1; if(iFlagSound!=1) { iFlagSound=1; //alert2 est le fichier son PlaySound("alert2");} } } if([Test croisement lignes à la à la baisse]&&iFlag!=2) { iFlag=2; if(iFlagSound!=2) { iFlagSound=2; PlaySound("alert2"); } } }
    Modifié le 2013-09-13 12:49:28 par forexensemble
  • yaelle

    Bonjour, je ne sais pas si ce post est encore d'actualité vu que le dernier message date de 2013 mais j'essaie en vain d'ajouter des fonctionnalités d'alerte et d'EA à un indicateur "scanner candle".
    Je suis à la recherche de piste ou de code source qui puisse me faire avancer dans ce projet.

    Voilà, je vous remercie!

    Bonne journée :)
  • jean760999 — en réponse à forexensemble dans son message #81612

    bonjour comment ajouter une alert sonnor sur cette indicateur merci


    //+------------------------------------------------------------------+
    //| Boa_ZigZag_Arrows_Duplex.mq5 |
    //| Copyright © 2005, MetaQuotes Software Corp. |
    //| [email protected] |
    //+------------------------------------------------------------------+
    //---- авторство индикатора
    #property copyright "Copyright © 2005, MetaQuotes Software Corp."
    //---- ссылка на сайт автора
    #property link "[email protected]"
    //---- номер версии индикатора
    #property version "1.00"
    #property description "Дв разнопериодных казахских удава"
    //---- отрисовка индикатора в основном окне
    #property indicator_chart_window
    //---- количество индикаторных буферов 4
    #property indicator_buffers 4
    //---- использовано всего четыре графических построения
    #property indicator_plots 4
    //+----------------------------------------------+
    //| Параметры отрисовки индикатора |
    //+----------------------------------------------+
    //---- отрисовка индикатора в виде значка
    #property indicator_type1 DRAW_ARROW
    //---- в качестве окраски индикатора использован
    #property indicator_color1 clrDodgerBlue
    //---- толщина линии индикатора равна 5
    #property indicator_width1 5
    //---- отображение метки сигнальной линии
    #property indicator_label1 "Slow Boa_ZigZag Dn"
    //+----------------------------------------------+
    //| Параметры отрисовки индикатора |
    //+----------------------------------------------+
    //---- отрисовка индикатора в виде значка
    #property indicator_type2 DRAW_ARROW
    //---- в качестве окраски индикатора использован
    #property indicator_color2 clrDeepPink
    //---- толщина линии индикатора равна 5
    #property indicator_width2 5
    //---- отображение метки сигнальной линии
    #property indicator_label2 "Slow Boa_ZigZag Up"
    //+----------------------------------------------+
    //| Параметры отрисовки бычьего индикатора |
    //+----------------------------------------------+
    //---- отрисовка индикатора 3 в виде значка
    #property indicator_type3 DRAW_ARROW
    //---- в качестве цвета бычей линии индикатора использован
    #property indicator_color3 clrAqua
    //---- толщина линии индикатора 3 равна 5
    #property indicator_width3 5
    //---- отображение бычьей метки индикатора
    #property indicator_label3 "Fast Boa_ZigZag Dn"
    //+----------------------------------------------+
    //| Параметры отрисовки медвежьего индикатора |
    //+----------------------------------------------+
    //---- отрисовка индикатора 4 в виде значка
    #property indicator_type4 DRAW_ARROW
    //---- в качестве цвета медвежьей линии индикатора использован
    #property indicator_color4 clrOrange
    //---- толщина линии индикатора 2 равна 5
    #property indicator_width4 5
    //---- отображение медвежьей метки индикатора
    #property indicator_label4 "Fast Boa_ZigZag Up"
    //+----------------------------------------------+
    //| Входные параметры индикатора |
    //+----------------------------------------------+
    input uint SlowLength=42; // период медленного зигзага
    input uint FastLength=6; // период быстрого зигзага
    //input int Shift=0; // Сдвиг индикатора по горизонтали в барах
    //+----------------------------------------------+
    //---- объявление динамических массивов, которые будут в
    //---- дальнейшем использованы в качестве индикаторных буферов
    double ZigzagLawnBuffer1[],ZigzagPeakBuffer1[];
    double ZigzagLawnBuffer2[],ZigzagPeakBuffer2[];
    //---- объявление целочисленных переменных начала отсчета данных
    int min_rates_total;
    //+------------------------------------------------------------------+
    //| Custom indicator initialization function |
    //+------------------------------------------------------------------+
    void OnInit()
    {
    //---- инициализация переменных начала отсчета данных
    min_rates_total=int(MathMax(SlowLength,FastLength))+1;

    //---- инициализации переменной для короткого имени индикатора
    string shortname;
    StringConcatenate(shortname,"Boa_ZigZag_Arrows_Duplex(",string(SlowLength),", ",string(FastLength),";)";);
    //---- создание имени для отображения в отдельном подокне и во всплывающей подсказке
    IndicatorSetString(INDICATOR_SHORTNAME,shortname);
    //---- определение точности отображения значений индикатора
    IndicatorSetInteger(INDICATOR_DIGITS,_Digits);

    //---- превращение динамического массива в индикаторный буфер
    SetIndexBuffer(0,ZigzagLawnBuffer1,INDICATOR_DATA);
    //---- осуществление сдвига индикатора по горизонтали на Shift
    //PlotIndexSetInteger(0,PLOT_SHIFT,Shift);
    //---- осуществление сдвига начала отсчета отрисовки индикатора
    PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
    //---- запрет на отрисовку индикатором пустых значений
    PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,NULL);
    //---- индексация элементов в буферах, как в таймсериях
    ArraySetAsSeries(ZigzagLawnBuffer1,true);
    //---- символ для индикатора
    PlotIndexSetInteger(0,PLOT_ARROW,162);

    //---- превращение динамического массива в индикаторный буфер
    SetIndexBuffer(1,ZigzagPeakBuffer1,INDICATOR_DATA);
    //---- осуществление сдвига индикатора по горизонтали на Shift
    //PlotIndexSetInteger(1,PLOT_SHIFT,Shift);
    //---- осуществление сдвига начала отсчета отрисовки индикатора
    PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total);
    //---- запрет на отрисовку индикатором пустых значений
    PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,NULL);
    //---- индексация элементов в буферах, как в таймсериях
    ArraySetAsSeries(ZigzagPeakBuffer1,true);
    //---- символ для индикатора
    PlotIndexSetInteger(1,PLOT_ARROW,162);

    //---- превращение динамического массива в индикаторный буфер
    SetIndexBuffer(2,ZigzagLawnBuffer2,INDICATOR_DATA);
    //---- осуществление сдвига индикатора 1 по горизонтали на Shift
    //PlotIndexSetInteger(2,PLOT_SHIFT,Shift);
    //---- осуществление сдвига начала отсчета отрисовки индикатора 1
    PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);
    //---- индексация элементов в буферах, как в таймсериях
    ArraySetAsSeries(ZigzagLawnBuffer2,true);
    //---- установка значений индикатора, которые не будут видимы на графике
    PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,NULL);
    //---- символ для индикатора
    PlotIndexSetInteger(2,PLOT_ARROW,159);

    //---- превращение динамического массива в индикаторный буфер
    SetIndexBuffer(3,ZigzagPeakBuffer2,INDICATOR_DATA);
    //---- осуществление сдвига индикатора 2 по горизонтали на Shift
    //PlotIndexSetInteger(3,PLOT_SHIFT,Shift);
    //---- осуществление сдвига начала отсчета отрисовки индикатора 2
    PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);
    //---- индексация элементов в буферах, как в таймсериях
    ArraySetAsSeries(ZigzagPeakBuffer2,true);
    //---- установка значений индикатора, которые не будут видимы на графике
    PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,NULL);
    //---- символ для индикатора
    PlotIndexSetInteger(3,PLOT_ARROW,159);
    //----
    }
    //+------------------------------------------------------------------+
    //| 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[])
    {
    //---- проверка количества баров на достаточность для расчета
    if(rates_total<min_rates_total) return(0);

    //---- объявления локальных переменных
    int limit,climit,bar;
    double HH,LL,BH,BL;
    int zu,zd,Swing,Swing_n;
    //----

    limit=rates_total-min_rates_total; // стартовый номер для расчёта всех баров
    climit=limit; // стартовый номер для раскраски индикатора

    //---- индексация элементов в массивах как в таймсериях
    ArraySetAsSeries(high,true);
    ArraySetAsSeries(low,true);
    //----
    Swing=0;
    Swing_n=0;
    zu=limit;
    zd=limit;
    BH=high[limit];
    BL=low[limit];
    //---- Цикл расчёта медленного зигзага
    for(bar=limit; bar>=0 && !IsStopped(); bar--)
    {
    ZigzagLawnBuffer1[bar]=NULL;
    ZigzagPeakBuffer1[bar]=NULL;

    HH=high[ArrayMaximum(high,bar+1,SlowLength)];
    LL=low[ArrayMinimum(low,bar+1,SlowLength)];
    if(low[bar]<LL && high[bar]>HH)
    {
    Swing=2;
    if(Swing_n== 1) zu=bar+1;
    if(Swing_n==-1) zd=bar+1;
    }
    else
    {
    if(low [bar]<LL) Swing=-1;
    if(high[bar]>HH) Swing= 1;
    }
    if(Swing!=Swing_n && Swing_n!=0)
    {
    if(Swing==2) {Swing=-Swing_n; BH=high[bar]; BL=low[bar];}
    if(Swing== 1)
    {
    if(BL==low[zd]) ZigzagLawnBuffer1[zd]=BL;
    else ZigzagLawnBuffer1[zd-1]=BL;
    }
    if(Swing==-1)
    {
    if(BH==high[zu]) ZigzagPeakBuffer1[zu]=BH;
    else ZigzagPeakBuffer1[zu-1]=BH;
    }
    BH=high[bar];
    BL=low [bar];
    }
    if(Swing== 1) {if(high[bar]>=BH) {BH=high[bar]; zu=bar;}}
    if(Swing==-1) {if(low [bar]<=BL) {BL=low [bar]; zd=bar;}}
    Swing_n=Swing;
    }
    //----
    Swing=0;
    Swing_n=0;
    zu=limit;
    zd=limit;
    BH=high[limit];
    BL=low[limit];
    //---- Цикл расчёта быстрого зигзага
    for(bar=limit; bar>=0 && !IsStopped(); bar--)
    {
    ZigzagLawnBuffer2[bar]=NULL;
    ZigzagPeakBuffer2[bar]=NULL;

    HH=high[ArrayMaximum(high,bar+1,FastLength)];
    LL=low[ArrayMinimum(low,bar+1,FastLength)];
    if(low[bar]<LL && high[bar]>HH)
    {
    Swing=2;
    if(Swing_n== 1) zu=bar+1;
    if(Swing_n==-1) zd=bar+1;
    }
    else
    {
    if(low [bar]<LL) Swing=-1;
    if(high[bar]>HH) Swing= 1;
    }
    if(Swing!=Swing_n && Swing_n!=0)
    {
    if(Swing==2) {Swing=-Swing_n; BH=high[bar]; BL=low[bar];}
    if(Swing== 1)
    {
    if(BL==low[zd]) ZigzagLawnBuffer2[zd]=BL;
    else ZigzagLawnBuffer2[zd-1]=BL;
    }
    if(Swing==-1)
    {
    if(BH==high[zu]) ZigzagPeakBuffer2[zu]=BH;
    else ZigzagPeakBuffer2[zu-1]=BH;
    }
    BH=high[bar];
    BL=low [bar];
    }
    if(Swing== 1) {if(high[bar]>=BH) {BH=high[bar]; zu=bar;}}
    if(Swing==-1) {if(low [bar]<=BL) {BL=low [bar]; zd=bar;}}
    Swing_n=Swing;
    }
    //----
    return(rates_total);
    }
    //+------------------------------------------------------------------+