|
Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4. |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
Hilfe beim Indikator bauen
Hey Leute ich bräuchte mal Hilfe bei was bin neu Hier und probiere gerade mal was aus.
der Indikator berechnet drei Indikatoren (RSI;STOCH;CCI) und soll mir das unten dann anzeigen wie beim RSI in einer Linie die auch zickzack macht und nicht gerade durchgeht. Wäre euch dankbar dabei mir mal zuhelfen [IMG]blob:https://mega.nz/12aa580d-0748-43e5-9e10-34e66155dc77[/IMG] und hier der Mql4 Code Code:
//+------------------------------------------------------------------+ //| 2.mq4 | //| M.Streit Copyright 2020 | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "M.Streit Copyright 2020" #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_separate_window //#property indicator_chart_window #property indicator_buffers 1 #property indicator_width1 1 #property indicator_width2 1 #property indicator_minimum -200 #property indicator_maximum 200 double tops[]; double bottoms[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { IndicatorShortName("Beta2020"); SetIndexBuffer(0,tops); SetIndexStyle(0,DRAW_LINE,EMPTY,1,clrBlue); SetIndexLabel(0,"tops"); SetIndexBuffer(1,bottoms); SetIndexStyle(1,DRAW_LINE); SetIndexLabel(0,"bottoms"); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { /* Berechnung des Indikatorwertes den er ausgeben soll */ double RSIWert = DoubleToStr(iRSI(Symbol(),0,14,PRICE_CLOSE,1),2); double CCIWERT = DoubleToStr(iCCI(Symbol(),0,14,PRICE_CLOSE,0),2); double SToWERT = DoubleToStr(iStochastic(Symbol(),0,14,3,3,MODE_SMA,0,MODE_MAIN,0),2); /* Ausgabewert den er ausgeben soll */ double DWert = DoubleToStr((SToWERT+RSIWert+CCIWERT)/3,2); for(int i=Bars-1;i>=0;i--) { tops[i]=DWert; //bottoms[i]=Low[i]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- } //+------------------------------------------------------------------+ Sirocool |
|
|||
Zitat:
Ich hab schon mal ne "Arbeitsversion" nach dem gemacht, was ich in Deinem Code gefunden habe, aber bisher sieht die Linie nur etwas unruhiger als ein CCI(14) aus. Zitat:
AVT |
|
|||
Brauche Hilfe beim Indikator erstellen
Bild wurde Bearbeitet nicht mehr bei Mega.nz in meiner Cloud müsste jetzt gehen. Mit freundlichen Grüßen Sirocool[/QUOTE] |
|
|||
Ich habe den Indi mal gebaut (einzige Abweichung: iRSI(Symbol(),0,14,PRICE_CLOSE,1) => iRSI(Symbol(),0,14,PRICE_CLOSE,0) weil die anderen beiden auch den aktuellen Wert nehmen).
Probier's mal aus, ob Du Dir das so gedacht hast. AVT |
|
|||
Ich glaube ich ahbe die lösung raus
hie mal der Mql4code
3.jpg Code:
// #property copyright "" #property link "" #property indicator_separate_window #property indicator_buffers 1 #property indicator_minimum -200 #property indicator_maximum 200 #property indicator_color1 Black extern int barsToProcess=100; double ExtMapBuffer1[]; int init() { SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); MathSrand(TimeLocal()); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectsDeleteAll(); // Löschen wir alle Objekte return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { MathSrand(GetTickCount()); double RSIWert = iRSI(Symbol(),0,14,PRICE_CLOSE,1); double CCIWERT = iCCI(Symbol(),0,14,PRICE_CLOSE,0); //DoubleToStr("",2); double SToWERT = iStochastic(Symbol(),0,14,3,3,MODE_SMA,0,MODE_MAIN,0); double DWert = (SToWERT+RSIWert+CCIWERT)/3; int counted_bars=IndicatorCounted(), limit; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>barsToProcess) limit=barsToProcess; for(int i=0;i<limit;i++) { ExtMapBuffer1[i]=DWert*MathRand()/32767;//MathRand()%2; //MathSrand(GetTickCount()); //MathRand()%1001; } return(0); } Geändert von Sirocool (31.03.20 um 12:24 Uhr) |
|
|||
So ist Fertig
Code:
// #property copyright "" #property link "" #property indicator_separate_window #property indicator_buffers 3 #property indicator_minimum -20 #property indicator_maximum 20 extern int barsToProcess=100; double TrendUp[], TrendDn[],SignalUp[]; string indicatorFileName; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,SignalUp);SetIndexStyle(0,DRAW_LINE,EMPTY,0,clrBlack); SetIndexBuffer(1,TrendUp);SetIndexStyle(1,DRAW_LINE,EMPTY,0,clrRed); SetIndexBuffer(2,TrendDn);SetIndexStyle(2,DRAW_LINE,EMPTY,0,clrGreen); indicatorFileName = WindowExpertName(); IndicatorShortName("Score 2020 " + "Signalwert:"); MathSrand(TimeLocal()); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectsDeleteAll(); // Löschen wir alle Objekte return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(), limit; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; if(limit>barsToProcess) limit=barsToProcess; for(int i=0;i<limit;i++) { double Scoreindex = 0; double cci = iCCI(NULL,0,14,PRICE_TYPICAL,i); if (cci < -100) Scoreindex -=5; if (cci > 100) Scoreindex +=5; double rsi = iRSI(NULL,0,14,PRICE_CLOSE,i); if (rsi < 30) Scoreindex -=5; if (rsi > 70) Scoreindex +=5; double stoFastK = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_MAIN ,i); double stoFastD = iStochastic(NULL,0,14,3,1,MODE_EMA,0,MODE_SIGNAL,i); if (stoFastK < 20) Scoreindex -=5; if (stoFastK > 80) Scoreindex +=5; if (stoFastD < 20) Scoreindex -=5; if (stoFastD > 80) Scoreindex +=5; /* if( insyncScore>=20) { TrendUp[i]=DoubleToStr(insyncScore,2);//iCCI(Symbol(),0,14,PRICE_CLOSE,i); } if( insyncScore>=-20)SetIndexStyle(3,DRAW_LINE,EMPTY,EMPTY,clrGreen); { SignalUp[i]=DoubleToStr(insyncScore,2);//iCCI(Symbol(),0,14,PRICE_CLOSE,i); } */ if(Scoreindex>+0)TrendUp[i]=DoubleToStr(Scoreindex,2); if(Scoreindex<-0)TrendDn[i]=DoubleToStr(Scoreindex,2); //if(Scoreindex=0)SignalUp[i]=DoubleToStr(Scoreindex,2); SignalUp[i]=DoubleToStr(Scoreindex,2); } return(0); } /* */ |
|
|||
Gefällt mir sehr gut, Deine Stufenlösung
AVT |
Lesezeichen |
|
|