Ich meine man kann immer einen Kommentar bei OrderSend() angeben der dann übernommen wird.
Sprich, Order halbieren ohne Kommentar löscht den alten.
Bin aber nicht sicher.
Ich meine man kann immer einen Kommentar bei OrderSend() angeben der dann übernommen wird.
Sprich, Order halbieren ohne Kommentar löscht den alten.
Bin aber nicht sicher.
Ich nutze
_trade.PositionClosePartial(posTicket,NormalizeDouble((posVolume * 0.1),_Digits),-1); // Und schließe 10% der Position
Und das sieht so aus:
bool PositionClosePartial( const ulong ticket, // Ticket der Position const double volume, // Volumen ulong deviation=ULONG_MAX // Abweichung )
Mein problem ist halt, dass im Kommentar die Art des Signals gespeichert wird und dass je nachdem verschieden vorgegangen wird:
void checkPositions(double ask, double bid) { if(PositionsTotal() < 1) return; double tslPoints = 100; for(int i = 0; i < PositionsTotal(); i++) { string symbol = PositionGetSymbol(i); //Symbol der Position i if(_Symbol == symbol) { ulong posTicket = PositionGetInteger(POSITION_TICKET); // Positionsticket int posDirection = (int)PositionGetInteger(POSITION_TYPE); // Positionsrichtung double posSize = PositionGetDouble(POSITION_VOLUME); // Positionsgröße double posOpen = PositionGetDouble(POSITION_PRICE_OPEN); // Öffnungspreis der Position double posSL = PositionGetDouble(POSITION_SL); // SL der Position double posVolume = PositionGetDouble(POSITION_VOLUME); // Volumen der Position string comment = PositionGetString(POSITION_COMMENT); // Comment der Position double abstandMult; if(comment == "fraktal") abstandMult = inpFraktalAbstandMult; else if(comment == "three inside") abstandMult = inpThreeInsideAbstandMult; else abstandMult = inpStarsAbstandMult; //------- Long Position if(posDirection == POSITION_TYPE_BUY) { double abstand = MathAbs(posSL - posOpen); //-- if(posSL < posOpen && ask >= (posOpen + (abstand*abstandMult))) { _trade.PositionModify(posTicket,posOpen,0); } //-- if(MathAbs(posSL-ask) > tslPoints*_Point && // Wenn der Abstand zwischen SL und Ask größer ist als die posSL >= posOpen) { // vorgegebenen TSL-Punkte und der SL bereits auf den Einsteig gesetzt wurde, _trade.PositionModify(posTicket,(ask-tslPoints*_Point),0); // ziehe den SL im Abstand von TSL-Punkten nach Print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " + comment); if(comment == "morning star") _trade.PositionClosePartial(posTicket,NormalizeDouble((posVolume * 0.2),_Digits),-1); // Und schließe 20% der Position else _trade.PositionClosePartial(posTicket,NormalizeDouble((posVolume * 0.1),_Digits),-1); // Und schließe 10% der Position } } } } }
Durch diese schöne Zeile:
Print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " + comment);
sollte ja immer den Kommentar ausgeben - manchmal ist der Kommentar aber halt = "" und das macht alles kaputt...
Ich nutze
Und das sieht so aus:
Mein problem ist halt, dass im Kommentar die Art des Signals gespeichert wird und dass je nachdem verschieden vorgegangen wird:
Durch diese schöne Zeile:
sollte ja immer den Kommentar ausgeben - manchmal ist der Kommentar aber halt = "" und das macht alles kaputt...
Probier es aus....
In trade.mqh findest du die Funktion
//+------------------------------------------------------------------+ //| Partial close specified opened position (for hedging mode only) | //+------------------------------------------------------------------+ bool CTrade::PositionClosePartial(const ulong ticket,const double volume,const ulong deviation) { //--- check stopped if(IsStopped(__FUNCTION__)) return(false); //--- for hedging mode only if(!IsHedging()) return(false); //--- check position existence if(!PositionSelectByTicket(ticket)) return(false); string symbol=PositionGetString(POSITION_SYMBOL); //--- clean ClearStructures(); //--- check filling if(!FillingCheck(symbol)) return(false); //--- check if((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { //--- prepare request for close BUY position m_request.type =ORDER_TYPE_SELL; m_request.price=SymbolInfoDouble(symbol,SYMBOL_BID); } else { //--- prepare request for close SELL position m_request.type =ORDER_TYPE_BUY; m_request.price=SymbolInfoDouble(symbol,SYMBOL_ASK); } //--- check volume double position_volume=PositionGetDouble(POSITION_VOLUME); if(position_volume>volume) position_volume=volume; //--- setting request m_request.action =TRADE_ACTION_DEAL; m_request.position =ticket; m_request.symbol =symbol; m_request.volume =position_volume; m_request.magic =m_magic; m_request.deviation=(deviation==ULONG_MAX) ? m_deviation : deviation; //--- close position return(OrderSend(m_request,m_result)); }
Einfach mal die zeile
m_request.comment = "Test Comment";
Unten vor Ordersend() einfügen . Spechern und testen.
Wenns geht, baust du dir deine eigene Close Fuinktion zusammen und erweiterst deine Trade.mqh .
Trade.mqh ist nur ein Framework für OrderSend()
Probier es aus....
In trade.mqh findest du die Funktion
Einfach mal die zeile
Unten vor Ordersend() einfügen . Spechern und testen.
Wenns geht, baust du dir deine eigene Close Fuinktion zusammen und erweiterst deine Trade.mqh .
Trade.mqh ist nur ein Framework für OrderSend()
Das sieht auf jeden Fall gut aus! Müsste ich da nichteinfach die gesamte Methode kopieren können und noch nen Übergabeparameter hinzufügen?
bool CTrade::PositionClosePartial(const ulong ticket,const double volume,const ulong deviation, const string comment) { //--- check stopped if(IsStopped(__FUNCTION__)) return(false); //--- for hedging mode only if(!IsHedging()) return(false); //--- check position existence if(!PositionSelectByTicket(ticket)) return(false); string symbol=PositionGetString(POSITION_SYMBOL); //--- clean ClearStructures(); //--- check filling if(!FillingCheck(symbol)) return(false); //--- check if((ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) { //--- prepare request for close BUY position m_request.type =ORDER_TYPE_SELL; m_request.price=SymbolInfoDouble(symbol,SYMBOL_BID); } else { //--- prepare request for close SELL position m_request.type =ORDER_TYPE_BUY; m_request.price=SymbolInfoDouble(symbol,SYMBOL_ASK); } //--- check volume double position_volume=PositionGetDouble(POSITION_VOLUME); if(position_volume>volume) position_volume=volume; //--- setting request m_request.action =TRADE_ACTION_DEAL; m_request.position =ticket; m_request.symbol =symbol; m_request.volume =position_volume; m_request.magic =m_magic; m_request.deviation=(deviation==ULONG_MAX) ? m_deviation : deviation; m_request.comment =comment; //--- close position return(OrderSend(m_request,m_result)); }
Wenn ich das so mache, kriege ich aber diesen Fehler:
'PositionClosePartial' - member function already defined with different parameters Trade.mqh 648 14Also ich würde halt gerne diese Methode neu hinzufügen und die alte trotzdem behalten
Das sieht auf jeden Fall gut aus! Müsste ich da nichteinfach die gesamte Methode kopieren können und noch nen Übergabeparameter hinzufügen?
Wenn ich das so mache, kriege ich aber diesen Fehler:
Also ich würde halt gerne diese Methode neu hinzufügen und die alte trotzdem behaltenChristian:
Du musst wenn du die Übergabe Parameter im body änderst, auch oben die formale Deklaration ändern
bool PositionClosePartial(const ulong ticket,const double volume,const ulong deviation=ULONG_MAX,const string comment = "");So, richtig?
Ouh man... kaum ist das erste Problem gelöst kommt schon das nächste....
Wenn ich das ganze jetzt aufrufe
double posVolume = PositionGetDouble(POSITION_VOLUME); // Volumen der Position string comment = PositionGetString(POSITION_COMMENT); // Comment der Position _trade.PositionClosePartial(posTicket,NormalizeDouble((posVolume * 0.1),_Digits),-1,comment);
bekomme ich folgenden Fehler, was bedeutet das?
'PositionClosePartial' - ambiguous call to overloaded function Candlestickpattern Riskmanagement.mq5 238 29
Achso, wies aussieh kommt das daher, dass der nicht zwischen
bool PositionClosePartial(const ulong ticket,const double volume,const ulong deviation=ULONG_MAX);
und
bool PositionClosePartial(const ulong ticket,const double volume,const ulong deviation=ULONG_MAX,const string comment = "");
unterscheiden kann. Aber wie mache ich meine neue Methode "unique"? Das ginge doch nur, wenn comment keinen default-Wert hat, da mault der aber auch rum....
okay, gute Idee! trotzdem würde mich interessieren, was man gegen diesen Fehler machen würde
- Freie Handelsapplikationen
- Über 8.000 Signale zum Kopieren
- Wirtschaftsnachrichten für die Lage an den Finanzmärkte
Sie stimmen der Website-Richtlinie und den Nutzungsbedingungen zu.