Einzelnen Beitrag anzeigen
  #1 (permalink)  
Alt 15.03.13
daysofthunder daysofthunder ist offline
Mitglied
 
Registriert seit: Aug 2012
Beiträge: 30
daysofthunder befindet sich auf einem aufstrebenden Ast
Standard ema mit spitzen wie ?

hallo leute ich habe ein problem. ich hab nen quellcode gefunden der ne ema hinmalt wie ich sie brache. weiterhin hab ich einen anzeiger gebastelt der bei ner spitze also der vorige und der folgende balken höher/tiefer nen signal zeigt.
jetzt möchte ich das aber kombiniert haben und das klappt irgendwie nicht.
sprich, wenn die ermittelte spitze genau an der ema +-0,5p dreht, soll das signal kommen. wie mache ich das ?

code ema:
#property copyright "Copyright © 2010, LeMAn."
#property link "b-market@mail.ru"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//----
extern double MA_Period = 13;
extern double Coef = 0.0;
extern int MA_Shift = 0;
extern int SetPrice = 0;
//----
double ExtMapBuffer[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
int init() {
int draw_begin;
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//----
SetIndexStyle(0, DRAW_LINE);
SetIndexShift(0, MA_Shift);
if (MA_Period < 2) MA_Period = 13;
draw_begin = 0;
//----
IndicatorShortName("EMA(" + MA_Period + ")");
SetIndexDrawBegin(0, draw_begin);
//----
SetIndexBuffer(0, ExtMapBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
int start() {
if (Bars <= MA_Period) return(0);
ExtCountedBars = IndicatorCounted();
if (ExtCountedBars < 0) return(-1);
if (ExtCountedBars > 0) ExtCountedBars--;
//----
ema();
//----
return(0);
}
//----
void ema() {
double pr;
if (Coef == 0.0) {
pr = 2.0/(MA_Period+1);
} else {
pr = Coef;
}
int pos = Bars-2;
if (ExtCountedBars > 2) pos = Bars - ExtCountedBars - 1;
//---- main calculation loop
while (pos >= 0) {
if (pos == Bars - 2)
ExtMapBuffer[pos+1] = (Open[pos+1]+Close[pos+1])/2;
ExtMapBuffer[pos] = GetPrice(pos)*pr+ExtMapBuffer[pos+1]*(1-pr);
pos--;
}
}
//+------------------------------------------------------------------+
double GetPrice(int Shift) {
double price;
//----
switch(SetPrice) {
case 0: price = Close[Shift]; break;
case 1: price = Open[Shift]; break;
case 2: price = High[Shift]; break;
case 3: price = Low[Shift]; break;
case 4: price = (High[Shift]+Low[Shift])/2.0; break;
case 5: price = (High[Shift]+Low[Shift]+Close[Shift])/3.0; break;
case 6: price = (High[Shift]+Low[Shift]+2*Close[Shift])/4.0; break;
case 7: price = (Open[Shift]+High[Shift]+Low[Shift]+Close[Shift])/4.0; break;
case 8: price = (Open[Shift]+Close[Shift])/2.0; break;
default: price = 0.0;
}
//----
return(price);
}

code spitze:
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Black

//---- buffers
double v1[];
double v2[];
double v3[];
double val1;
double val2;
double val3;
int i;

int init()
{

IndicatorBuffers(4);

//---- drawing settings
SetIndexArrow(0, 119);
SetIndexArrow(1, 119);
SetIndexArrow(2, 119);

SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1,Red);
SetIndexDrawBegin(0,i-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Widerstand");


SetIndexStyle(1,DRAW_ARROW,STYLE_DASH,1,Blue);
SetIndexDrawBegin(1,i-1);
SetIndexBuffer(1, v2);
SetIndexLabel(1,"Unterstuetzung");

return(0);
}

int start(){
i=Bars;

while(i>=0){
//eine linie 5 kerzen weit zeichnen
val1 = iFractals(NULL, 0, MODE_UPPER,i);
int h=0,l=0;
//hoch spitzen raussuchen
if(High[i]>=High[i+1]&&High[i]>=High[i-1])
h++;

if(h==1)
v1[i]=High[i];




//tief spitzen raussuchen
val2 = iFractals(NULL, 0, MODE_LOWER,i);
if(Low[i]<Low[i+1] && Low[i]<=Low[i-1])
l++;

if(l==1)
v2[i]=Low[i];


i--;
}

return(0);
}