Zum Inhalt springen
View in the app

A better way to browse. Learn more.

#T/N/X/T

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

High/Low-Loop

Geschrieben

Hi, ich versuche mich gerade an einem Loop, welcher den Hoch- bzw. Tiefkurs der Vorwoche fortlaufend im Chart darstellt. Leider gibts nur Spagetti oder totales Abdriften, kann mir mal jemand einhelfen?

 

 

int start()
{
int i,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;

if(Period()>PERIOD_H4) return(-1);


for(i=limit-1; i>=0; i--)
{
// 1sts Days of Week
if(TimeDayOfWeek(Time[i])<=2 && TimeDayOfWeek(Time[i+1])>=4)
{
last_week_low=iLow(Symbol(),PERIOD_W1,i+1);
last_week_high= iHigh(Symbol(),PERIOD_W1,i+1);
}

low_Buffer[i]=last_week_low;
high_Buffer[i]=last_week_high;

}
//----
return(0);
}

post-1524-0-45972200-1337118169_thumb.png

Featured Replies

Geschrieben

 

last_week_low=iLow(Symbol(),PERIOD_W1,i+1);
}

i im (z.B. M5-Chart) ist nicht gleich i im Wochenchart.

Wenn i=5 in M5, dann heisst das vor 25 Minuten. Das selbe i in W1 ist dann aber 5 Wochen.

Du musst den Index vorher umrechnen.

Geschrieben

Kann man da nicht als Grundlage den Donchian nehmen und den dann fix auf W1 und 1 Periode umbauen? Wäre nun so mein erster Gedanke.

Link zum Indikator: http://codebase.mql4.com/5684

 

Edit hat es gerade mal probiert. Es tritt dann genau das gleiche Problem auf, wie WOGO es beschrieben hat. Man muss also erstmal ermitteln, in welcher Woche man sich befindet und dementsprechend dann die Linien den Kerzen anpassen.

Geschrieben
  • Autor

Ich muss zugeben, ich bin nur so am raten. Hab jetzt verschiedenes ausprobiert, nur ist da irgendwo noch ne Denkfalte^^

 

In AFL gibt es sowas wie "inWeekly", dann berechnet er alles auf Weeklybars, egal wie klein man den TF dann wählt.

Geschrieben

Ich muss zugeben, ich bin nur so am raten. Hab jetzt verschiedenes ausprobiert, nur ist da irgendwo noch ne Denkfalte^^

 

In AFL gibt es sowas wie "inWeekly", dann berechnet er alles auf Weeklybars, egal wie klein man den TF dann wählt.

Auf die Schnelle fällt mir jetzt nichts wirklich intelligentes ein. Ich würd einfach einen 2. Index einführen, der mit MathFloor(Period()/PERIOD_W1) startet und runter zählt, wenn TimeDayOfWeek

 

Also inetwa so:

int start()
{
int i,j,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;

if(Period()>PERIOD_H4) return(-1);

j=MathFloor(Period()/PERIOD_W1);
for(i=limit-1; i>=0; i--)
{
// 1sts Days of Week
if(TimeDayOfWeek(Time[i])<=2 && TimeDayOfWeek(Time[i+1])>=4)
{
last_week_low=iLow(Symbol(),PERIOD_W1,j+1);
last_week_high= iHigh(Symbol(),PERIOD_W1,j+1);
}

low_Buffer[i]=last_week_low;
high_Buffer[i]=last_week_high;
if(TimeDayOfWeek[i] < TimeDayOfWeek[i-1])
j--;
}
//----
return(0);
}

Kann sein, dass du bei der Initialisierung von j noch 1 dazuzählen oder abziehen musst. Um mir das zu überlegen bin ich heute schon zu müde...

sleepy.gif

Geschrieben
  • Autor

Hat ne Fehlermeldung ausgegeben, habe noch Time eingesetzt, nur irgendwie gibts jetzt gar keine Linien mehr.

 

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green

double low_Buffer[];
double high_Buffer[];
int init()
 {
  SetIndexBuffer(0,low_Buffer);
  SetIndexBuffer(1,high_Buffer);
  SetIndexStyle(0,DRAW_LINE,0,2);
  SetIndexStyle(1,DRAW_LINE,0,2);
  SetIndexLabel(0,"pw_low");
  SetIndexLabel(1,"pw_high");
  return(0);
 }

int deinit()
 {
  ObjectDelete("pw_low");
  ObjectDelete("pw_high");

  return(0);
 }

int start()
{
int i,j,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;
if(Period()>PERIOD_H4) return(-1);
j=MathFloor(Period()/PERIOD_W1);
for(i=limit-1; i>=0; i--)
{
// 1sts Days of Week
if(TimeDayOfWeek(Time[i])<=2 && TimeDayOfWeek(Time[i+1])>=4)
{
double last_week_low=iLow(Symbol(),PERIOD_W1,j+1);
double last_week_high= iHigh(Symbol(),PERIOD_W1,j+1);
}
low_Buffer[i]=last_week_low;
high_Buffer[i]=last_week_high;
if(TimeDayOfWeek(Time[i])< TimeDayOfWeek(Time[i-1]))
j--;
}
//----
return(0);
}

Bearbeitet von remon

Geschrieben

ja, die Berechnung von j stimmt nicht. Du musst natürlich noch i mit rein bringen:

j=MathFloor(i*Period()/PERIOD_W1);

Geschrieben

Was spricht gegen iBarShift?

 


int start()
{
int i,counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
int limit=Bars-counted_bars;

if(Period()>PERIOD_H4) return(-1);

double last_week_low,last_week_high;

for(i=limit-1; i>=0; i--)
{
// 1sts Days of Week
if(TimeDayOfWeek(Time[i])<=2 && TimeDayOfWeek(Time[i+1])>=4)
{
//we are at the first bar of the week, means nearest bar in W1 is this weeks bar
int shift= iBarShift(Symbol(),PERIOD_W1,Time[i],false);
last_week_low=iLow(Symbol(),PERIOD_W1,shift+1);
last_week_high= iHigh(Symbol(),PERIOD_W1,shift+1);
}

low_Buffer[i]=last_week_low;
high_Buffer[i]=last_week_high;

}
//----
return(0);
}

 

(habs jetzt aber nit getestet... OMG.gif )

Geschrieben
  • Autor

Ooh ja, iBarShift, das is es!^^ Danke Mythos und WOGO:)

 

Wäre trotzdem interessant zu wissen wie man grundsätzlich einen Index jeweils so umrechnet, dass Berechnungen von verschiedenen Zeitrahmen herangezogen werden können und diese unabhängig vom gewählten TF dargestellt werden.

Geschrieben

Wäre trotzdem interessant zu wissen wie man grundsätzlich einen Index jeweils so umrechnet, dass Berechnungen von verschiedenen Zeitrahmen herangezogen werden können und diese unabhängig vom gewählten TF dargestellt werden.

 

Mit iBarShift ;) Du kannst beim Umrechnen von Indizes zwischen den Timeframes nur nach der Zeit gehen, da du ja keine Garantie hast wieviele Bars es in kleineren Timeframe gab.

 

Also entweder iBarShift oder so wie WOGO den höheren TimeFrame parallel checken und den index updaten

Dein Kommentar

Du kannst jetzt schreiben und Dich später registrieren. Wenn Du ein Konto hast, melde Dich jetzt an, um unter Deinem Benutzernamen zu schreiben.

Gast
Auf dieses Thema antworten...

Account

Navigation

Suche

Suche

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.