|
Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4. |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
Stop Order nach ziehen
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. 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; Code:
extern string SOTS="Stop Orders Trailing Stop?"; input bool Stop_Ord_Trailing_Stop=true; extern int Stop_Ord_TS_Step=20; 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); 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? |
Lesezeichen |
|
|