Jump to content
Tom Next - Daytrading Community

Multitimeframe-Indikator


Eddy

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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();
}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...