Antwort

Ich möchte den Zickzack-Index in MT4 verpflanzen, um die Form in SQ zu analysieren

0 Antworten

Bürgermeister Mais

Abonnent, bbp_participant, 1 Antworten.

Profil besuchen

vor 2 Jahren #271096

Ich mag die Zickzack morphologische Analyse Index in MT4, ich möchte die Zickzack-Index in MT4 zu verpflanzen, um die Form in SQ zu analysieren, aber es gibt kein Problem mit dem Code. Es scheint, dass es ein Problem im SQ-Chart gibt.

 

Paket SQ.Blocks.Indicators.ZIGZAG;

import SQ.Calculators.HighestCalculator;
import SQ.Calculators.LowestCalculator;
import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;

import SQ.Internal.IndicatorBlock;

/**
* Name des Indikators, wie er in der Benutzeroberfläche angezeigt wird, und sein Rückgabetyp.
* Mögliche Rückgabearten:
* ReturnTypes.Price - Indikator wird auf dem Preisdiagramm gezeichnet, wie SMA, Bollinger Bands usw.
* ReturnTypes.Number - Indikator wird in einem separaten Diagramm gezeichnet, wie CCI, RSI, MACD
* ReturnTypes.PriceRange - Indikator ist eine Preisspanne, wie ATR.
*/
@BuildingBlock(name="(ZIGZAG) ZIGZAG", display="ZIGZAG(#InpDepth#,#InpDeviation#,#InpBackstep#)[#Shift#]", returnType = ReturnTypes.Price)

@Help
(“ZIGZAG help text”)
public class ZIGZAG extends IndicatorBlock {

@Parameter
public ChartData Chart;

@Parameter(defaultValue="12″)
public int InpDepth;

@Parameter(defaultValue="5″)
public int InpDeviation;

@Parameter(defaultValue="3″)
public int InpBackstep;

@Output(name = "ExtZigzagBuffer", color = Colors.Green)
public DataSeries ExtZigzagBuffer;

@Output
public DataSeries ExtHighBuffer;
@Output
public DataSeries ExtLowBuffer;

@Override
protected void OnInit() throws TradingException {
ExtZigzagBuffer.set(0,0);
ExtHighBuffer.set(0,0.00);
ExtLowBuffer.set(0,0.00);

}

//————————————————————————
//————————————————————————
//————————————————————————

/**
* Diese Methode wird bei jeder Balkenaktualisierung aufgerufen, und hier wird der Indikatorwert berechnet.
*
* Anders als in MT4 berechnen Sie die Indikatorwerte nicht für mehrere Balken in einer Schleife,
* Sie müssen den Wert nur für den letzten (aktuellen) Balken berechnen.
* Die Trading Engine kümmert sich um den Aufruf dieser Methode für jeden Balken im Diagramm.
*
* Der aktuelle Takt, für den der Indikatorwert berechnet wird, wird in der Variablen CurrentBar gespeichert.
* Wenn 0, bedeutet dies, dass es sich um den allerersten Balken des Diagramms handelt.
*/
@Override
protected void OnBarUpdate() throws TradingException {

int i;
int counterZ,whatlookfor=0;
int back,pos,lasthighpos=0,lastlowpos=0;
double extremum=0;
double curlow=0.0,curhigh=0.0,lasthigh=0.0,lastlow=0.0;
double val;
double Punkt1=0,00001;
//Chart.getInstrumentInfo.pointValue;
int limit=0;

for(i=limit; i>=0; i-)

{

//- Hauptschleife

//- Tiefstwert in der Tiefe der Balken finden

val= Chart.Low(InpDepth+i);

for(int j = InpDepth+i-1; j>=i;j-) {
val = Math.min(val, Chart.Low(j));
}

extremum= val;

//- dieser niedrigste Wert wurde bereits gefunden
if(extremum==lastlow)
extremum=0,0;
sonst
{
//- neues letztes Tief
lastlow=extremum;
//- Verwerfen des Extremwerts, wenn der aktuelle Tiefstwert zu hoch ist
if(Chart.Low(i)-extremum>InpDeviation*Point1)
extremum=0,0;
sonst
{
//- vorherige Extremwerte in Rückschritttakten löschen
for(back=1; back<=InpBackstep; back++)
{
pos=i+back;
if(ExtLowBuffer.get(pos)!=0 && ExtLowBuffer.get(pos)>extremum)
ExtLowBuffer.set(pos,0.0);
}
}
}
//- gefundener Extremwert ist aktueller Tiefpunkt
if(Chart.Low(i)==extremum)

ExtLowBuffer.set(i,extremum);
// ExtLowBuffer[i]=extremum;
sonst
ExtLowBuffer.set(i,0.00);

val= Chart.High(InpDepth+i);

for(int j = InpDepth+i-1; j>=i;j-){
val = Math.max(val, Chart.High(j));
}

//- Höchstwert in der Tiefe der Balken finden
extremum=val;
//- dieser höchste Wert wurde bereits gefunden
if(extremum==lasthigh)
extremum=0,0;
sonst
{
//- neuer letzter Höchststand
lasthigh=extremum;
//- Verwerfen des Extremwerts, wenn der aktuelle Höchstwert zu niedrig ist
if(extremum-Chart.High(i)>InpDeviation*Point1)
extremum=0,0;
sonst
{
//- vorherige Extremwerte in Rückschritttakten löschen
for(back=1; back<=InpBackstep; back++)
{
pos=i+back;
if(ExtHighBuffer.get(pos)!=0 && ExtHighBuffer.get(pos)<extremum)
ExtHighBuffer.set(pos,0.00);
//ExtHighBuffe.set(pos,0.0);
}
}
}
//- gefundener Extremwert ist aktueller Höchstwert
if(Chart.High(i)==extremum)
ExtHighBuffer.set(i,extremum);
sonst
// ExtHighBufferr.set(i,0.00);
ExtHighBuffer.set(i,0.00);

}

//- endgültiger Schnitt
if(whatlookfor==0)
{
lastlow=0.0;
lasthigh=0.0;
}
sonst
{
lastlow=curlow;
lasthigh=curhigh;
}

for(i=limit; i>=0; i-)

{

switch(whatlookfor)
{
Fall 0: // Suche nach Spitze oder Rasen
if(lastlow==0.0 && lasthigh==0.0)
{
if(ExtHighBuffer.get(i)!=0.0)
{
lasthigh=Chart.High(i);
lasthighpos=i;
whatlookfor=-1;
ExtZigzagBuffer.set(i,lasthigh);
}
if(ExtLowBuffer.get(i)!=0.0)
{
lastlow=Chart.Low(i);
lastlowpos=i;
whatlookfor=1;
ExtZigzagBuffer.set(i,lastlow);
}
}
Pause;
Fall 1: // Suche nach Spitzenwert
if(ExtLowBuffer.get(i)!=0.0 && ExtLowBuffer.get(i)<lastlow && ExtHighBuffer.get(i)==0.0)
{
ExtZigzagBuffer.set(lastlowpos,0.0);
lastlowpos=i;
lastlow=ExtLowBuffer.get(i);
ExtZigzagBuffer.set(i,lastlow);
}
if(ExtHighBuffer.get(i)!=0.0 && ExtLowBuffer.get(i)==0.0)
{
lasthigh=ExtHighBuffer.get(i);
lasthighpos=i;
ExtZigzagBuffer.set(i,lasthigh);
whatlookfor=-1;
}
Pause;
Fall -1: // Suche nach Rasen
if(ExtHighBuffer.get(i)!=0.0 && ExtHighBuffer.get(i)>lasthigh && ExtLowBuffer.get(i)==0.0)
{
ExtZigzagBuffer.set(lasthighpos,0.0);
lasthighpos=i;
lasthigh=ExtHighBuffer.get(i);
ExtZigzagBuffer.set(i,lasthigh);
}
if(ExtLowBuffer.get(i)!=0.0 && ExtHighBuffer.get(i)==0.0)
{
lastlow=ExtLowBuffer.get(i);
lastlowpos=i;
ExtZigzagBuffer.set(i,lastlow);
whatlookfor=1;
}
Pause;

}
}

}

}

0