|
Startseite | Registrieren | Hilfe | Benutzerliste | Kalender | Suchen | Heutige Beiträge | Alle Foren als gelesen markieren |
Programmierung MQL4 Hier gehts rund ums Programmieren in MQL4. |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
Nachtrag:
wenn ich einen EURUSD Chart öffne, und dann auf das Script gehe und "Anwenden auf Chart" auswähle, dann habe ich bessere Werte:
TP = 1.0989 SL = 1.0968 etc. aber wieder OrderSend failed with error #4109. Prinzipiell kann ich (manuell) Positionen öffnen. Nur halt nicht per Script / EA. |
|
|||
Zitat:
Alert("Bid-Price = ", MarketInfo("EURUSD",MODE_BID));// EURUSD chart OrderSend("EURUSD",OP_BUY,1,MarketInfo("EURUSD",MO DE_ASK),30,0,0,"My order",16384,0,clrGreen); |
|
|||
Hallo,
ich glaube nun, dass mich der Tipp deutlich weitergebracht hat, pako ! Mein Script sieht nun folgendermaßen aus: int start() { int ticket, iSlipPage, iSLPips, iTPPips; double dStopLoss, dTakeProfit, dLots, dAskPrice, dBidPrice; string sText,sArrow; iSLPips=100; //Stop Loss in Pips iTPPips=100; //Take Profit in Pips dLots=0.01; //Amount of Lots iSlipPage=5; sText="My Order"; //Order Text sArrow=CLR_NONE; //Order Arrow Color dAskPrice=MarketInfo("EURUSD",MODE_ASK); dBidPrice=MarketInfo("EURUSD",MODE_BID); dStopLoss=(dAskPrice * 10000 - iSLPips) / 10000; dTakeProfit=(dAskPrice * 10000 + iTPPips) / 10000; ticket=OrderSend("EURUSD", OP_BUY, dLots, dBidPrice, iSlipPage, dStopLoss, dTakeProfit, sText, 000, 0, sArrow); if(ticket<0) { Alert("OrderSend failed with error = #",GetLastError()); Alert("Order-Text = ", sText); Alert("Lot-Size = ", dLots); Alert("Ask-Price = ", dAskPrice); Alert("Bid-Price = ", dBidPrice); Alert("SL = ", dStopLoss); Alert("TP = ", dTakeProfit); Alert("SlipPage = ", iSlipPage); } return(0); } Es scheint mir saubere Werte zu liefern und auf den Ticker zu laufen, den ich möchte, nämlich EURUSD. Nächstes Problem (da immer noch #4109 error): Mein Broker ist wohl ein 5-digit-Broker (fxcc). Die Alerts sagen mir aber: TP: 1.0967 SL: 1.0767 Bid-Price: 1.0867 Ask-Price: 1.0867 was doch 4-digit ist, richtig ? (=Stellen nach dem Komma) Wie bekomme ich es umgebaut, dass ich mit 5-digit-Werten arbeite ? Oder liegt der Fehler noch woanders ? Dankeee ! |
|
|||
Wir mir scheint liefert
Alert("Digits after decimal point=",MarketInfo("EURUSD",MODE_DIGITS)); 5 digits, so wie ich es brauche, jedoch bekomme ich diesen Wert mit den 5 Nachkommastellen nicht in die Variable dAskPrice hinein. Nach der Zuweisung habe ich dort wieder nur 4 Nachkommastellen. Habe auch probiert einen String wie "0.12345" per StrToDouble umzuwandeln: Zack bekomme ich wieder 0.1234 Eine double - Variable kann noch 0.12345 aufnehmen - oder ? Was mache ich falsch ? |
|
|||
Code:
//+------------------------------------------------------------------+ //| Chton.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int ticket,iSlipPage,iSLPips,iTPPips; double dStopLoss,dTakeProfit,dLots,dAskPrice,dBidPrice,dPoint; string sText; color cArrow; iSLPips=100; //Stop Loss in Pips iTPPips=100; //Take Profit in Pips dLots=0.01; //Amount of Lots iSlipPage=5; sText="My Order"; //Order Text cArrow=clrLime; //Order Arrow Color dAskPrice=MarketInfo("EURUSD",MODE_ASK); dBidPrice=MarketInfo("EURUSD",MODE_BID); dPoint =MarketInfo("EURUSD",MODE_POINT); dStopLoss=(dAskPrice-iSLPips*dPoint); dTakeProfit=(dAskPrice+iTPPips*dPoint); ticket=OrderSend("EURUSD",OP_BUY,dLots,dAskPrice,iSlipPage,dStopLoss,dTakeProfit,sText,2345678,0,cArrow); if(ticket<0) { Alert("OrderSend failed with error = #",GetLastError()); Alert("Order-Text = ",sText); Alert("Lot-Size = ",dLots); Alert("Ask-Price = ",dAskPrice); Alert("Bid-Price = ",dBidPrice); Alert("SL = ",dStopLoss); Alert("TP = ",dTakeProfit); Alert("SlipPage = ",iSlipPage); } else Alert("OrderSend successful ticket = ",ticket); } //+------------------------------------------------------------------+ // 4109 ERR_TRADE_NOT_ALLOWED Trade is not allowed. Enable checkbox "Allow live trading" in the Expert Advisor properties |
|
|||
Und ja, ich kann Code für "5-digit-Brokers ergoogeln, da kommt aber mein nächstes Problem:
"Point" ist bei mir aus für mich unerfindlichen Gründen 0, also brauche ich damit wohl nix zu multiplizieren ... zB.:Code for 5-digit brokers //+------------------------------------------------------------------+ //| Tutorial15.mq4 | //| Copyright 2014, ForexBoat | //| Forex Trading Training Courses For Beginners - Learn The Basics and What It Is | //+------------------------------------------------------------------+ #property copyright "Copyright 2014, ForexBoat" #property link "http://www.forexboat.com" #property version "1.00" #property strict #property script_show_inputs //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ extern int TakeProfit = 10; extern int StopLoss = 10; void OnStart() { double TakeProfitLevel; double StopLossLevel; TakeProfitLevel = Bid + TakeProfit*Point*10; //0.00001 * 10 = 0.0001 StopLossLevel = Bid - StopLoss*Point*10; Alert("TakeProfitLevel = ", TakeProfitLevel); Alert("StopLossLevel = ", StopLossLevel); OrderSend("EURUSD", OP_BUY, 1.0, Ask, 10*10, StopLossLevel, TakeProfitLevel, "My 1st Order!"); //notice that slippage also has to be multiplied by 10 } //+------------------------------------------------------------------+ |
|
|||
// 4109 ERR_TRADE_NOT_ALLOWED Trade is not allowed. Enable checkbox "Allow live trading" in the Expert Advisor properties
[/CODE][/QUOTE] Danke, aber wo das bei einem Script ? Ist ja gerade kein EA. |
|
|||
Zitat:
Code:
//+------------------------------------------------------------------+ //| Chton.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int ticket,iSlipPage,iSLPips,iTPPips; double dStopLoss,dTakeProfit,dLots,dAskPrice,dBidPrice,dPoint; string sText; color cArrow; iSLPips=100; //Stop Loss in Pips iTPPips=100; //Take Profit in Pips dLots=0.01; //Amount of Lots iSlipPage=5; sText="My Order"; //Order Text cArrow=clrLime; //Order Arrow Color dAskPrice=NormalizeDouble(MarketInfo("EURUSD",MODE_ASK),5); dBidPrice=MarketInfo("EURUSD",MODE_BID); dPoint =MarketInfo("EURUSD",MODE_POINT); dStopLoss=(dAskPrice-iSLPips*dPoint); dTakeProfit=(dAskPrice+iTPPips*dPoint); ticket=OrderSend("EURUSD",OP_BUY,dLots,dAskPrice,iSlipPage,dStopLoss,dTakeProfit,sText,2345678,0,cArrow); if(ticket<0) { Alert("OrderSend failed with error = #",GetLastError()); Alert("Order-Text = ",sText); Alert("Lot-Size = ",dLots); Alert("Ask-Price = ",DoubleToString(dAskPrice,5)); Alert("Bid-Price = ",dBidPrice); Alert("SL = ",dStopLoss); Alert("TP = ",dTakeProfit); Alert("SlipPage = ",iSlipPage); } else { Alert("OrderSend successful ticket = ",ticket); Alert("Ask-Price = ",DoubleToString(dAskPrice,5)); } } //+------------------------------------------------------------------+ |
|
|||
in bild oder
#property show_inputs Code:
//+------------------------------------------------------------------+ //| Chton.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property show_inputs //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int ticket,iSlipPage,iSLPips,iTPPips; double dStopLoss,dTakeProfit,dLots,dAskPrice,dBidPrice,dPoint; string sText; color cArrow; iSLPips=100; //Stop Loss in Pips iTPPips=100; //Take Profit in Pips dLots=0.01; //Amount of Lots iSlipPage=5; sText="My Order"; //Order Text cArrow=clrLime; //Order Arrow Color dAskPrice=NormalizeDouble(MarketInfo("EURUSD",MODE_ASK),5); dBidPrice=MarketInfo("EURUSD",MODE_BID); dPoint =MarketInfo("EURUSD",MODE_POINT); dStopLoss=(dAskPrice-iSLPips*dPoint); dTakeProfit=(dAskPrice+iTPPips*dPoint); ticket=OrderSend("EURUSD",OP_BUY,dLots,dAskPrice,iSlipPage,dStopLoss,dTakeProfit,sText,2345678,0,cArrow); if(ticket<0) { Alert("OrderSend failed with error = #",GetLastError()); Alert("Order-Text = ",sText); Alert("Lot-Size = ",dLots); Alert("Ask-Price = ",DoubleToString(dAskPrice,5)); Alert("Bid-Price = ",dBidPrice); Alert("SL = ",dStopLoss); Alert("TP = ",dTakeProfit); Alert("SlipPage = ",iSlipPage); } else { Alert("OrderSend successful ticket = ",ticket); Alert("Ask-Price = ",DoubleToString(dAskPrice,5)); } } //+------------------------------------------------------------------+ |
|
|||
Leute, ich beiß gerade Stücke aus der Tischkante !!
in diesem Augenblick kam ein MT4 - Upgrade.
Ich installier' es ... und ab dem Zeitpunkt habe ich unter Optionen die Möglichkeit Live - Trading zu erlauben. Vorher nicht, bitte glaubt es mir !! Jetzt funzt mein Script (auch mit 4 digits), d.h. ich kann damit Positionen öffnen. Sorry für's Nerven und 1000 Dank insbesondere an pako !!!!!! Danke - Danke - Danke ! |
Lesezeichen |
Stichworte |
datei, datei prüfen, ea, expert advisor, mql4, programmierung, programmierung metatrader, verzeichnis |
Themen-Optionen | Thema durchsuchen |
Ansicht | |
|
|