Indikator Notification - Ask, Bid, TP, SL anzeigen lassen

 
Ich benötige Hilfe!

Ich bin neu und habe quasi kein richtiges wissen vom Programmieren.

Mein Indikator soll mir eigentlich folgende Notification schicken, sobald ein Signal generiert wird:

#EURUSD - Long @1.21691

Alle meine Bemühungen, den Preis bei einem Signal zu integriere, sind fehlgeschlagen und ich weiß nicht mehr weiter.

ich hoffe das mir einer weiterhelfen kann.

Ich nutze den Trendsignal Indikator von Pankaj Bhaban mit leichten anpassungen.

//+------------------------------------------------------------------+
//|                                        Trendsignal Indicator.mq5 |
//|                                    Copyright 2015, Pankaj Bhaban |
//|                                     http://www.trendsignal.co.in |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Pankaj Bhaban"
#property link      "http://www.trendsignal.co.in"

input bool EMailON=false; //Mail-Sendesignal zulassen
input bool PushON=true; //Signals an das Handy zulassen

input int RISK=
    21; // signal sensitivity control
input int SSP=
    2;  // signal displacement
int NumberofAlerts=1;

double SellBuffer[];
double BuyBuffer[];

int K;
int counter=0;
bool pre,BT;

#property version   "1.00"
#property indicator_chart_window 
#property indicator_buffers 2
#property indicator_plots   2
#property indicator_type1   DRAW_ARROW
#property indicator_color1  Red
#property indicator_width1  2
#property indicator_label1  "Trendsignal Sell"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  Lime
#property indicator_width2  2
#property indicator_label2 "Trendsignal Buy"

int StartBars;
//+------------------------------------------------------------------+
//| Initialization and checking for input parameters                 |
//+------------------------------------------------------------------+
void OnInit()
  {

   StartBars=SSP+1;
SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA);
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,StartBars);
PlotIndexSetString(1,PLOT_LABEL,"Trendsignal Buy");
PlotIndexSetInteger(1,PLOT_ARROW,233);
ArraySetAsSeries(BuyBuffer,true);
   
SetIndexBuffer(0,SellBuffer,INDICATOR_DATA);
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartBars);
PlotIndexSetString(0,PLOT_LABEL,"Trendsignal Sell");
PlotIndexSetInteger(0,PLOT_ARROW,234);
ArraySetAsSeries(SellBuffer,true);
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
string short_name="Trendsignal";
IndicatorSetString(INDICATOR_SHORTNAME,short_name);
   
  }

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<StartBars) return(0);


   int limit;
   double Range,AvgRange,smin,smax,SsMax,SsMin,price;
   bool uptrend;

   if(prev_calculated>rates_total || prev_calculated<=0)
     {
      K=33-RISK;
      limit=rates_total-StartBars;      
     }
   else
     {
      limit=rates_total-prev_calculated; 
     }


   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);


   uptrend=BT;


   for(int bar=limit; bar>=0; bar--)
     {
     
      if(rates_total!=prev_calculated && bar==0)
        {
         BT=uptrend;
        }

      Range=0;
      AvgRange=0;
      for(int iii=bar; iii<=bar+SSP; iii++) AvgRange=AvgRange+MathAbs(high[iii]-low[iii]);
      Range=AvgRange/(SSP+1);
      //----
      SsMax=low[bar];
      SsMin=close[bar];

      for(int kkk=bar; kkk<=bar+SSP-1; kkk++)
        {
         price=high[kkk];
         if(SsMax<price) SsMax=price;
         price=low[kkk];
         if(SsMin>=price) SsMin=price;
        }

      smin=SsMin+(SsMax-SsMin)*K/100;
      smax=SsMax-(SsMax-SsMin)*K/100;

      SellBuffer[bar]=0;
      BuyBuffer[bar]=0;

      if(close[bar]<smin) uptrend=false;
      if(close[bar]>smax) uptrend=true;

      if(uptrend!=pre && uptrend==true)
        {
         BuyBuffer[bar]=low[bar]-Range*0.5;

         if(bar==0)
           {
            if(counter<=NumberofAlerts)
              {
               SendNotification ( "#" + Symbol() + " - " + "Long" + " @" ); 
               counter++;    
              }
           }
         else counter=0;
        }
      if(uptrend!=pre && uptrend==false)
        {
         SellBuffer[bar]=high[bar]+Range*0.5;

         if(bar==0)
           {
            if(counter<=NumberofAlerts)
              {
               SendNotification ( "#" + Symbol() + " - " + "Short" + " @" );
               counter++;
              }
           }
         else counter=0;
        }

      if(bar>0) pre=uptrend;
     }
//----     
   return(rates_total);
  }
//+------------------------------------------------------------------+


Gerne würde ich auch noch eine auto TP SL Funktion hinzufügen, auf Basis des generierten Signale mit einem 70/30 Verhältnisse.

Die Folgende Notification sollten dann wie folgt aussehen:

#EURUSD - Long @1.21691 TP: 1.21761 SL: 1.21661

Hierbei bin ich komplett überfragt.


Vielen dank schonmal im Vorraus!😊




 

Was willst Du wo integrieren?

Variable? Codezeile?

 
Carl Schreiber:

Was willst Du wo integrieren?

Variable? Codezeile?

Ich habe es selber gelöst mithilfe der Code von @Nikolay Kositsi


die Lösung:

     }
     
   BuySignal("Advanced fractals(",BufferUpFactal,rates_total,prev_calculated,close,spread);
   SellSignal("Advanced fractals(",BufferDownFractal,rates_total,prev_calculated,close,spread);
//--- return value of prev_calculated for next call
   return(rates_total);
  }

//+------------------------------------------------------------------+
//| Buy signal function                                              |
//+------------------------------------------------------------------+
void BuySignal(string SignalSirname,      // текст имени индикатора для почтовых и пуш-сигналов
               double &BuyArrow[],        // индикаторный буфер с сигналами для покупки
               const int Rates_total,     // текущее количество баров
               const int Prev_calculated, // количество баров на предыдущем тике
               const double &Close[],     // цена закрытия
               const int &Spread[])       // спред
  {
//---
   static uint counter=0;
   if(Rates_total!=Prev_calculated) counter=0;

   bool BuySignal=false;
   bool SeriesTest=ArrayGetAsSeries(BuyArrow);
   int index;
   if(SeriesTest) index=int(NumberofBar);
   else index=Rates_total-int(NumberofBar)-1;
   if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) BuySignal=true;
   if(BuySignal && counter<=NumberofAlerts)
     {
      counter++;
      MqlDateTime tm;
      TimeToStruct(TimeCurrent(),tm);
      string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
      SeriesTest=ArrayGetAsSeries(Close);
      if(SeriesTest) index=int(NumberofBar);
      else index=Rates_total-int(NumberofBar)-1;
      double Ask=Close[index];
      double Bid=Close[index];
      SeriesTest=ArrayGetAsSeries(Spread);
      if(SeriesTest) index=int(NumberofBar);
      else index=Rates_total-int(NumberofBar)-1;
      Bid+=Spread[index]*_Point;
      string sAsk=DoubleToString(Ask,_Digits);
      string sBid=DoubleToString(Bid,_Digits);
      string sPeriod=GetStringTimeframe(ChartPeriod());
      if(SoundON) Alert("BUY signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
      if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
      if(PushON) SendNotification( "#" + Symbol()+ "  - " + " Long @"+sBid+"");
     }

//---
  }
//+------------------------------------------------------------------+
//| Sell signal function                                             |
//+------------------------------------------------------------------+
void SellSignal(string SignalSirname,      // текст имени индикатора для почтовых и пуш-сигналов
                double &SellArrow[],       // индикаторный буфер с сигналами для покупки
                const int Rates_total,     // текущее количество баров
                const int Prev_calculated, // количество баров на предыдущем тике
                const double &Close[],     // цена закрытия
                const int &Spread[])       // спред
  {
//---
   static uint counter=0;
   if(Rates_total!=Prev_calculated) counter=0;

   bool SellSignal=false;
   bool SeriesTest=ArrayGetAsSeries(SellArrow);
   int index;
   if(SeriesTest) index=int(NumberofBar);
   else index=Rates_total-int(NumberofBar)-1;
   if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) SellSignal=true;
   if(SellSignal && counter<=NumberofAlerts)
     {
      counter++;
      MqlDateTime tm;
      TimeToStruct(TimeCurrent(),tm);
      string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
      SeriesTest=ArrayGetAsSeries(Close);
      if(SeriesTest) index=int(NumberofBar);
      else index=Rates_total-int(NumberofBar)-1;
      double Ask=Close[index];
      double Bid=Close[index];
      SeriesTest=ArrayGetAsSeries(Spread);
      if(SeriesTest) index=int(NumberofBar);
      else index=Rates_total-int(NumberofBar)-1;
      Bid+=Spread[index]*_Point;
      string sAsk=DoubleToString(Ask,_Digits);
      string sBid=DoubleToString(Bid,_Digits);
      string sPeriod=GetStringTimeframe(ChartPeriod());
      if(SoundON) Alert("SELL signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
      if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
      if(PushON) SendNotification( "#" + Symbol()+ "  - " + " Short @"+sAsk+"");
     }
//---
  }
//+------------------------------------------------------------------+
//|  Получение таймфрейма в виде строки                              |
//+------------------------------------------------------------------+
string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
  {
//----
   return(StringSubstr(EnumToString(timeframe),7,-1));
//----
  }
//+------------------------------------------------------------------+