Habe diesen Code von einem Youtuber (Jim Dandy 1958). Ursprünglich war es ein kleines Programm mit zwei Buttons auf dem Chart, einem für Buy und einem für Sell Order: Man drückt den Knopf und sofort wird mit Hilfe der externen Variablen eine komplette Order inklusive SL und TP erstellt. Soweit hat das auch funktioniert.
Jetzt habe ich versucht, das Ganze so zu verändern, dass ich vier Buttons habe, mit denen ich BuyLimit, SellLimit, BuyStop und SellStop erzeugen kann, wieder mit Hilfe der externen Variablen. Nur leider klappt das nicht. Meta Trader sagt "invalid ticket", Fehlercode 4051, d.h. ungültiger Funktionsparameter. Ich schätze es liegt daran, dass ich das Argument im Chart Event und in der PlaceOrder Funktion gleich benannt habe, bin mir jedoch nicht sicher, wie ich jetzt verfahren soll. Bin dankbar für jede Hilfe.
input double volume = 1.0; input bool StopLoss = true; input int SL = 100; input bool TakeProfit = true; input int TP = 500; input int distance = 50; //die gewünschte Distanz zwischen Kauf-/Verkaufpreis und Pending Order. double pip = Point;
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(Digits == 3 || Digits == 5) pip *= 10; //zunächst wird hier geklärt, wie viele Nachkommastellen das Chart hat. Davon hängt //ab, ob ein Pip ein Point ist oder zehn Points.
//+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- if (id==CHARTEVENT_OBJECT_CLICK && sparam == "buylimit") PlaceOrder(OP_BUYLIMIT); //stellt einen Zusammenhang zwischen einem Knopfdruck und einer Aktion //in der Funtion "PlaceOrder" her, siehe unten
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "selllimit") PlaceOrder(OP_SELLLIMIT);
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "buystop") PlaceOrder(OP_BUYSTOP);
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "sellstop") PlaceOrder(OP_SELLSTOP); } //+------------------------------------------------------------------+
void ButtonCreate() //Erstellt die Knöpfe auf dem Chart { int chart_ID = 0; string name1 = "buylimit"; //---
if(!ObjectCreate(0,name1,OBJ_BUTTON,0,0,0)) { Print(__FUNCTION__, ": failed to create the buy limit button! Error code = ",GetLastError()); return; } //--- set button coordinates ObjectSetInteger(chart_ID,name1,OBJPROP_XDISTANCE,0); ObjectSetInteger(chart_ID,name1,OBJPROP_YDISTANCE,150); //--- set button size ObjectSetInteger(chart_ID,name1,OBJPROP_XSIZE,100); ObjectSetInteger(chart_ID,name1,OBJPROP_YSIZE,50); //--- set the chart's corner, relative to which point coordinates are defined ObjectSetInteger(chart_ID,name1,OBJPROP_CORNER,2); //--- set the text ObjectSetString(chart_ID,name1,OBJPROP_TEXT,"BUYLIMIT"); //--- set text font ObjectSetString(chart_ID,name1,OBJPROP_FONT,"Arial"); //--- set font size ObjectSetInteger(chart_ID,name1,OBJPROP_FONTSIZE,12); //--- set text color ObjectSetInteger(chart_ID,name1,OBJPROP_COLOR,clrGreen); //--- set background color ObjectSetInteger(chart_ID,name1,OBJPROP_BGCOLOR,clrBlack); //--- set border color ObjectSetInteger(chart_ID,name1,OBJPROP_BORDER_COLOR,clrGray); //--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name1,OBJPROP_BACK,false); //--- set button state ObjectSetInteger(chart_ID,name1,OBJPROP_STATE,true); //--- enable (true) or disable (false) the mode of moving the button by mouse ObjectSetInteger(chart_ID,name1,OBJPROP_SELECTABLE,false); ObjectSetInteger(chart_ID,name1,OBJPROP_SELECTED,false); //--- hide (true) or display (false) graphical object name1 in the object list ObjectSetInteger(chart_ID,name1,OBJPROP_HIDDEN,false); //--- set the priority for receiving the event of a mouse click in the chart ObjectSetInteger(chart_ID,name1,OBJPROP_ZORDER,0);
if(!ObjectCreate(0,name2,OBJ_BUTTON,0,0,0)) { Print(__FUNCTION__, ": failed to create the sell limit button! Error code = ",GetLastError()); return; } //--- set button coordinates ObjectSetInteger(chart_ID,name2,OBJPROP_XDISTANCE,0); ObjectSetInteger(chart_ID,name2,OBJPROP_YDISTANCE,200); //--- set button size ObjectSetInteger(chart_ID,name2,OBJPROP_XSIZE,100); ObjectSetInteger(chart_ID,name2,OBJPROP_YSIZE,50); //--- set the chart's corner, relative to which point coordinates are defined ObjectSetInteger(chart_ID,name2,OBJPROP_CORNER,2); //--- set the text ObjectSetString(chart_ID,name2,OBJPROP_TEXT,"SELLLIMIT"); //--- set text font ObjectSetString(chart_ID,name2,OBJPROP_FONT,"Arial"); //--- set font size ObjectSetInteger(chart_ID,name2,OBJPROP_FONTSIZE,12); //--- set text color ObjectSetInteger(chart_ID,name2,OBJPROP_COLOR,clrRed); //--- set background color ObjectSetInteger(chart_ID,name2,OBJPROP_BGCOLOR,clrBlack); //--- set border color ObjectSetInteger(chart_ID,name2,OBJPROP_BORDER_COLOR,clrGray); //--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name2,OBJPROP_BACK,false); //--- set button state ObjectSetInteger(chart_ID,name2,OBJPROP_STATE,true); //--- enable (true) or disable (false) the mode of moving the button by mouse ObjectSetInteger(chart_ID,name2,OBJPROP_SELECTABLE,false); ObjectSetInteger(chart_ID,name2,OBJPROP_SELECTED,false); //--- hide (true) or display (false) graphical object name2 in the object list ObjectSetInteger(chart_ID,name2,OBJPROP_HIDDEN,false); //--- set the priority for receiving the event of a mouse click in the chart ObjectSetInteger(chart_ID,name2,OBJPROP_ZORDER,0);
if(!ObjectCreate(0,name3,OBJ_BUTTON,0,0,0)) { Print(__FUNCTION__, ": failed to create the buy stop button! Error code = ",GetLastError()); return; } //--- set button coordinates ObjectSetInteger(chart_ID,name3,OBJPROP_XDISTANCE,0); ObjectSetInteger(chart_ID,name3,OBJPROP_YDISTANCE,250); //--- set button size ObjectSetInteger(chart_ID,name3,OBJPROP_XSIZE,100); ObjectSetInteger(chart_ID,name3,OBJPROP_YSIZE,50); //--- set the chart's corner, relative to which point coordinates are defined ObjectSetInteger(chart_ID,name3,OBJPROP_CORNER,2); //--- set the text ObjectSetString(chart_ID,name3,OBJPROP_TEXT,"BUYSTOP"); //--- set text font ObjectSetString(chart_ID,name3,OBJPROP_FONT,"Arial"); //--- set font size ObjectSetInteger(chart_ID,name3,OBJPROP_FONTSIZE,12); //--- set text color ObjectSetInteger(chart_ID,name3,OBJPROP_COLOR,clrWhite); //--- set background color ObjectSetInteger(chart_ID,name3,OBJPROP_BGCOLOR,clrBlack); //--- set border color ObjectSetInteger(chart_ID,name3,OBJPROP_BORDER_COLOR,clrGray); //--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name3,OBJPROP_BACK,false); //--- set button state ObjectSetInteger(chart_ID,name3,OBJPROP_STATE,true); //--- enable (true) or disable (false) the mode of moving the button by mouse ObjectSetInteger(chart_ID,name3,OBJPROP_SELECTABLE,false); ObjectSetInteger(chart_ID,name3,OBJPROP_SELECTED,false); //--- hide (true) or display (false) graphical object name3 in the object list ObjectSetInteger(chart_ID,name3,OBJPROP_HIDDEN,false); //--- set the priority for receiving the event of a mouse click in the chart ObjectSetInteger(chart_ID,name3,OBJPROP_ZORDER,0);
if(!ObjectCreate(0,name4,OBJ_BUTTON,0,0,0)) { Print(__FUNCTION__, ": failed to create the sell stop button! Error code = ",GetLastError()); return; } //--- set button coordinates ObjectSetInteger(chart_ID,name4,OBJPROP_XDISTANCE,0); ObjectSetInteger(chart_ID,name4,OBJPROP_YDISTANCE,300); //--- set button size ObjectSetInteger(chart_ID,name4,OBJPROP_XSIZE,100); ObjectSetInteger(chart_ID,name4,OBJPROP_YSIZE,50); //--- set the chart's corner, relative to which point coordinates are defined ObjectSetInteger(chart_ID,name4,OBJPROP_CORNER,2); //--- set the text ObjectSetString(chart_ID,name4,OBJPROP_TEXT,"SELLSTOP"); //--- set text font ObjectSetString(chart_ID,name4,OBJPROP_FONT,"Arial"); //--- set font size ObjectSetInteger(chart_ID,name4,OBJPROP_FONTSIZE,12); //--- set text color ObjectSetInteger(chart_ID,name4,OBJPROP_COLOR,clrBlue); //--- set background color ObjectSetInteger(chart_ID,name4,OBJPROP_BGCOLOR,clrBlack); //--- set border color ObjectSetInteger(chart_ID,name4,OBJPROP_BORDER_COLOR,clrGray); //--- display in the foreground (false) or background (true) ObjectSetInteger(chart_ID,name4,OBJPROP_BACK,false); //--- set button state ObjectSetInteger(chart_ID,name4,OBJPROP_STATE,true); //--- enable (true) or disable (false) the mode of moving the button by mouse ObjectSetInteger(chart_ID,name4,OBJPROP_SELECTABLE,false); ObjectSetInteger(chart_ID,name4,OBJPROP_SELECTED,false); //--- hide (true) or display (false) graphical object name4 in the object list ObjectSetInteger(chart_ID,name4,OBJPROP_HIDDEN,false); //--- set the priority for receiving the event of a mouse click in the chart ObjectSetInteger(chart_ID,name4,OBJPROP_ZORDER,0); } //--- successful execution
//+------------------------------------------------------------------+ void PlaceOrder(int action) //Hier müsste normalerweise eine Order erstellt und dann unter einer Ticketnummer //aufgegriffen und modifiziert werden, aber leider ist das nicht der Fall. { if(action==OP_BUYLIMIT) { int ticket = OrderSend(Symbol(),action,volume,(Ask-distance*pip),30,0,0,NULL,0,0,clrGreen); if(!OrderModify(ticket,OrderOpenPrice(),(Ask-SL*pip)*StopLoss,(Ask+TP*pip)*TakeProfit,0,clrGreen)) Print("unable to modify the buy limit order Error code = ",GetLastError()); }
if(action==OP_SELLLIMIT) { int ticket = OrderSend(Symbol(),action,volume,(Bid+distance*pip),30,0,0,NULL,0,0,clrRed); if(!OrderModify(ticket,OrderOpenPrice(),(Bid+SL*pip)*StopLoss,(Bid-TP*pip)*TakeProfit,0,clrRed)) Print("unable to modify the sell limit order Error code = ",GetLastError()); }
if(action==OP_BUYSTOP) { int ticket = OrderSend(Symbol(),action,volume,(Ask+distance*pip),30,0,0,NULL,0,0,clrGreen); if(!OrderModify(ticket,OrderOpenPrice(),(Ask-SL*pip)*StopLoss,(Ask+TP*pip)*TakeProfit,0,clrGreen)) Print("unable to modify the buy stop order Error code = ",GetLastError()); }
if(action==OP_SELLSTOP) { int ticket = OrderSend(Symbol(),action,volume,(Bid-distance*pip),30,0,0,NULL,0,0,clrRed); if(!OrderModify(ticket,OrderOpenPrice(),(Bid+SL*pip)*StopLoss,(Bid-TP*pip)*TakeProfit,0,clrRed)) Print("unable to modify the sell stop order Error code = ",GetLastError()); } }
Wählen Sie eine passende Handelsstrategie und abonnieren Sie sie mit wenigen Klicks. Alle Signale sind mit einer detaillierten Statistik und informativen Charts versehen. Werden Sie Provider von Handelssignalen und verkaufen Sie Abonnements für Ihr Signal an tausende Trader weltweit. Dank unserem Service kann Ihre Gewinnstrategie auch bei einem...
Wenn Sie kein Benutzerkonto haben, registrieren Sie sich
Erlauben Sie die Verwendung von Cookies, um sich auf der Website MQL5.com anzumelden.
Bitte aktivieren Sie die notwendige Einstellung in Ihrem Browser, da Sie sich sonst nicht einloggen können.
Sie sind angemeldet. Die Zwei-Faktor-Authentifizierung wurde deaktiviert. Richten Sie sie erneut ein und scannen Sie einen neuen QR-Code oder fahren Sie mit deaktivierter Zwei-Faktor-Authentifizierung fort.
Hallo zusammen!
Habe diesen Code von einem Youtuber (Jim Dandy 1958). Ursprünglich war es ein kleines Programm mit zwei Buttons auf dem Chart, einem für Buy und einem für Sell Order: Man drückt den Knopf und sofort wird mit Hilfe der externen Variablen eine komplette Order inklusive SL und TP erstellt. Soweit hat das auch funktioniert.
Jetzt habe ich versucht, das Ganze so zu verändern, dass ich vier Buttons habe, mit denen ich BuyLimit, SellLimit, BuyStop und SellStop erzeugen kann, wieder mit Hilfe der externen Variablen. Nur leider klappt das nicht. Meta Trader sagt "invalid ticket", Fehlercode 4051, d.h. ungültiger Funktionsparameter. Ich schätze es liegt daran, dass ich das Argument im Chart Event und in der PlaceOrder Funktion gleich benannt habe, bin mir jedoch nicht sicher, wie ich jetzt verfahren soll. Bin dankbar für jede Hilfe.
Hier der Code:
//+------------------------------------------------------------------+
//| PendingButtonTrader.mq4 |
//| Copyright 2017, dermatthiaszimmermann@gmx.de |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, dermatthiaszimmermann@gmx.de"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input double volume = 1.0;
input bool StopLoss = true;
input int SL = 100;
input bool TakeProfit = true;
input int TP = 500;
input int distance = 50;
//die gewünschte Distanz zwischen Kauf-/Verkaufpreis und Pending Order.
double pip = Point;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(Digits == 3 || Digits == 5)
pip *= 10;
//zunächst wird hier geklärt, wie viele Nachkommastellen das Chart hat. Davon hängt
//ab, ob ein Pip ein Point ist oder zehn Points.
ButtonCreate();
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
ObjectDelete("buylimit");
ObjectDelete("selllimit");
ObjectDelete("buystop");
ObjectDelete("sellstop");
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{};
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "buylimit")
PlaceOrder(OP_BUYLIMIT);
//stellt einen Zusammenhang zwischen einem Knopfdruck und einer Aktion
//in der Funtion "PlaceOrder" her, siehe unten
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "selllimit")
PlaceOrder(OP_SELLLIMIT);
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "buystop")
PlaceOrder(OP_BUYSTOP);
if (id==CHARTEVENT_OBJECT_CLICK && sparam == "sellstop")
PlaceOrder(OP_SELLSTOP);
}
//+------------------------------------------------------------------+
void ButtonCreate()
//Erstellt die Knöpfe auf dem Chart
{
int chart_ID = 0;
string name1 = "buylimit";
//---
if(!ObjectCreate(0,name1,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
": failed to create the buy limit button! Error code = ",GetLastError());
return;
}
//--- set button coordinates
ObjectSetInteger(chart_ID,name1,OBJPROP_XDISTANCE,0);
ObjectSetInteger(chart_ID,name1,OBJPROP_YDISTANCE,150);
//--- set button size
ObjectSetInteger(chart_ID,name1,OBJPROP_XSIZE,100);
ObjectSetInteger(chart_ID,name1,OBJPROP_YSIZE,50);
//--- set the chart's corner, relative to which point coordinates are defined
ObjectSetInteger(chart_ID,name1,OBJPROP_CORNER,2);
//--- set the text
ObjectSetString(chart_ID,name1,OBJPROP_TEXT,"BUYLIMIT");
//--- set text font
ObjectSetString(chart_ID,name1,OBJPROP_FONT,"Arial");
//--- set font size
ObjectSetInteger(chart_ID,name1,OBJPROP_FONTSIZE,12);
//--- set text color
ObjectSetInteger(chart_ID,name1,OBJPROP_COLOR,clrGreen);
//--- set background color
ObjectSetInteger(chart_ID,name1,OBJPROP_BGCOLOR,clrBlack);
//--- set border color
ObjectSetInteger(chart_ID,name1,OBJPROP_BORDER_COLOR,clrGray);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name1,OBJPROP_BACK,false);
//--- set button state
ObjectSetInteger(chart_ID,name1,OBJPROP_STATE,true);
//--- enable (true) or disable (false) the mode of moving the button by mouse
ObjectSetInteger(chart_ID,name1,OBJPROP_SELECTABLE,false);
ObjectSetInteger(chart_ID,name1,OBJPROP_SELECTED,false);
//--- hide (true) or display (false) graphical object name1 in the object list
ObjectSetInteger(chart_ID,name1,OBJPROP_HIDDEN,false);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name1,OBJPROP_ZORDER,0);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string name2 = "selllimit";
//---
if(!ObjectCreate(0,name2,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
": failed to create the sell limit button! Error code = ",GetLastError());
return;
}
//--- set button coordinates
ObjectSetInteger(chart_ID,name2,OBJPROP_XDISTANCE,0);
ObjectSetInteger(chart_ID,name2,OBJPROP_YDISTANCE,200);
//--- set button size
ObjectSetInteger(chart_ID,name2,OBJPROP_XSIZE,100);
ObjectSetInteger(chart_ID,name2,OBJPROP_YSIZE,50);
//--- set the chart's corner, relative to which point coordinates are defined
ObjectSetInteger(chart_ID,name2,OBJPROP_CORNER,2);
//--- set the text
ObjectSetString(chart_ID,name2,OBJPROP_TEXT,"SELLLIMIT");
//--- set text font
ObjectSetString(chart_ID,name2,OBJPROP_FONT,"Arial");
//--- set font size
ObjectSetInteger(chart_ID,name2,OBJPROP_FONTSIZE,12);
//--- set text color
ObjectSetInteger(chart_ID,name2,OBJPROP_COLOR,clrRed);
//--- set background color
ObjectSetInteger(chart_ID,name2,OBJPROP_BGCOLOR,clrBlack);
//--- set border color
ObjectSetInteger(chart_ID,name2,OBJPROP_BORDER_COLOR,clrGray);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name2,OBJPROP_BACK,false);
//--- set button state
ObjectSetInteger(chart_ID,name2,OBJPROP_STATE,true);
//--- enable (true) or disable (false) the mode of moving the button by mouse
ObjectSetInteger(chart_ID,name2,OBJPROP_SELECTABLE,false);
ObjectSetInteger(chart_ID,name2,OBJPROP_SELECTED,false);
//--- hide (true) or display (false) graphical object name2 in the object list
ObjectSetInteger(chart_ID,name2,OBJPROP_HIDDEN,false);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name2,OBJPROP_ZORDER,0);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string name3 = "buystop";
//---
if(!ObjectCreate(0,name3,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
": failed to create the buy stop button! Error code = ",GetLastError());
return;
}
//--- set button coordinates
ObjectSetInteger(chart_ID,name3,OBJPROP_XDISTANCE,0);
ObjectSetInteger(chart_ID,name3,OBJPROP_YDISTANCE,250);
//--- set button size
ObjectSetInteger(chart_ID,name3,OBJPROP_XSIZE,100);
ObjectSetInteger(chart_ID,name3,OBJPROP_YSIZE,50);
//--- set the chart's corner, relative to which point coordinates are defined
ObjectSetInteger(chart_ID,name3,OBJPROP_CORNER,2);
//--- set the text
ObjectSetString(chart_ID,name3,OBJPROP_TEXT,"BUYSTOP");
//--- set text font
ObjectSetString(chart_ID,name3,OBJPROP_FONT,"Arial");
//--- set font size
ObjectSetInteger(chart_ID,name3,OBJPROP_FONTSIZE,12);
//--- set text color
ObjectSetInteger(chart_ID,name3,OBJPROP_COLOR,clrWhite);
//--- set background color
ObjectSetInteger(chart_ID,name3,OBJPROP_BGCOLOR,clrBlack);
//--- set border color
ObjectSetInteger(chart_ID,name3,OBJPROP_BORDER_COLOR,clrGray);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name3,OBJPROP_BACK,false);
//--- set button state
ObjectSetInteger(chart_ID,name3,OBJPROP_STATE,true);
//--- enable (true) or disable (false) the mode of moving the button by mouse
ObjectSetInteger(chart_ID,name3,OBJPROP_SELECTABLE,false);
ObjectSetInteger(chart_ID,name3,OBJPROP_SELECTED,false);
//--- hide (true) or display (false) graphical object name3 in the object list
ObjectSetInteger(chart_ID,name3,OBJPROP_HIDDEN,false);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name3,OBJPROP_ZORDER,0);
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string name4 = "sellstop";
//---
if(!ObjectCreate(0,name4,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
": failed to create the sell stop button! Error code = ",GetLastError());
return;
}
//--- set button coordinates
ObjectSetInteger(chart_ID,name4,OBJPROP_XDISTANCE,0);
ObjectSetInteger(chart_ID,name4,OBJPROP_YDISTANCE,300);
//--- set button size
ObjectSetInteger(chart_ID,name4,OBJPROP_XSIZE,100);
ObjectSetInteger(chart_ID,name4,OBJPROP_YSIZE,50);
//--- set the chart's corner, relative to which point coordinates are defined
ObjectSetInteger(chart_ID,name4,OBJPROP_CORNER,2);
//--- set the text
ObjectSetString(chart_ID,name4,OBJPROP_TEXT,"SELLSTOP");
//--- set text font
ObjectSetString(chart_ID,name4,OBJPROP_FONT,"Arial");
//--- set font size
ObjectSetInteger(chart_ID,name4,OBJPROP_FONTSIZE,12);
//--- set text color
ObjectSetInteger(chart_ID,name4,OBJPROP_COLOR,clrBlue);
//--- set background color
ObjectSetInteger(chart_ID,name4,OBJPROP_BGCOLOR,clrBlack);
//--- set border color
ObjectSetInteger(chart_ID,name4,OBJPROP_BORDER_COLOR,clrGray);
//--- display in the foreground (false) or background (true)
ObjectSetInteger(chart_ID,name4,OBJPROP_BACK,false);
//--- set button state
ObjectSetInteger(chart_ID,name4,OBJPROP_STATE,true);
//--- enable (true) or disable (false) the mode of moving the button by mouse
ObjectSetInteger(chart_ID,name4,OBJPROP_SELECTABLE,false);
ObjectSetInteger(chart_ID,name4,OBJPROP_SELECTED,false);
//--- hide (true) or display (false) graphical object name4 in the object list
ObjectSetInteger(chart_ID,name4,OBJPROP_HIDDEN,false);
//--- set the priority for receiving the event of a mouse click in the chart
ObjectSetInteger(chart_ID,name4,OBJPROP_ZORDER,0);
}
//--- successful execution
//+------------------------------------------------------------------+
void PlaceOrder(int action)
//Hier müsste normalerweise eine Order erstellt und dann unter einer Ticketnummer
//aufgegriffen und modifiziert werden, aber leider ist das nicht der Fall.
{
if(action==OP_BUYLIMIT)
{
int ticket = OrderSend(Symbol(),action,volume,(Ask-distance*pip),30,0,0,NULL,0,0,clrGreen);
if(!OrderModify(ticket,OrderOpenPrice(),(Ask-SL*pip)*StopLoss,(Ask+TP*pip)*TakeProfit,0,clrGreen))
Print("unable to modify the buy limit order Error code = ",GetLastError());
}
if(action==OP_SELLLIMIT)
{
int ticket = OrderSend(Symbol(),action,volume,(Bid+distance*pip),30,0,0,NULL,0,0,clrRed);
if(!OrderModify(ticket,OrderOpenPrice(),(Bid+SL*pip)*StopLoss,(Bid-TP*pip)*TakeProfit,0,clrRed))
Print("unable to modify the sell limit order Error code = ",GetLastError());
}
if(action==OP_BUYSTOP)
{
int ticket = OrderSend(Symbol(),action,volume,(Ask+distance*pip),30,0,0,NULL,0,0,clrGreen);
if(!OrderModify(ticket,OrderOpenPrice(),(Ask-SL*pip)*StopLoss,(Ask+TP*pip)*TakeProfit,0,clrGreen))
Print("unable to modify the buy stop order Error code = ",GetLastError());
}
if(action==OP_SELLSTOP)
{
int ticket = OrderSend(Symbol(),action,volume,(Bid-distance*pip),30,0,0,NULL,0,0,clrRed);
if(!OrderModify(ticket,OrderOpenPrice(),(Bid+SL*pip)*StopLoss,(Bid-TP*pip)*TakeProfit,0,clrRed))
Print("unable to modify the sell stop order Error code = ",GetLastError());
}
}