Haut noch nicht ganz Hin aber sieht schonmal besser aus.
Code:
//+------------------------------------------------------------------+
//| SHARK_Stochastic_CLASSIC_V.2.1.0 - 1221 |
//| Copyright 2021 |
//| www.companyname.net |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Farbenauswahl |
//| |
//| Farbe 01 - C'35,248,48' - Grün |
//| Farbe 02 - C'204,0,15' - Rot |
//| Farbe 03 - C'93,219,231'- Hellblau |
//| Farbe 04 - C'248,86,13' - Orange |
//| Farbe 05 - C'204,0,183' - Magenta |
//| Farbe 06 - C'64,121,246'- Dunkelblau |
//| Farbe 07 - C'237,252,255'-Weiß |
//| Farbe 07 - C'254,239,79'- Hellgelb |
//| |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_minimum 0
#property indicator_maximum 100
extern string Inputs = "";
extern int K_Length = 5;
extern int K_Smoothing = 3;
extern int D_Smoothing = 3;
extern ENUM_MA_METHOD StoSignalMethod = MODE_SMA;
extern ENUM_APPLIED_PRICE APPLEY = PRICE_CLOSE;
extern ENUM_STO_PRICE PRICE_RANGE = 0;
extern string STYL = "";
extern string ALARM = "";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
string PriceTypeToString(int pt)
{
string answer;
switch(pt)
{
case 0:
answer = "Close" ;
break;
case 1:
answer = "Open" ;
break;
case 2:
answer = "High" ;
break;
case 3:
answer = "Low" ;
break;
case 4:
answer = "Median" ;
break;
case 5:
answer = "Typical" ;
break;
case 6:
answer = "Wighted" ;
break;
default:
answer = "Invalid price field requested";
Alert(answer);
}
return(answer);
}
string Name ="SHARK_STOCHASTIC_CLASSIC_V.2.1.0 - 1221 " + "("+K_Length +","+K_Smoothing+","+D_Smoothing+")";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int windowIndex=WindowFind(Name);
// ==================================== rectangle names
string NameTopLev=windowIndex+"LevelTop"; //50 -
string NameWaitUp=windowIndex+"LevelWaitTop"; // 55
string NameWaitLo=windowIndex+"LevelWaitBot"; //-45
string NameBotLev=windowIndex+"LevelBot"; //30
//+------------------------------------------------------------------+
//| Buffer |
//+------------------------------------------------------------------+
double SHARK_BUFFER_M[],SHARK_BUFFER_S[],TREND_BUFFER_UP[],TREND_BUFFER_DN[],SHARK_BUFFER_SIGNAL[];
bool initFinished=false;
datetime time_alert;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(5);
IndicatorDigits(Digits);//max. 2
SetIndexBuffer(0,SHARK_BUFFER_M,INDICATOR_DATA);
SetIndexStyle(0,DRAW_LINE,EMPTY,1,C'64,121,246');
SetIndexLabel(0,"MAIN");
SetIndexBuffer(1,SHARK_BUFFER_S,INDICATOR_DATA);
SetIndexStyle(1,DRAW_LINE,EMPTY,1,C'204,0,15');
SetIndexLabel(1,"SIGNAL");
SetIndexBuffer(2,TREND_BUFFER_UP,INDICATOR_DATA);
SetIndexStyle(2,DRAW_ARROW,EMPTY,2,C'0,255,0');
SetIndexArrow(2,119);
SetIndexLabel(2,NULL);
SetIndexBuffer(3,TREND_BUFFER_DN,INDICATOR_DATA);
SetIndexStyle(3,DRAW_ARROW,EMPTY,2,C'255,0,0');
SetIndexArrow(3,119);
SetIndexLabel(3,NULL);
SetIndexBuffer(4,SHARK_BUFFER_SIGNAL,INDICATOR_DATA);
SetIndexStyle(4,DRAW_NONE,EMPTY,1,clrNONE);
SetIndexLabel(4,"TREND");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
ObjectsDeleteAll();
// Löschen wir alle Objekte
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
//_CreateLevelChanel();
_Upper_Lower_Line();
int counted_bars=IndicatorCounted(),limit,i;
if(counted_bars<0)
return(-1);
if(counted_bars>0)
counted_bars--;
limit=MathMin(Bars-counted_bars,Bars-1);
for(i = limit; i >= 0 && !IsStopped(); i--)
{
SHARK_BUFFER_M[i]= iStochastic(Symbol(),Period(),K_Length,D_Smoothing,K_Smoothing,StoSignalMethod,PRICE_RANGE,MODE_MAIN,i);
SHARK_BUFFER_S[i]= iStochastic(Symbol(),Period(),K_Length,D_Smoothing,K_Smoothing,StoSignalMethod,PRICE_RANGE,MODE_SIGNAL,i);
SHARK_BUFFER_SIGNAL[i] = SHARK_BUFFER_M[i] - SHARK_BUFFER_S[i];
//+------------------------------------------------------------------+
//| TRENDSIGNAL - OVERBOUGHT |
//+------------------------------------------------------------------+
if((SHARK_BUFFER_S[i] <= 80) && (SHARK_BUFFER_S[i+1] >= 80) && (SHARK_BUFFER_S[i] > SHARK_BUFFER_M[i]))
{
bool TREND_UP = false;
TREND_BUFFER_DN[i+1] = SHARK_BUFFER_S[i+1];
bool TREND_DN = true;
}
if((SHARK_BUFFER_SIGNAL[i+1] >= 0) && (SHARK_BUFFER_SIGNAL[i] < 0)&& (SHARK_BUFFER_S[i] >= 20) && TREND_DN == true)
{
TREND_BUFFER_DN[i+1] = SHARK_BUFFER_S[i+1];
}
//+------------------------------------------------------------------+
//| TRENDSIGNAL - OVERSOLD |
//+------------------------------------------------------------------+
if((SHARK_BUFFER_S[i+1] <= 20) && (SHARK_BUFFER_S[i] >= 20) && (SHARK_BUFFER_S[i] < SHARK_BUFFER_M[i]))
{
TREND_DN = false;
TREND_BUFFER_UP[i+1] = SHARK_BUFFER_S[i+1];
TREND_UP = true;
}
if((SHARK_BUFFER_SIGNAL[i+1] <= 0) && (SHARK_BUFFER_SIGNAL[i] > 0)&& (SHARK_BUFFER_S[i] <=80) && TREND_UP == true)
{
TREND_BUFFER_UP[i+1] = SHARK_BUFFER_S[i+1];
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
return(0);
}
//+------------------------------------------------------------------+
//| OVERBOUGHT / OVERSOLD = 80 / 20 BEREICH |
//+------------------------------------------------------------------+
void _CreateLevelChanel()
{
if(true)
{
if(ObjectFind(0,NameTopLev)!=windowIndex)
if(!ObjectCreate(0,NameTopLev,OBJ_RECTANGLE,windowIndex,
Bars-1,50, //ChartBegin,70
Time[0],80) //Now,100
)
Print(__FUNCTION__+" "+NameTopLev+" failed, Code="+IntegerToString(_LastError));
ObjectSetInteger(0,NameTopLev,OBJPROP_COLOR,C'51,51,50');
if(ObjectFind(0,NameBotLev)!=windowIndex)
if(!ObjectCreate(0,NameBotLev,OBJ_RECTANGLE,windowIndex,
Bars-1,50, //ChartBegin,50
Time[0],20) //Now,500
)
Print(__FUNCTION__+" "+NameBotLev+" failed, Code="+IntegerToString(_LastError));
ObjectSetInteger(0,NameBotLev,OBJPROP_COLOR,C'51,51,50');
}
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| OVERBOUGHT / OVERSOLD = 80 / 20 LINIEN |
//+------------------------------------------------------------------+
void _Upper_Lower_Line()
{
// === get the subwin height in pixels
int SubWinHeightPix=ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,ChartWindowFind());
//Print(" Subwin height in pix: ",(int)SubWinHeightPix);
// === devide the height, so we get the equivalent for 80|20
int Equiv80=(int)MathRound(80*SubWinHeightPix/100);
int Equiv20=(int)MathRound(20*SubWinHeightPix/100);
if(initFinished==false)
{
IndicatorShortName(Name);
windowIndex=WindowFind(Name);
if(windowIndex<0)
{
// wenn die Nummer des Unterfensters -1 gleich ist, so tritt der Fehler auf
Print("Can\'t find window");
//return(0);
}
//+------------------------------------------------------------------+
//| OVERBOUGHT BEREICH 80.0 % LINIE |
//+------------------------------------------------------------------+
// wir zeichnen die Linie im Unterfenster unseres Indikators
ObjectCreate("Upperline",OBJ_HLINE,windowIndex,0,80);
ObjectSet("Upperline",OBJPROP_COLOR,C'35,248,48');
ObjectSet("Upperline",OBJPROP_WIDTH,1);
ObjectSet("Upperline",OBJPROP_STYLE,STYLE_DOT);
WindowRedraw();
// wir zeichnen das Fenster, damit wir die Linie sehen
//+------------------------------------------------------------------+
//| OVERBOUGHT BEREICH 80.0 % TEXT (AVT by www.expert-advisor.com) |
//+------------------------------------------------------------------+
ObjectCreate("UPPERTEXT",OBJ_LABEL,windowIndex,0,100);
//ObjectSet("UPPERTEXT",OBJPROP_XDISTANCE,5);
//ObjectSet("UPPERTEXT",OBJPROP_YDISTANCE,25);
ObjectSetInteger(0,"UPPERTEXT",OBJPROP_CORNER,CORNER_RIGHT_LOWER); //ReferenceWindowEdge
ObjectSetInteger(0,"UPPERTEXT",OBJPROP_ANCHOR,CORNER_LEFT_UPPER); //Example
ObjectSet("UPPERTEXT",OBJPROP_XDISTANCE,90); //hardcoded: 90
ObjectSetInteger(0,"UPPERTEXT",OBJPROP_YDISTANCE,Equiv80);
ObjectSetText("UPPERTEXT", "OVERBOUGHT",10,"Times New Roman",clrWhiteSmoke);
//+------------------------------------------------------------------+
//| OVERSOLD BEREICH 20.0 % LINIE |
//+------------------------------------------------------------------+
// wir zeichnen die Linie im Unterfenster unseres Indikators
ObjectCreate("Lowerline",OBJ_HLINE,windowIndex,0,20);
ObjectSet("Lowerline",OBJPROP_COLOR,C'204,0,15');
ObjectSet("Lowerline",OBJPROP_WIDTH,1);
ObjectSet("Lowerline",OBJPROP_STYLE,STYLE_DOT);
WindowRedraw();
// wir zeichnen das Fenster, damit wir die Linie sehen
//+------------------------------------------------------------------+
//| OVERSOLD BEREICH 20.0 % TEXT (AVT by www.expert-advisor.com) |
//+------------------------------------------------------------------+
ObjectCreate("LOWERTEXT",OBJ_LABEL,windowIndex,0,0);
ObjectSetInteger(0,"LOWERTEXT",OBJPROP_CORNER,CORNER_RIGHT_LOWER); //ReferenceWindowEdge
ObjectSetInteger(0,"LOWERTEXT",OBJPROP_ANCHOR,CORNER_LEFT_UPPER); //Example
ObjectSetInteger(0,"LOWERTEXT",OBJPROP_YDISTANCE,Equiv20);
ObjectSet("LOWERTEXT",OBJPROP_XDISTANCE,72); //hardcoded: 72
ObjectSetText("LOWERTEXT", "OVERSOLD",10,"Times New Roman",clrWhiteSmoke);
initFinished=true;
// Das Zeichen wurde schon beendet
}
}
//+------------------------------------------------------------------+