Einzelnen Beitrag anzeigen
  #3 (permalink)  
Alt 17.12.19
Uli Uli ist offline
Neues Mitglied
 
Registriert seit: Dec 2019
Beiträge: 4
Uli befindet sich auf einem aufstrebenden Ast
Standard EA Programmierung (Rectangle)

Hallo AVT!

Vielen Dank für Deine Hilfe.
Ich habe aber einen anderen Weg gefunden und
konnte nun das Rechteck auf den MT4 legen.
So weit so gut.
Aber ich hätte noch ein Paar Fragen.

1. Wie bekomme ich ein Kommentar-String in
dieses Rechteck?

2.Kann man die "Reiter" unten auf der Chartleiste
mit einem EA ansteuern? (Via Button)

Zum besseren Verständnis habe ich meinen EA hier mal gepostet.

// Programm: Mein EA
#property strict
//CrossOver--1.Teil--Anfang
int Ticket;
input int SmallEMA = 20;
input int BigEMA = 50;
input double VolumenSell = 8;
input double VolumenBuy = 8;
input int AbstandSell = 10;
input int AbstandBuy = 10;

//CrossOver--1.Teil--Ende
int OnInit()
{
//Rechteck--1.Teil--Anfang
int b = 1118;
CreateRectangle("rectangle1",NULL,b,5,240,270,Yell ow,MediumBlue,White,12);
//Rechteck--1.Teil--Ende

//Button--1.Teil--Anfang
int x = 470;
CreateButton("button1","Buy",x,5,150,30,Yellow,Gre en,White,11);
CreateButton("button2",Symbol(),x,5,150,30,Yellow, Maroon,White,11);
CreateButton("button3","Sell",x,5,150,30,Yellow,Re d,White,11);

return(INIT_SUCCEEDED);
}

void CreateButton(string btnName,
string btnText,
int &x,
int y,
int w,
int h,
color clrText,
color clrBg,
color clrBorder,
int fontSize)
{
ObjectCreate(0,btnName,OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,btnName,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,btnName,OBJPROP_YDISTANCE,y);
ObjectSetInteger(0,btnName,OBJPROP_XSIZE,w);
ObjectSetInteger(0,btnName,OBJPROP_YSIZE,h);
ObjectSetString(0,btnName,OBJPROP_TEXT,btnText);
ObjectSetInteger(0,btnName,OBJPROP_COLOR,clrText);
ObjectSetInteger(0,btnName,OBJPROP_BGCOLOR,clrBg);
ObjectSetInteger(0,btnName,OBJPROP_BORDER_COLOR,cl rBorder);
ObjectSetInteger(0,btnName,OBJPROP_BORDER_TYPE,BOR DER_FLAT);
ObjectSetInteger(0,btnName,OBJPROP_HIDDEN,true);
ObjectSetInteger(0,btnName,OBJPROP_STATE,false);
ObjectSetInteger(0,btnName,OBJPROP_FONTSIZE,fontSi ze);
x=x+w+10;
}

void DeleteButtons()
{
for(int i=ObjectsTotal()-1; i>-1; i--)
{
if(StringFind(ObjectName(i),"button")>=0) ObjectDelete(ObjectName(i));
}
}
//Button--1.Teil--Ende

//Rechteck--2.Teil--Anfang
void CreateRectangle(string recName,
string recText,
int &b,
int y,
int w,
int h,
color clrText,
color clrBg,
color clrBorder,
int fontSize)
{
ObjectCreate(0,recName,OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,recName,OBJPROP_XDISTANCE,b);
ObjectSetInteger(0,recName,OBJPROP_YDISTANCE,y);
ObjectSetInteger(0,recName,OBJPROP_XSIZE,w);
ObjectSetInteger(0,recName,OBJPROP_YSIZE,h);
ObjectSetString(0,recName,OBJPROP_TEXT,recText);
ObjectSetInteger(0,recName,OBJPROP_COLOR,clrText);
ObjectSetInteger(0,recName,OBJPROP_BGCOLOR,clrBg);
ObjectSetInteger(0,recName,OBJPROP_BORDER_COLOR,cl rBorder);
ObjectSetInteger(0,recName,OBJPROP_BORDER_TYPE,BOR DER_FLAT);
ObjectSetInteger(0,recName,OBJPROP_HIDDEN,true);
ObjectSetInteger(0,recName,OBJPROP_STATE,false);
ObjectSetInteger(0,recName,OBJPROP_FONTSIZE,fontSi ze);
ObjectSetInteger(0,recName,OBJPROP_SELECTABLE,true );
b=b+w+10;
}

void DeleteRectangle1()
{
for(int i=ObjectsTotal()-1; i>-1; i--)
{
if(StringFind(ObjectName(i),"rectangle1")>=0) ObjectDelete(ObjectName(i));
}
}
//Rechteck--2.Teil--Ende

void OnDeinit(const int reason)
{
DeleteButtons(); //zu Button
DeleteRectangle1(); //zu Rechteck
}

void OnTick()
{
//Rechteck--3.Teil--Anfang
Comment(_Symbol
+"\n\nKonto in "+AccountCurrency()
+"\n\nUhrzeit: "+TimeToStr (TimeLocal(),TIME_DATE|TIME_MINUTES) //(Time[1])
+"\n\nBroker: "+AccountCompany()
+"\n\nHebel: "+AccountLeverage()
+"\n\nKontostand: "+DoubleToStr(AccountBalance(),2)
+"\n\nMargin: "+DoubleToStr(AccountMargin(),2)
+"\n\nMargin-Level in %: "+DoubleToStr(AccountEquity()/AccountMargin()*100,2)
+"\n\nG/V: "+DoubleToStr(AccountProfit(),2)
);
//Rechteck--3.Teil--Ende

//CrossOver--2.Teil--Anfang
string signal = "";

double SmallMovingAverage1 = iMA ( _Symbol,_Period,SmallEMA,0,MODE_EMA,PRICE_CLOSE,1) ;

double BigMovingAverage1 = iMA ( _Symbol,_Period,BigEMA,0,MODE_EMA,PRICE_CLOSE,1);

double SmallMovingAverage2 = iMA ( _Symbol,_Period,SmallEMA,0,MODE_EMA,PRICE_CLOSE,2) ;

double BigMovingAverage2 = iMA ( _Symbol,_Period,BigEMA,0,MODE_EMA,PRICE_CLOSE,2);

if (BigMovingAverage1 > SmallMovingAverage1)

if (BigMovingAverage2 < SmallMovingAverage2)

{
signal = "Verkaufen";
}

if (BigMovingAverage1 < SmallMovingAverage1)

if (BigMovingAverage2 > SmallMovingAverage2)

{
signal = "Kaufen";
}

if (signal == "Kaufen" && OrdersTotal() == 0)
{
Ticket = OrderSend (_Symbol,OP_BUY,VolumenBuy,Ask,3,0,Ask+AbstandBuy* _Point,NULL,0,0,Green);
}

if (signal == "Verkaufen" && OrdersTotal() == 0)
{
Ticket = OrderSend (_Symbol,OP_SELL,VolumenSell,Bid,3,0,Bid-AbstandSell*_Point,NULL,0,0,Red);
}

//CrossOver--2.Teil--Ende
}
//Button--2.Teil--Anfang
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if(sparam=="button1")
{
Action_Button1();
ObjectSetInteger(0,"button1",OBJPROP_STATE,false);
}
else if(sparam=="button2")
{
Action_Button2();
ObjectSetInteger(0,"button2",OBJPROP_STATE,false);
}
else if(sparam=="button3")
{
Action_Button3();
ObjectSetInteger(0,"button3",OBJPROP_STATE,false);
}
}

void Action_Button1()
{
PlaySound("ok.wav");
}

void Action_Button2()
{
PlaySound("alert.wav");
}

void Action_Button3()
{
PlaySound("news.wav");
//Button--2.Teil--Ende
}

Wenn du den EA ausprobierst ...
...die Daten oben links sind ein Kommentar-String und die hätte
ich gerne oben rechts im Rechteck.

Ich habe ein Paar Button installiert mit womit ich die "Reiter" auf der
Chartleiste ansprechen möchte.
Vieleicht hast du eine Idee.

So, erstmal bis hier her.


MfG Uli