Einzelnen Beitrag anzeigen
  #4 (permalink)  
Alt 04.09.19
AVT AVT ist offline
Elite Mitglied
 
Registriert seit: Mar 2018
Ort: Hamburg
Beiträge: 612
AVT befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von Max2018 Beitrag anzeigen
Mir ging es nur um die Frage, wie ein Objekt erzeugt werden kann, was man dann aber nicht in der Objektliste sehen kann......
über Buffer so (haste lauter Bomben im Chart):
Code:
//=============================================================================
#property copyright   "© BigSister"
#property description "object demo"
#property strict

#property indicator_chart_window

#property indicator_buffers 3
#property indicator_color1 clrGold       // object
#property indicator_width1 2 
#property indicator_color2 clrLimeGreen  // faster line
#property indicator_color3 clrMagenta    // slower line

//=============================================================================
extern int    EMA1peri     = 10;    // Ema1 Period
extern int    EMA2peri     = 20;    // Ema2 Period
extern int    WinDiNo      = 77;    // Wingdings Symbol number
extern bool   ShowLines    = false; // Show lines

//=============================================================================
// --- buffers 
double Ema1Buff[];
double Ema2Buff[];
double ObjectBuff[];

//=============================================================================
int OnInit(void)
{
   IndicatorDigits(Digits);
   IndicatorShortName("DemoOBJ");
   
   IndicatorBuffers(3);
   
   SetIndexBuffer(0,ObjectBuff);                     // signal object
   SetIndexLabel(0,"Object");
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,WinDiNo);
   
   SetIndexBuffer(1,Ema1Buff);                       // faster line
   SetIndexLabel(1,"Ema1");
   if(ShowLines==true) SetIndexStyle(1,DRAW_LINE);
   else                SetIndexStyle(1,DRAW_NONE);
   
   SetIndexBuffer(2,Ema2Buff);                       // slower line
   SetIndexLabel(2,"Ema2");
   if(ShowLines==true) SetIndexStyle(2,DRAW_LINE);
   else                SetIndexStyle(2,DRAW_NONE);
   
   return(INIT_SUCCEEDED);
}

//=============================================================================
void OnDeinit(const int reason)
{
   // == print code why we were deinitialized
   Print(__FUNCTION__," DeInit reason code = ",reason);
}

//=============================================================================
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 limit=rates_total-prev_calculated;
   if(prev_calculated>0) limit++;
   limit=Bars-MathMax(EMA1peri,EMA2peri);
   
   for(int i=limit; i>0; i--) 
   {
      Ema1Buff[i]=iMA(NULL,0,EMA1peri,0,MODE_EMA,PRICE_CLOSE,i);
      Ema2Buff[i]=iMA(NULL,0,EMA2peri,0,MODE_EMA,PRICE_CLOSE,i);
    
      if     (   Ema1Buff[i+1]>=Ema2Buff[i+2]  //previous 1above2 now 1below2
              && Ema1Buff[i]<=Ema2Buff[i+1] )  ObjectBuff[i]=Ema1Buff[i+1];
      else if(   Ema1Buff[i+1]<=Ema2Buff[i+2]  // previous 1below2 now 1above2
              && Ema1Buff[i]>=Ema2Buff[i+1])   ObjectBuff[i]=Ema1Buff[i+1];
      else                                     ObjectBuff[i]=EMPTY_VALUE;
  }
   
   //== return the value of prev_calculated for next call
   return(rates_total);
}
//=============================================================================