Skip to content
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.

Multitimeframe-Indikator

Hallo,

 

ich möchte einen Indikator schreiben, der zwei SMAs zeichnet. Der 2. SMA soll sich auf ein höheren Timeframe beziehen. Leider wird der 2. SMA nicht gezeichnet (sollte Grün sein).

Woran liegt das.

 

Gruß

Eddy

protected override void Initialize()
       {
    Add(PeriodType.Week, 10);
           Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));
		
           Overlay = false;
       }

       protected override void OnBarUpdate()
       {
           Plot0.Set(SMA(10)[0]);
   //Plot1.Set(SMA(20)[0]);
   if (BarsInProgress == 1)
   {
	Plot1.Set(SMA(BarsArray[1], 10)[0]);
   }
       }

Edited by whipsaw

Featured Replies

Ich hab vom NT keinen blassen Schimmer. Und ob dein Code stimmt kann ich dir leider auch nicht sagen. Aber vieleicht hilft dir folgendes: Du kannst den MA eines höheren Timeframes berechnen indem du die Periode mit dem Timeframe multiplizierst.

 

Beispiel, du hast einen 1Min TF und willst den 20er MA aus dem 5Min Chart in den 1Min TF einzeichnen:

 

20 x 5Min = 100

 

Wenn du also einen 100er MA in den 1Min Chart zeichnest hast du das gleiche wie einen 20er MA im 5Min Chart.

 

 

Viele Grüße,

Rumpel

Ich denke Du hast keine wöchtenlichen Daten, wenn Forex ...

sonst schaue Dir mal BarsInProgress

 

Hier

 

protected override void Initialize()
{
    // Add a 5 minute Bars object - BarsInProgress index = 1 
    Add(PeriodType.Minute, 5);



    // Add a 100 tick Bars object for the ES 12-06 contract - BarsInProgress index = 2 
    Add("ES 12-06", PeriodType.Tick, 100); 
} 

protected override void OnBarUpdate() 
{ 
    // Ignore bar update events for the supplementary Bars object added above 
    if (BarsInProgress == 1 || BarsInProgress == 2)
         return; 

    // Go long if we have three up bars on all bars objects 
    if (Close[0] > Open[0] && Closes[1][0] > Opens[1][0] && Closes[2][0] > Opens[2][0]) 
         EnterLong();
}

  • Author

Zugreifen kann ich auf die andere Zeitebene. Ich bekomme nur nicht hin, das 2 SMAs in ein Chart gezeichnet werden. Ich dachte mit

 

Plot1.Set(SMA(BarsArray[1], 10)[0]);

müsste es funktionieren. Tut es aber nicht.

 

Gruß

Eddy

Das Problem könnte auch hier liegen

 

Das Problem liegt bei CurrentBar oder BarsInProgress

if(CurrentBar < SMALength) return;

 

Was sagt Dein Log (Tab in NT) ...

 

Zu dem wird unterschieden zwischen

 

Open[0]

Opens[0][0] ...

 

Schaue mal hier zwecks BarsArray ...

  • Author

Tja, das Problem ist anscheinend doch kein Problem. Wenn ich folgenden Code verwende

protected override void Initialize()
       {
    Add(PeriodType.Week, 1);
           Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "Plot1"));			
           Overlay				= false;
       }

       protected override void OnBarUpdate()
       {
    if (BarsInProgress == 0)
           	Plot0.Set(SMA(SMALength)[0]);

   	    //Plot1.Set(0);
    //Plot1.Set(SMA(BarsArray[1], SMALength)[0]);    // A) ggff. aktivieren
    if (BarsInProgress == 1)
           {
               if(CurrentBar < SMALength) return;
	Plot1.Set(SMA(BarsArray[1], SMALength)[0]);
           }
    	    Print ("BarsInProgress: " + BarsInProgress 
	+ " Time: " + Time[0]	
	+ " / CurrentBar: " + CurrentBar + " / " + Plot1.Get(CurrentBar));
       }

 

wird die SMA-Line für den 2. Timeframe nicht SICHTBAR gezeichnet. Markiert man aber die sichtbare Linie im Chart, werden auch die Punkte der "Unsichtbaren" Linie markiert.

 

Aktiviere ich die Anweisung A), wird die 2. Linie als treppenförmige Linie gezeichnet.

 

Warum? Noch keine Ahnung.

 

Gruß

Eddy

Tja, das Problem ist anscheinend doch kein Problem. Wenn ich folgenden Code verwende

[...]

 

wird die SMA-Line für den 2. Timeframe nicht SICHTBAR gezeichnet. Markiert man aber die sichtbare Linie im Chart, werden auch die Punkte der "Unsichtbaren" Linie markiert.

 

Aktiviere ich die Anweisung A), wird die 2. Linie als treppenförmige Linie gezeichnet.

 

Warum? Noch keine Ahnung.

 

Gruß

Eddy

 

Gültigkeit, Sichtbarkeit und Lebensdauer

 

Lebensdauer und so ein Zeug nur

 

 if(BarsInProgress == 0){...}

//dann ist da noch nichts ...

 

 

 

The following example demonstrates various ways to access price data.



protected override void OnBarUpdate()
{
    // Checks if OnBarUpdate() is called from an update on the primary Bars
    if (BarsInProgress == 0)
    {
         double primaryClose  = Close[0];
         double msft3minClose = Closes[1][0];
         double aapl1minClose = Closes[2][0];

         // primaryClose could also be expressed as
         // primaryClose = Closes[0][0];
    }



    // Checks if OnBarUpdate() is called from an update on MSFT 3 minute Bars object
    if (BarsInProgress == 1)
    {
         double primaryClose  = Closes[0][0];
         double msft3minClose = Close[0];
         double aapl1minClose = Closes[2][0];
    }
}

Edited by whipsaw
Zitat gekürzt

  • Author

Danke nochmals für den Link. Habe ich zwar schon mehrmals gelesen, die Wiederholung war aber doch noch mal sinnvoll. Das NT-Model ist (zumindest jetzt am Anfang) doch recht komplex (gerade wenn man wie ich von tradesignal kommt). Bis auf weiteres glaube ich das multi-time-frame-Model verstanden zu haben.

 

Wie kann man denn die treppenförmige Darstellung glätten?

 

Gruß

Eddy

Danke nochmals für den Link. Habe ich zwar schon mehrmals gelesen, die Wiederholung war aber doch noch mal sinnvoll. Das NT-Model ist (zumindest jetzt am Anfang) doch recht komplex (gerade wenn man wie ich von tradesignal kommt). Bis auf weiteres glaube ich das multi-time-frame-Model verstanden zu haben.

 

Wie kann man denn die treppenförmige Darstellung glätten?

 

Gruß

Eddy

 

Das mit den Kanten ist schon richtig.

Lösung A)siehe Rumpels Post

Lösung B)Antialiasing/Smoothing durch überschreiben der Plot-Methode

 

using System.Drawing.Drawing2D; 

 

Nicht für Deinen Fall, dient nur als Beispiel

 

protected override void OnPaint(PaintEventArgs paintEvnt)
{
   Graphics gfx = paintEvnt.Graphics;
   Pen myPen = new Pen(Color.Black);
   gfx.SmoothingMode = SmoothingMode.None;
   gfx.DrawEllipse(myPen, 20, 20, 100, 100);
   gfx.SmoothingMode = SmoothingMode.AntiAlias;
   gfx.DrawEllipse(myPen, 150, 20, 100, 100);
   gfx.PixelOffsetMode = PixelOffsetMode.HighQuality;
   gfx.DrawEllipse(myPen, 20, 150, 100, 100);
} 

 

Lösung C)Einfach EMA/WMA(higherseries,2)[0]

Lösung D)einfach belassen

  • Author

@wh, @Rumpel

 

Danke. Werde Rumpels Rat folgen.

 

Gruß

Eddy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Account

Navigation

Search

Search

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.