Fragen von Neueinsteigern zu MQL4 und MQL5, Hilfe und Diskussion über Algorithmen und Codes
Hallo.
Ist es möglich, die Anzahl der Konstruktionsbalken im Standard-Fraktal-Indikator anpassbar zu machen, d.h. anders als 5?
Wenn ja, wie kann dies geschehen?
Ist es möglich, die Anzahl der Konstruktionsbalken im Standard-Fraktal-Indikator anpassbar zu machen, d.h. anders als 5?
Wenn ja, wie kann dies geschehen?
Hallo.
Ist es möglich, die Anzahl der Konstruktionsbalken im Standard-Fraktal-Indikator anpassbar zu machen, d.h. anders als 5?
Wenn ja, wie kann dies geschehen?
in der Codebasishttps://www.mql5.com/ru/search#!keyword=fractals&module=mql5_module_codebase ist ein solcher vorhanden
Ich danke Ihnen. Ich brauche eine nur für mq4https://www.mql5.com/de/code/1381
Ich habe es in MT4-Editor kompiliert, es funktioniert, aber es lädt die CPU, was sollte ich ändern, um es nicht zu laden?
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
//--- plot UpFractals
#property indicator_label1 "Up Fractals"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrDodgerBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot DnFractals
#property indicator_label2 "Down Fractals"
#property indicator_type2 DRAW_ARROW
#property indicator_color2 clrTomato
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- input parameters
input int InpLeftSide = 3; // Кол-во баров слева от фрактала
input int InpRightSide = 3; // Кол-во баров справа от фрактала
//--- indicator buffers
double UpFractalsBuffer[];
double DnFractalsBuffer[];
//--- global variables
int minRequiredBars;
int leftSide, rightSide;
int maxSide;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit() {
//---
if ( InpLeftSide < 1 ) {
leftSide = 2;
printf("Неккоретно указан параметр \"Кол-во баров слева от фрактала\": %d. Будет использовано значение: %d.",
InpLeftSide, leftSide);
} else {
leftSide = InpLeftSide;
}
if ( InpRightSide < 1 ) {
rightSide = 2;
printf("Неккоретно указан параметр \"Кол-во баров справа от фрактала\": %d. Будет использовано значение: %d.",
InpRightSide, rightSide);
} else {
rightSide = InpRightSide;
}
//---
minRequiredBars = leftSide + rightSide + 1;
maxSide = int(MathMax(leftSide, rightSide));
//---
SetIndexBuffer(0, UpFractalsBuffer, INDICATOR_DATA);
SetIndexBuffer(1, DnFractalsBuffer, INDICATOR_DATA);
//---
PlotIndexSetInteger(0, PLOT_ARROW, 217);
PlotIndexSetInteger(1, PLOT_ARROW, 218);
//---
PlotIndexSetInteger(0, PLOT_ARROW_SHIFT, -10);
PlotIndexSetInteger(1, PLOT_ARROW_SHIFT, 10);
//---
for ( int i = 0; i < 2; i++ ) {
PlotIndexSetInteger(i, PLOT_DRAW_BEGIN, minRequiredBars);
PlotIndexSetDouble(i, PLOT_EMPTY_VALUE, 0.0);
}
//---
IndicatorSetInteger(INDICATOR_DIGITS, _Digits);
//---
IndicatorSetString(INDICATOR_SHORTNAME, "ffra ("+(string)leftSide+", "+(string)rightSide+")");
//---
return(0);
}
//+------------------------------------------------------------------+
//| Check if is Up Fractal function |
//+------------------------------------------------------------------+
bool isUpFractal(int bar, int max, const double &High[]) {
//---
for ( int i = 1; i <= max; i++ ) {
if ( i <= leftSide && High[bar] < High[bar-i] ) {
return(false);
}
if ( i <= rightSide && High[bar] <= High[bar+i] ) {
return(false);
}
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| Check if is Down Fractal function |
//+------------------------------------------------------------------+
bool isDnFractal(int bar, int max, const double &Low[]) {
//---
for ( int i = 1; i <= max; i++ ) {
if ( i <= leftSide && Low[bar] > Low[bar-i] ) {
return(false);
}
if ( i <= rightSide && Low[bar] >= Low[bar+i] ) {
return(false);
}
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
int startBar, lastBar;
//---
if ( rates_total < minRequiredBars ) {
Print("Недостаточно данных для расчёта");
return(0);
}
//---
if (prev_calculated < minRequiredBars) {
startBar = leftSide;
ArrayInitialize(UpFractalsBuffer, 0.0);
ArrayInitialize(DnFractalsBuffer, 0.0);
}
else {
startBar = rates_total - minRequiredBars;
}
//---
lastBar = rates_total - rightSide;
for ( int bar = startBar; bar < lastBar && !IsStopped(); bar++ ) {
//---
if ( isUpFractal(bar, maxSide, high) ) {
UpFractalsBuffer[bar] = high[bar];
} else {
UpFractalsBuffer[bar] = 0.0;
}
//---
if ( isDnFractal(bar, maxSide, low) ) {
DnFractalsBuffer[bar] = low[bar];
} else {
DnFractalsBuffer[bar] = 0.0;
}
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Ich danke Ihnen. Benötigt wird eine nur auf mq4https://www.mql5.com/de/code/1381
Die Korrekturen sind minimal:
//| iXBarsFractals.mq4 |
//| Copyright 2011, Rone. redaction 2016 by artmedia70 |
//| rone.sergey@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011, Rone."
#property link "rone.sergey@gmail.com"
#property version "1.00"
#property description "Индикатор позволяет отдельно указывать кол-во баров слева и справа от фрактала. Хорошо подходит "
#property description "для определения как локальных, так и глобальных экстремумов."
#property strict
//--- indicator buffers
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
//--- plot UpFractals
#property indicator_label1 "Up Fractals"
#property indicator_type1 DRAW_ARROW
#property indicator_color1 clrDodgerBlue
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot DnFractals
#property indicator_label2 "Down Fractals"
#property indicator_type2 DRAW_ARROW
#property indicator_color2 clrTomato
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- input parameters
input int InpLeftSide = 3; // Кол-во баров слева от фрактала
input int InpRightSide = 3; // Кол-во баров справа от фрактала
//--- indicator buffers
double UpFractalsBuffer[];
double DnFractalsBuffer[];
//--- global variables
int minRequiredBars;
int leftSide,rightSide;
int maxSide;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
leftSide=(InpLeftSide<2?2:InpLeftSide);
rightSide=(InpRightSide<2?2:InpRightSide);
//---
minRequiredBars=leftSide+rightSide+1;
maxSide=int(fmax(leftSide,rightSide));
//---
SetIndexBuffer(0,UpFractalsBuffer,INDICATOR_DATA);
SetIndexBuffer(1,DnFractalsBuffer,INDICATOR_DATA);
//---
SetIndexArrow(0,217);
SetIndexArrow(1,218);
//PlotIndexSetInteger(0,PLOT_ARROW,217);
//PlotIndexSetInteger(1,PLOT_ARROW,218);
//---
PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-10);
PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,10);
//---
for(int i=0; i<2; i++) {
PlotIndexSetInteger(i,PLOT_DRAW_BEGIN,minRequiredBars);
PlotIndexSetDouble(i,PLOT_EMPTY_VALUE,0.0);
}
//---
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//---
IndicatorSetString(INDICATOR_SHORTNAME,"XBarsFractals("+(string)leftSide+", "+(string)rightSide+")");
//---
return(0);
}
//+------------------------------------------------------------------+
//| Check if is Up Fractal function |
//+------------------------------------------------------------------+
bool isUpFractal(int bar,int max,const double &high[])
{
//---
for(int i=1; i<=max; i++) {
if(i<=leftSide && high[bar]<high[bar-i]) return(false);
if(i<=rightSide && high[bar]<=high[bar+i]) return(false);
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| Check if is Down Fractal function |
//+------------------------------------------------------------------+
bool isDnFractal(int bar,int max,const double &low[])
{
//---
for(int i=1; i<=max; i++) {
if(i<=leftSide && low[bar]>low[bar-i]) return(false);
if(i<=rightSide && low[bar]>=low[bar+i]) return(false);
}
//---
return(true);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
int startBar,lastBar;
//---
if(rates_total<minRequiredBars) return(0);
//---
if(prev_calculated<minRequiredBars) {
startBar=leftSide;
ArrayInitialize(UpFractalsBuffer, 0.0);
ArrayInitialize(DnFractalsBuffer, 0.0);
}
else startBar=rates_total-minRequiredBars;
//---
lastBar=rates_total-rightSide;
for(int bar=startBar; bar<lastBar && !IsStopped(); bar++) {
//---
if(isUpFractal(bar,maxSide,high)) UpFractalsBuffer[bar]=high[bar];
else UpFractalsBuffer[bar]=0.0;
//---
if(isDnFractal(bar,maxSide,low)) DnFractalsBuffer[bar]=low[bar];
else DnFractalsBuffer[bar]=0.0;
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Ich würde es zwar ein wenig anders machen, aber das ist Gewohnheitssache...
Man könnte es auch so machen:
rightSide=(InpRightSide<1?1:InpRightSide);
Dann erhältst du ziemlich lustige Fraktale...
Die Korrekturen sind minimal:
Ich hätte es zwar ein wenig anders gemacht, aber das ist Macht der Gewohnheit...
Man könnte es auch so machen:
rightSide=(InpRightSide<1?1:InpRightSide);
In diesem Fall wird es absolut lächerliche Fraktale anzeigen...
Danke, so.
Sie können es auch nicht in der MT4-Hilfe finden, womit kann ich es ersetzen?
Danke, so etwas gibt es auch.
Auch nicht in der MT4-Hilfe. Wodurch soll ich sie ersetzen?
Sie lautet "Vertikaler Pfeilversatz für DRAW_ARROW-Stil".
Keine der üblichen.
Sie können den Offset entweder in den Einstellungen oder durch den Wert von ATReinstellen
Und machen Sie diese Zeilen wie folgt:
for(int i=0; i<2; i++) {
SetIndexDrawBegin(i,minRequiredBars);
SetIndexEmptyValue(i,0);
//PlotIndexSetInteger(i,PLOT_DRAW_BEGIN,minRequiredBars);
//PlotIndexSetDouble(i,PLOT_EMPTY_VALUE,0.0);
}
//---
Dies ist "Vertikaler Pfeilversatz für den Stil DRAW_ARROW".
Löschen Sie, was hier auskommentiert ist, und fügen Sie ein, was hier geschrieben steht.
Es wird immer noch geladen.
Ruft man von einem anderen Indikator aus an, bleibt das Terminal sogar einen Moment lang hängen.
Was kann ich sonst noch tun?
Es wird immer noch geladen.
Ruft man von einem anderen Indikator aus an, bleibt das Terminal sogar einen Moment lang hängen.
Was kann ich sonst noch tun?
Rufen Sie nicht von einem anderen Indikator aus an :)
Oder zeigen Sie, wie Sie es machen.

- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
In diesem Thread möchte ich damit beginnen, denjenigen zu helfen, die wirklich das Programmieren in der neuen MQL4 verstehen und lernen wollen und einfach zu MQL5 wechseln wollen - die Sprachen sind sehr ähnlich.
Dieser Blog wird ein guter Ort sein, um Aufgaben, Algorithmen zu ihrer Lösung und alle anderen Fragen zur MT-Programmierung zu diskutieren.
Ich hoffe, dass andere erfahrene Mitglieder unseres Forums sich uns anschließen werden und dieser Thread für alle interessant sein wird.