Sie verpassen Handelsmöglichkeiten:
- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Registrierung
Einloggen
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.
Wenn Sie kein Benutzerkonto haben, registrieren Sie sich
Offene Position verkleinern
Weiß jemand, wie man eine halbe Position schließt/verringert. Welche Funktion muss man aufrufen?
Beispiel: Eine offene Position von 10 Lots auf 5 Lots reduzieren, ohne einen weiteren Handel in der Gegenrichtung zu eröffnen?
Wird als "Teilabschluss" bezeichnet;
Geben Sie einfach an, wie viele Lose geschlossen werden sollen.
Hallo,
Versuchen Sie es auf diese Weise
for (int i=OrdersTotal()-1;i>=0 i--) {
if (OrderSelect(i, SELECT_BY_POS)) {
if (OrderSymbol()==Symbol()&&OrderType()==0) {
Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing
}
if (OrderSymbol()==Symbol()&&OrderType()==1) {
Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing
}
}
Weiß jemand, wie man eine halbe Position schließen/reduzieren kann. Welche Funktion müssen wir aufrufen? Beispiel: Eine offene Position von 10 Lots auf 5 Lots reduzieren, ohne einen weiteren Handel in die entgegengesetzte Richtung zu eröffnen?
Schließen Sie einfach den Auftrag für 5 Lots, wie folgt:
OrderClose(OrderTicket(),5.0,.......
Hallo Roger,
vielen Dank für deine Hilfe. In der Zwischenzeit habe ich es geschafft, es zum Laufen zu bringen:
OrderSend(Symbol(),OP_BUY,alLots,Ask,3,0,0,EA_Tester,Magic);
if(OrderSelect(OrdersTotal()-1, SELECT_BY_POS)==true) {
alTicker = OrderTicket();
Alert("Bought! ", alTicker);
} else Print("OrderSelect failed error code is ",GetLastError());
[/CODE]
Like that I found alTicker (after opening position) which I close later on.
But your code I will use to optimize my Closing function. Sorry for maybe "beginner's code", I am into mq4 just 2 days ... will improve - I promise
Thanks again
Try this way
[CODE]
for (int i=OrdersTotal()-1;i>=0 i--) {
if (OrderSelect(i, SELECT_BY_POS)) {
if (OrderSymbol()==Symbol()&&OrderType()==0) {
Ans=OrderClose(OrderTicket(),alLots,Bid,2);// Order closing
}
if (OrderSymbol()==Symbol()&&OrderType()==1) {
Ans=OrderClose(OrderTicket(),alLots,Ask,2);// Order closing
}
}
Wie kann ich einen festen StopLoss setzen?
Hallo!
Könnte mir bitte jemand sagen, wie ich einen festen StopLoss in diesem Code platzieren kann?
//| Daydream by Cothool |
//| Recommended: USD/JPY 1H |
//+------------------------------------------------------------------+
#define MAGIC_NUM 48213657
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}
//+------------------------------------------------------------------+
void CloseLong()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void CloseShort()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != -1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void start()
{
double HighestValue;
double LowestValue;
HighestValue = High;
LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)];
// BUY
if (Close[0] < LowestValue)
{
CloseShort();
OpenLong();
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
}
// SELL
if (Close[0] > HighestValue)
{
CloseLong();
OpenShort();
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
}
// Trailing Profit Taking for Long Position
if (CurrentDirection == 1)
{
if (CurrentTakeProfitPrice > Bid + TakeProfit * Point)
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
if (Bid >= CurrentTakeProfitPrice)
CloseLong();
}
// Trailing Profit Taking for Short Position
if (CurrentDirection == -1)
{
if (CurrentTakeProfitPrice < Ask - TakeProfit * Point)
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
if (Ask <= CurrentTakeProfitPrice)
CloseShort();
}
}
//+------------------------------------------------------------------+
Mit freundlichen Grüßen!
Hallo,
Könnte mir bitte jemand sagen, wie ich einen festen StopLoss in diesen Code einfügen kann?
Ersetzen
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, 0, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
} [/CODE]
to
[CODE]extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 15;
extern int StopLoss = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Ask-StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Bid+StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}Brauche Hilfe beim Ändern des Indikators
Hallo alle Programmierer,
Ich habe einen Indikator (Währungspositionen) im Forum gefunden, der die aktuellen Positionen anzeigt, mit denen ich gerade handle. Nun möchte ich jemanden da draußen finden, der mir hilft, diesen Indikator zu machen, um ein externes Fenster am unteren Rand des Charts zu verwenden, auch die Schriftarten und Farbe kann geändert werden. Ich bin nicht gut im Programmieren. Herzlichen Dank.
asam
Funktioniert nicht im Tester
Ich starte diesen EA im Tester und wenn er den ersten Stoploss erreicht, stoppt der Tester und fährt nicht fort, einen Test zu machen. ist es möglich, dieses Problem zu korrigieren. danke Roger.
//| Daydream by Cothool |
//| Recommended: USD/JPY 1H |
//+------------------------------------------------------------------+
#define MAGIC_NUM 48213657
//+------------------------------------------------------------------+
extern double Lots = 0.1;
extern int ChannelPeriod = 25;
extern int Slippage = 3;
extern int TakeProfit = 0;
extern int StopLoss = 15;
//+------------------------------------------------------------------+
double LastOrderTime = 0;
double CurrentDirection = 0;
double CurrentTakeProfitPrice = 0;
//+------------------------------------------------------------------+
void OpenLong()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage,Ask-StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Blue);
LastOrderTime = Time[0];
CurrentDirection = 1;
}
//+------------------------------------------------------------------+
void OpenShort()
{
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 0)
return;
OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage,Bid+StopLoss*Point, 0,
"Daydream", MAGIC_NUM, 0, Red);
LastOrderTime = Time[0];
CurrentDirection = -1;
}
//+------------------------------------------------------------------+
void CloseLong()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != 1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_BUY)
{
OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void CloseShort()
{
int i;
if (Time[0] == LastOrderTime)
return;
if (CurrentDirection != -1)
return;
for (i = 0; i < OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == Symbol() &&
OrderMagicNumber() == MAGIC_NUM && OrderType() == OP_SELL)
{
OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
LastOrderTime = Time[0];
CurrentDirection = 0;
}
}
}
//+------------------------------------------------------------------+
void start()
{
double HighestValue;
double LowestValue;
HighestValue = High;
LowestValue = Low[Lowest(NULL, 0, MODE_LOW, ChannelPeriod, 1)];
// BUY
if (Close[0] < LowestValue)
{
CloseShort();
OpenLong();
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
}
// SELL
if (Close[0] > HighestValue)
{
CloseLong();
OpenShort();
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
}
// Trailing Profit Taking for Long Position
if (CurrentDirection == 1)
{
if (CurrentTakeProfitPrice > Bid + TakeProfit * Point)
CurrentTakeProfitPrice = Bid + TakeProfit * Point;
if (Bid >= CurrentTakeProfitPrice)
CloseLong();
}
// Trailing Profit Taking for Short Position
if (CurrentDirection == -1)
{
if (CurrentTakeProfitPrice < Ask - TakeProfit * Point)
CurrentTakeProfitPrice = Ask - TakeProfit * Point;
if (Ask <= CurrentTakeProfitPrice)
CloseShort();
}
}
//+------------------------------------------------------------------+
Der Code ist erstaunlich, danke