|
Startseite | Registrieren | Hilfe | Benutzerliste | Kalender | Suchen | Heutige Beiträge | Alle Foren als gelesen markieren |
Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4. |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
Neues Projekt
Project 1 = STOCHASTIC
LONG und SHORT Signale kommen von der Mainlinie sowie Signallinie es folgt demnächst noch das Trendsignal. Ihr werdet sehen die dritte wieder gabe ist sehr hilfreich beim Traden. ich bin für Anregungen und änderungen gerne offen wo man was noch verbessern kann. FOLGEARBEITEN: Trendsignal wiedergeben als Punkt Alert Code:
//+------------------------------------------------------------------+ //| SHARK_Stochastic_CLASSIC_V.2.1.0 - 1121 | //| 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 SETTING = ""; extern int K_PERIOD = 5; extern int D_PERIOD = 3; extern int Slowing = 3; extern int Upper_Limit = 80; extern int Lower_Limit = 20; 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 color Upper_Color = C'204,0,15'; extern color Lower_Color = C'35,248,48'; extern color Hlines_Background = C'51,31,52'; 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 - 1121 " + "("+K_PERIOD +","+ D_PERIOD+","+Slowing+","+PriceTypeToString(APPLEY)+","+Upper_Limit+","+Lower_Limit+")"; //+------------------------------------------------------------------+ //| 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[],SHARK_BUFFER_UP[],SHARK_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,SHARK_BUFFER_UP,INDICATOR_DATA); SetIndexStyle(2,DRAW_ARROW,EMPTY,2,C'0,255,0'); SetIndexArrow(2,159); SetIndexLabel(2,NULL); SetIndexBuffer(3,SHARK_BUFFER_DN,INDICATOR_DATA); SetIndexStyle(3,DRAW_ARROW,EMPTY,2,C'255,0,0'); SetIndexArrow(3,159); 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_Limit,Lower_Limit,Hlines_Background); _Upper_Lower_Line(Upper_Limit,Lower_Limit,Upper_Color,Lower_Color); 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_PERIOD,D_PERIOD,Slowing,StoSignalMethod,PRICE_RANGE,MODE_MAIN,i); SHARK_BUFFER_S[i]= iStochastic(Symbol(),Period(),K_PERIOD,D_PERIOD,Slowing,StoSignalMethod,PRICE_RANGE,MODE_SIGNAL,i); SHARK_BUFFER_SIGNAL[i] = SHARK_BUFFER_M[i] - SHARK_BUFFER_S[i]; //+------------------------------------------------------------------+ //| LONG - TRENDSIGNAL | //+------------------------------------------------------------------+ if(((SHARK_BUFFER_S[i] >= 20) && ( SHARK_BUFFER_S[i+1] <= 20 )) || ((SHARK_BUFFER_M[i] >= 20) && ( SHARK_BUFFER_M[i+1] <= 20 ) && (SHARK_BUFFER_M[i] > SHARK_BUFFER_S[i]) &&( SHARK_BUFFER_S[i] < 20 )) ) { SHARK_BUFFER_UP[i+1] = SHARK_BUFFER_M[i+1]; SHARK_BUFFER_UP[i+1] = SHARK_BUFFER_S[i+1]; } //+------------------------------------------------------------------+ //| SHORT - TRENDSIGNAL | //+------------------------------------------------------------------+ if(((SHARK_BUFFER_S[i] <= 80) && ( SHARK_BUFFER_S[i+1] >= 80 )) || ((SHARK_BUFFER_M[i] <= 80) && ( SHARK_BUFFER_M[i+1] >= 80 ) && (SHARK_BUFFER_M[i] < SHARK_BUFFER_S[i]) &&( SHARK_BUFFER_S[i] > 80 ))) { SHARK_BUFFER_DN[i+1] = SHARK_BUFFER_M[i+1];SHARK_BUFFER_DN[i+1] = SHARK_BUFFER_S[i+1]; } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void _CreateLevelChanel(int Upper, int Lower, color BG) { if(true) { if(ObjectFind(0,NameTopLev)!=windowIndex) if(!ObjectCreate(0,NameTopLev,OBJ_RECTANGLE,windowIndex, Bars-1,80, //ChartBegin,70 Time[0],100) //Now,100 ) Print(__FUNCTION__+" "+NameTopLev+" failed, Code="+IntegerToString(_LastError)); ObjectSetInteger(0,NameTopLev,OBJPROP_COLOR,C'2,51,4'); if(ObjectFind(0,NameBotLev)!=windowIndex) if(!ObjectCreate(0,NameBotLev,OBJ_RECTANGLE,windowIndex, Bars-1,20, //ChartBegin,50 Time[0],0) //Now,500 ) Print(__FUNCTION__+" "+NameBotLev+" failed, Code="+IntegerToString(_LastError)); ObjectSetInteger(0,NameBotLev,OBJPROP_COLOR,C'51,0,4'); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void _Upper_Lower_Line(int UPPER_HEIGHT, int LOWER_DEPTH, color HEIGHT_COLOR, color DEPTH_COLOR) { 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 % | //+------------------------------------------------------------------+ ObjectCreate("UPPERTEXT",OBJ_LABEL,windowIndex,0,LOWER_DEPTH); ObjectSet("UPPERTEXT",OBJPROP_XDISTANCE,5); ObjectSet("UPPERTEXT",OBJPROP_YDISTANCE,25); ObjectSetText("UPPERTEXT", "OVERBOUGHT",10,"Times New Roman",clrWhiteSmoke); // wir zeichnen die Linie im Unterfenster unseres Indikators ObjectCreate("Upperline",OBJ_HLINE,windowIndex,0,LOWER_DEPTH); ObjectSet("Upperline",OBJPROP_COLOR,HEIGHT_COLOR); ObjectSet("Upperline",OBJPROP_WIDTH,1); ObjectSet("Upperline",OBJPROP_STYLE,STYLE_DOT); WindowRedraw(); // wir zeichnen das Fenster, damit wir die Linie sehen //+------------------------------------------------------------------+ //| OVERSOLD BEREICH 20 % | //+------------------------------------------------------------------+ ObjectCreate("LOWERTEXT",OBJ_LABEL,windowIndex,0,LOWER_DEPTH); ObjectSet("LOWERTEXT",OBJPROP_XDISTANCE,5); ObjectSet("LOWERTEXT",OBJPROP_YDISTANCE,175); ObjectSetText("LOWERTEXT", "OVERSOLD",10,"Times New Roman",clrWhiteSmoke); // wir zeichnen die Linie im Unterfenster unseres Indikators ObjectCreate("Lowerline",OBJ_HLINE,windowIndex,0,UPPER_HEIGHT); ObjectSet("Lowerline",OBJPROP_COLOR,DEPTH_COLOR); ObjectSet("Lowerline",OBJPROP_WIDTH,1); ObjectSet("Lowerline",OBJPROP_STYLE,STYLE_DOT); WindowRedraw(); // wir zeichnen das Fenster, damit wir die Linie sehen initFinished=true; // Das Zeichen wurde schon beendet } } //+------------------------------------------------------------------+ [IMG]bilderupload.org/bild/118359332-stochastic[/IMG] Link zum Bild fals nicht angezeigt wird |
|
|||
Fehler
wie beomme ich das Hin das wenn man nur Ein Fenster hat. Geht das OVERSOLD leider wo anders hin soll aber immer da unten im Rotenbereich bleiben.
und wenn wir gleich dabei sind wie kann ich das anzeigen lassen (Rechts oder links) Rechts wäre besser als links |
|
|||
In Deiner Funktion void _Upper_Lower_Line
zu Begin einfügen: Code:
// === 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 ); Dann bei den Labeln ändern: Code:
//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); //ObjectSet("LOWERTEXT",OBJPROP_XDISTANCE,5); //ObjectSet("LOWERTEXT",OBJPROP_YDISTANCE,175); 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 Ich habe die Zahlen hier mal an Deine Werte angepaßt. Komplizierter wird es, wenn die Fontgröße und evtl. sogar noch der Font selber vom Benutzer festzulegen ist, dann sind einige andere Verhältnisrechnungen fällig. Kannst Du als Vorlage für Tests nehmen. AVT |
|
|||
Update V.2.1.0 - 1221
Haut noch nicht ganz Hin aber sieht schonmal besser aus.
Signale = 100 % Linien 80 / 20 = 100 % Text = 90 % Alert = 0 % Level Channel = 0% wurde erstmal deaktiviert 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 } } //+------------------------------------------------------------------+ |
|
|||
Update V.2.1.0 - 1221
OVERBOUGHT | OVERSOLD = 100 %
LONG | SHORT - SIGNALE = 100 % 80 | 20 Linie = 100% Levelchanel = deaktiviert vorerst Alert in arbeit 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 //+------------------------------------------------------------------+ //| EINSTELLUNGEN | //+------------------------------------------------------------------+ 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_TEXT,1,Time[WindowFirstVisibleBar()],90); 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,0); 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_TEXT,1,Time[WindowFirstVisibleBar()],30); ObjectSetInteger(0,"LOWERTEXT",OBJPROP_CORNER,CORNER_RIGHT_LOWER); //ReferenceWindowEdge ObjectSetInteger(0,"LOWERTEXT",OBJPROP_ANCHOR,CORNER_LEFT_UPPER); //Example ObjectSetInteger(0,"LOWERTEXT",OBJPROP_YDISTANCE,90); ObjectSet("LOWERTEXT",OBJPROP_XDISTANCE,0); //hardcoded: 72 ObjectSetText("LOWERTEXT", "OVERSOLD",10,"Times New Roman",clrWhiteSmoke); initFinished=true; // Das Zeichen wurde schon beendet } } //+------------------------------------------------------------------+ |
|
|||
Code:
int deinit() { ObjectsDeleteAll(); // Löschen wir alle Objekte return(0); } Entschuldige, daß ich da so heftig werde, ich habe mir schon x-mal meine Charts versaut, weil ich einen Indikator auf einen Arbeitschart losgelassen hatte (mache ich auch nie wieder). Darum bitte nie einfach alle Objekte löschen. Danke. AVT |
|
|||
Projekt RSI
RSI wurde bearbeitet aber den Fehler das die Signal mal unten angzeigt werden und mal oben kann ich noch nicht beantworten bei folgen Symbolen kommen die Signale oben Gold;Eth bei Symbolen kommen Signale nur unten :-( EURUSD,u.s.w.
Overbought & Oversould Linien sind zu 100 % Signale für Sell und Buy sind zu 100 % Show Arrows zu 85 % Alert zu 0% Telegramm 0% Preislinie zu 0% RSI Channel zu 0% da ich erstmal schauen muss wie ich das Transperrent bekomme und das es Nicht an der Aktuellen Kerze stehen bleibt und erst wandert wenn die kerze vorbei ist. Bild kommt dazu wie es jetzt auszieht und wie ich es haben möchte :-). Code:
//+------------------------------------------------------------------+ //| SHARK_RSI_CLASSIC_V.22 - 0122 | //| Copyright 2020 | //| www.expert-advisor.com | //+------------------------------------------------------------------+ #property copyright "Sirocool" #property link "http://www.expert-advisor.com/forum/members/sirocool.html" //#property icon "\\Images\\Icon\\Shark.ico" extern string a_SHARK_SETTINGS ="~~* RSI Settings *~~"; extern int Fast_Length = 14; extern int Over_Up = 30; extern int Over_Dn = 70; extern ENUM_APPLIED_PRICE SOURCE = PRICE_CLOSE; extern string b_SHARK_SETTINGS ="~~* RSI Settings Styl *~~"; extern string c_SHARK_SETTINGS ="~~* RSI Settings Alert *~~"; extern bool ShowArrows = true; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 3 #property indicator_minimum 0 #property indicator_maximum 100 //+------------------------------------------------------------------+ //| ENUM_APPLIED_PRICE | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| IndicatorShortName | //+------------------------------------------------------------------+ string Name ="SHARK_RSI_CLASSIC_V.21"+"( "+ Fast_Length +","+PriceTypeToString(SOURCE)+","+ Over_Up+","+Over_Dn+")"; int windowIndex=WindowFind(Name),maxArrows; //==================================== rectangle names string NameTopLev=windowIndex+"LevelTop"; //50 - string NameWaitUp=windowIndex+"LevelWaitTop"; // 55 string NameWaitLo=windowIndex+"LevelWaitBot"; //-45 string NameBotLev=windowIndex+"LevelBot"; //30 double SHARK_BUFFER_M[],SHARK_BUFFER_ARROW_UP[],SHARK_BUFFER_ARROW_DN[]; bool ExtParameters=false, initFinished=false; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); IndicatorDigits(Digits);//max. 2 SetIndexBuffer(0,SHARK_BUFFER_M,INDICATOR_DATA); // RSI_LINIE SetIndexStyle(0,DRAW_LINE,EMPTY,1,clrRoyalBlue); SetIndexDrawBegin(0,Fast_Length); SetIndexLabel(0,"RSI"); SetIndexBuffer(1,SHARK_BUFFER_ARROW_UP,INDICATOR_DATA); SetIndexStyle(1, DRAW_ARROW, EMPTY,1,clrForestGreen); SetIndexArrow(1, 241); SetIndexLabel(1,NULL); SetIndexBuffer(2,SHARK_BUFFER_ARROW_DN,INDICATOR_DATA); SetIndexStyle(2, DRAW_ARROW, EMPTY,1,clrFireBrick); SetIndexArrow(2, 242); SetIndexLabel(2,NULL); if(Fast_Length<=1) { Print("Wrong input parameters"); ExtParameters=false; return(INIT_FAILED); } else ExtParameters=true; return(INIT_SUCCEEDED); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int deinit() { DeleteArrows(); //ObjectsDeleteAll(); //ObjectDelete(); //deleteArrows(); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ _Overlines(Over_Up,Over_Dn,false); 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] = iRSI(Symbol(),Period(),Fast_Length,SOURCE,i); //+------------------------------------------------------------------+ //| SHARK_SHOW_ARROWS | //+------------------------------------------------------------------+ if(ShowArrows) { //+------------------------------------------------------------------+ //| SHARK_SHORT_SIGNAL | //+------------------------------------------------------------------+ if((SHARK_BUFFER_M[i] < Over_Dn) && (SHARK_BUFFER_M[i+1] > Over_Dn)) { SHARK_BUFFER_ARROW_DN[i+1] = High[i+1]+90; } if((SHARK_BUFFER_M[i] < Over_Dn) && (SHARK_BUFFER_M[i+1] > Over_Dn)) { DrawArrow(i+1,"Dn"); } //+------------------------------------------------------------------+ //| SHARK_LONG_SIGNAL | //+------------------------------------------------------------------+ if((SHARK_BUFFER_M[i] > Over_Up) && (SHARK_BUFFER_M[i+1] < Over_Up)) { SHARK_BUFFER_ARROW_UP[i+1] = Low[i+1]+5; } if((SHARK_BUFFER_M[i] > Over_Up) && (SHARK_BUFFER_M[i+1] < Over_Up)) { DrawArrow(i+1,"Up"); } } } return(0); } //+------------------------------------------------------------------+ //| Extras | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Overline 70 / 30 | //+------------------------------------------------------------------+ void _Overlines(int Up, int Dn) { if(initFinished==false) { IndicatorShortName(Name); windowIndex=WindowFind(Name); if(windowIndex<0) { Print("Can\'t find window"); return; } ObjectCreate("OVERSOLDLINE",OBJ_HLINE,windowIndex,0,Up); ObjectSet("OVERSOLDLINE",OBJPROP_COLOR,clrGreen); ObjectSet("OVERSOLDLINE",OBJPROP_WIDTH,1); ObjectSet("OVERSOLDLINE",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("SHORTLINE",OBJ_HLINE,windowIndex,0,Up+10); ObjectSet("SHORTLINE",OBJPROP_COLOR,C'128,128,128'); ObjectSet("SHORTLINE",OBJPROP_WIDTH,1); ObjectSet("SHORTLINE",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("LONGLINE",OBJ_HLINE,windowIndex,0,Dn-10); ObjectSet("LONGLINE",OBJPROP_COLOR,C'128,128,128'); ObjectSet("LONGLINE",OBJPROP_WIDTH,1); ObjectSet("LONGLINE",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("OVERBOUGHTLINE",OBJ_HLINE,windowIndex,0,Dn); ObjectSet("OVERBOUGHTLINE",OBJPROP_COLOR,clrRed); ObjectSet("OVERBOUGHTLINE",OBJPROP_WIDTH,1); ObjectSet("OVERBOUGHTLINE",OBJPROP_STYLE,STYLE_DOT); } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Show Arrows | //+------------------------------------------------------------------+ void DrawArrow(int i,string type) { maxArrows++; ObjectCreate("RSISignal"+maxArrows,OBJ_ARROW,0,Time[i],0); if(type=="Dn") { ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,High[i]+10); ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,242); ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrRed); } else if(type=="Up") { ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,Low[i]-10); ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,241); ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrGreen); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void DeleteArrows() { while(maxArrows>0) { ObjectDelete("RSISignal"+maxArrows); maxArrows--; } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ |
|
|||
Update RSI Arrows_Signale
Code:
//+------------------------------------------------------------------+ //| SHARK_RSI_CLASSIC_V.22 - 0122 | //| Copyright 2020 | //| www.expert-advisor.com | //+------------------------------------------------------------------+ #property copyright "Sirocool" #property link "http://www.expert-advisor.com/forum/members/sirocool.html" //#property icon "\\Images\\Icon\\Shark.ico" extern string a_SHARK_SETTINGS ="~~* RSI Settings *~~"; extern int Fast_Length = 14; extern double Over_Up = 30; extern double Over_Dn = 70; extern ENUM_APPLIED_PRICE SOURCE = PRICE_CLOSE; extern string b_SHARK_SETTINGS ="~~* RSI Settings Styl *~~"; extern string c_SHARK_SETTINGS ="~~* RSI Settings Alert *~~"; extern bool ShowArrows = true; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 3 #property indicator_minimum 0 #property indicator_maximum 100 //+------------------------------------------------------------------+ //| ENUM_APPLIED_PRICE | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| IndicatorShortName | //+------------------------------------------------------------------+ string Name ="SHARK_RSI_CLASSIC_V.21"+"( "+ Fast_Length +","+PriceTypeToString(SOURCE)+","+ Over_Up+","+Over_Dn+")"; int windowIndex=WindowFind(Name),maxArrows,maxLine; //==================================== rectangle names string NameTopLev=windowIndex+"LevelTop"; //50 - string NameWaitUp=windowIndex+"LevelWaitTop"; // 55 string NameWaitLo=windowIndex+"LevelWaitBot"; //-45 string NameBotLev=windowIndex+"LevelBot"; //30 double SHARK_BUFFER_M[],SHARK_BUFFER_ARROW_UP[],SHARK_BUFFER_ARROW_DN[]; bool ExtParameters=false, initFinished=false; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(3); IndicatorDigits(Digits+1);//max. 2 SetIndexBuffer(0,SHARK_BUFFER_M,INDICATOR_DATA); // RSI_LINIE SetIndexStyle(0,DRAW_LINE,EMPTY,1,clrRoyalBlue); SetIndexDrawBegin(0,Fast_Length); SetIndexLabel(0,"RSI"); SetIndexBuffer(1,SHARK_BUFFER_ARROW_UP,INDICATOR_DATA); SetIndexStyle(1, DRAW_ARROW, EMPTY,1,clrForestGreen); SetIndexArrow(1, 241); SetIndexLabel(1,NULL); SetIndexBuffer(2,SHARK_BUFFER_ARROW_DN,INDICATOR_DATA); SetIndexStyle(2, DRAW_ARROW, EMPTY,1,clrFireBrick); SetIndexArrow(2, 242); SetIndexLabel(2,NULL); if(Fast_Length<=1) { Print("Wrong input parameters"); ExtParameters=false; return(INIT_FAILED); } else ExtParameters=true; return(INIT_SUCCEEDED); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int deinit() { _DeleteArrows(); ObjectDelete("SoldLine"); ObjectDelete("BuyLine"); ObjectDelete("SellLine"); ObjectDelete("BoughtLine"); //ObjectsDeleteAll(); //ObjectDelete(); //deleteArrows(); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ _Overlines(Over_Up,Over_Dn); 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] = iRSI(Symbol(),Period(),Fast_Length,SOURCE,i); double Lower=iFractals(NULL,0,MODE_LOWER,i); double Upper=iFractals(NULL,0,MODE_UPPER,i); //+------------------------------------------------------------------+ //| SHARK_SHOW_ARROWS | //+------------------------------------------------------------------+ if(ShowArrows) { //+------------------------------------------------------------------+ //| SHARK_SHORT_SIGNAL | //+------------------------------------------------------------------+ if((SHARK_BUFFER_M[i] < Over_Dn) && (SHARK_BUFFER_M[i+1] > Over_Dn)) { SHARK_BUFFER_ARROW_DN[i+1] = Upper+95; DrawArrow(i+1,"Dn",Upper); } //+------------------------------------------------------------------+ //| SHARK_LONG_SIGNAL | //+------------------------------------------------------------------+ if((SHARK_BUFFER_M[i] > Over_Up) && (SHARK_BUFFER_M[i+1] < Over_Up)) { SHARK_BUFFER_ARROW_UP[i+1] = Lower+5; DrawArrow(i+1,"Up",Lower); } } //+------------------------------------------------------------------+ } return(0); } //+------------------------------------------------------------------+ //| Extras | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ //| Overline 70 / 30 | //+------------------------------------------------------------------+ void _Overlines(int Up, int Dn) { if(initFinished==false) { IndicatorShortName(Name); windowIndex=WindowFind(Name); if(windowIndex<0) { Print("Can\'t find window"); return; } ObjectCreate("SoldLine",OBJ_HLINE,windowIndex,0,Up); ObjectSet("SoldLine",OBJPROP_COLOR,clrGreen); ObjectSet("SoldLine",OBJPROP_WIDTH,1); ObjectSet("SoldLine",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("BuyLine",OBJ_HLINE,windowIndex,0,Up+10); ObjectSet("BuyLine",OBJPROP_COLOR,C'128,128,128'); ObjectSet("BuyLine",OBJPROP_WIDTH,1); ObjectSet("BuyLine",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("SellLine",OBJ_HLINE,windowIndex,0,Dn-10); ObjectSet("SellLine",OBJPROP_COLOR,C'128,128,128'); ObjectSet("SellLine",OBJPROP_WIDTH,1); ObjectSet("SellLine",OBJPROP_STYLE,STYLE_DOT); ObjectCreate("BoughtLine",OBJ_HLINE,windowIndex,0,Dn); ObjectSet("BoughtLine",OBJPROP_COLOR,clrRed); ObjectSet("BoughtLine",OBJPROP_WIDTH,1); ObjectSet("BoughtLine",OBJPROP_STYLE,STYLE_DOT); } } //+------------------------------------------------------------------+ //| Show Arrows | //+------------------------------------------------------------------+ void DrawArrow(int i,string type, double grap) { maxArrows++; ObjectCreate("RSISignal"+maxArrows,OBJ_ARROW,0,Time[i],0); if(type=="Dn") { ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,grap); ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,242); ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrRed); } else if(type=="Up") { ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,grap); ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,241); ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,clrGreen); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void _DeleteArrows() { while(maxArrows>0) { ObjectDelete("RSISignal"+maxArrows); maxArrows--; } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ |
Lesezeichen |
Themen-Optionen | Thema durchsuchen |
Ansicht | |
|
|