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)
-   -   Stop Order nach ziehen (http://www.expert-advisor.com/forum/showthread.php?t=6186)

MA-EA 29.08.18 04:00

Stop Order nach ziehen
 
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo.

Der komplette Code ist im Anhang.

Ich versuche seit einiger Zeit, Stop Order Einstiegspreise usw. hinter Ask und Bid her zu ziehen. Das in einstellbaren Schritten. Aber mir fehlt irgendwie der Überblick. Die Stop-Orders werden zwar geändert, allerdings in beide Richtungen. Und nicht in (eingestellten 8er- bis 20er-) Schritten. Da muss irgendwo nen Logik-Fehler drin sein. :confused:

Die Stop-Orders sollen einen einstellbaren Abstand zu Ask/Bid haben:
Code:

extern string DAB1="Distance to";
extern string DAB2="current";
extern string DAB3="Ask / Bid";
extern int Buy_Stop_Dist=64;
extern int Sell_Stop_Dist=64;

Und dann in entsprechenden Schritten hinter Ask/Bid her gezogen werden:
Code:

extern string SOTS="Stop Orders Trailing Stop?";
input bool Stop_Ord_Trailing_Stop=true;
extern int Stop_Ord_TS_Step=20;

So werden Stop-Einstiegspreise berechnet:
Code:

double Buy_Stop_OOP=NormalizeDouble(M_CA+Buy_Stop_Dist*_Point,_Digits);
double Sel_Stop_OOP=NormalizeDouble(M_CB-Sell_Stop_Dist*_Point,_Digits);

Die Funktionen usw. zum hinterher ziehn. Da blick ich bei der Logik einfach nicht durch. :confused:
Code:

if(Stop_Ord_Trailing_Stop==true) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  for(i=OrdersTotal()-1;i>=0;i--) {
    if(OrderSelect(i,SELECT_BY_POS)) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

      if(OrderType()==OP_BUYSTOP&&OrderMagicNumber()==Buy_Stop_MN&&OrderSymbol()==Symbol()) {
     
        double BuyStOOP = OrderOpenPrice();

//     
        double BuyStOOP__StopOrdTSS = NormalizeDouble( BuyStOOP + Buy_Stop_Dist *_Point,_Digits);

//
        double BuyStOOP__BuyStopDist__StopOrdTSS = NormalizeDouble( M_CA + Buy_Stop_Dist + Stop_Ord_TS_Step *_Point,_Digits);


        double New_Buy_St_OOP = NormalizeDouble( M_CA + Buy_Stop_Dist *_Point,_Digits);
//

        if(NormalizeDouble( BuyStOOP__StopOrdTSS > BuyStOOP__BuyStopDist__StopOrdTSS *_Point,_Digits))OrderModify(OrderTicket(),New_Buy_St_OOP,B_Stop_SL,B_Stop_TP,0,Maroon);} } }

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  for(i=OrdersTotal()-1;i>=0;i--) {
    if(OrderSelect(i,SELECT_BY_POS)) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
      if(OrderType()==OP_SELLSTOP&&OrderMagicNumber()==Sell_Stop_MN&&OrderSymbol()==Symbol()) {


        double Sel_St_OOP = OrderOpenPrice();


        double SelStOOP__SelStopDist = NormalizeDouble( Sel_St_OOP - Sell_Stop_Dist *_Point,_Digits);

//     
        double MCB__SelStopDist__StopOrdTSS = NormalizeDouble( M_CB - Sell_Stop_Dist - Stop_Ord_TS_Step *_Point,_Digits);


        double New_Sel_St_OOP = NormalizeDouble( M_CB - Sell_Stop_Dist *_Point,_Digits);

//     
        if(NormalizeDouble( MCB__SelStopDist__StopOrdTSS < SelStOOP__SelStopDist  *_Point,_Digits))OrderModify(OrderTicket(),New_Sel_St_OOP,S_Stop_SL,S_Stop_TP,0,Maroon);} } } }


Edit:Eigentlich müssen die OOP nicht noch neu berechnet werden oder?

daybyter 09.09.18 05:31

Da fehlt doch noch eine Abfrage, ob der neue Stop > als der Alte (bei Buy) bzw kleiner (bei Dell) ist. Du willst ja den Stop nur nachziehen, und Dich im andern Fall ausstoppen lassen.


Alle Zeitangaben in WEZ +2. Es ist jetzt 04:41 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