Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Hilfe mit SMAs und OBJ_VLINE (http://www.expert-advisor.com/forum/showthread.php?t=1539)

ATCDevil 19.08.11 21:39

Hilfe mit SMAs und OBJ_VLINE
 
Hi zusammen,

ich bin ganz neu hier und mache meine ersten Schritte mit MQL.

Ich möchte einen Indicator schreiben, der die Postionen an denen sich 2 Durchschnitte kreuzen mit einer vertikalen Linie versieht... Wie könnte es am Ende des Scriptes aussehen?

//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
int Crossed (double line1 , double line2)
{
static int last_direction = 0;
static int current_direction = 0;

if(line1>line2)current_direction = 1; //up
if(line1<line2)current_direction = 2; //down


if (current_direction != last_direction) //changed
{
last_direction = current_direction;
return (last_direction);
}
else
{
return (0);
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int counted_bars=IndicatorCounted();
double shortSMA, longSMA;

//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if (counted_bars>0) counted_bars--;

int pos=Bars-counted_bars;


shortSMA = iMA(NULL,0,8,0,0,0,0);
longSMA = iMA(NULL,0,21,0,0,0,0);

int isCrossed = Crossed(shortSMA,longSMA);

if (isCrossed == 1) //Blaue vertikale Linie;
if (isCrossed == 2) //Rote vertikale Linie;



Danke im Voraus für eure Mühen und euer Engagement!

Grüße

JoeDormann 12.09.11 01:16

Naja, :o

ich würde Dir den Tipp geben, in der MQL4-Doku nach createObject zu suchen und Codeausschnitte aus angebotenen Beispielen oder Open Source für Deinen Bedarf anzupassen.

Macht zwar etwas Mühe, aber dafür lernst Du es umso besser.

Gruß Joe


Alle Zeitangaben in WEZ +2. Es ist jetzt 07:06 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum