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)
-   -   Prozent des Kontostands als Einsatz (http://www.expert-advisor.com/forum/showthread.php?t=6582)

MA-EA 24.01.20 16:19

Prozent des Kontostands als Einsatz
 
Liste der Anhänge anzeigen (Anzahl: 2)
Hallo.

Ich möchte einen bestimmten %Wert des Kontostands in den Orders einsetzen. Aber wie man in der Text-Datei im Anhang erkennen kann, fängts schon bei der Margin für ein Lot an, unberechenbar zu werden. :confused:
Code:

extern bool Percent_of_Balance=true;
extern double Auto_Lotsize_Perc=0.25;

Code:

double Min_L=MarketInfo(Symbol(),MODE_MINLOT);
double Max_L=MarketInfo(Symbol(),MODE_MAXLOT);

if(Percent_of_Balance==true){

  double M_REQ=MarketInfo(Symbol(),MODE_MARGINREQUIRED); // nötige Margin für 1 Lot (100.000 Units)

//"1 Lot" geteilt durch Mindest-Lot, um später raus zu finden, wie viel Margin für Mindest-Lot gebraucht wird.
//z.B.: 1 Lot / 0.01 L = 100
  double OneL_MinL = 1.0 / Min_L; // ?

//Margin_für_1_Lot geteilt durch Ergebnis, um raus zu finden, wie viel Margin für Mindest_Lot benötigt wird.
//z.B.:  €1000,00 / 100 = €10,00
  double MREQ_MinL = M_REQ / OneL_MinL;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

//1% von Kontostand ausrechnen
//z.B.: €1000,00 / 100% = €10,00
  double OPAB = AccountBalance() / 100.0;

//1% des Kontostands * Prozent, für die Lots gekauft werden sollen
//z.B.: €10,00 * 2,5% = €25,00
  double OPAB_ALP = OPAB * Auto_Lotsize_Perc; // ?

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

//Betrag, für den Lots gekauft werden sollen / Margin für Mindest-Lot
//z.B.: €25,00 / €10,00 = 2,5
  double OPABALP_MREQMinL = OPAB_ALP / MREQ_MinL;

//Ergebnis * Mindest-Lot
//z.B.: 2,5 * 0.01L = 0.025L (aufgerundet 0.03L)
  Lots = OPABALP_MREQMinL * Min_L; //  ?

}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////

if(Lots<Min_L)Lots=Min_L;
if(Lots>Max_L)Lots=Max_L;



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