|
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 |
|
|||
Code:
TakeProfit = NormalizeDouble(OrderOpenPrice()*(1+(TP_Prozent/100)),1); |
|
|||
TakeProfit = NormalizeDouble(10744,75*(1+(10/100)),1);
TakeProfit = 11819,2 11819,2 ?? traderdoc
__________________
Ich erfülle Euch gern Eure EA-, Indikator- und Script-Programmierungswünsche auf Honorarbasis. |
|
|||
Code:
void OnStart() { //--- double TakeProfit = NormalizeDouble(10744.75*(1+(10/100)),1); Alert(DoubleToString(TakeProfit,3)); Print(DoubleToString(TakeProfit,3)); } //+------------------------------------------------------------------+ |
|
||||
Zitat:
ich kann das jetzt im moment nicht testen, aber ich nehm mal an dass das auch wieder einen fehler Produziert? da es nicht mit 0,25 - 0,5 - 0,75 - 0,00 endet? |
|
|||
falsch 10744,75
|
|
|||
Zitat:
Rounding floating point number to a specified accuracy. |
|
|||
Code:
void OnStart() { //--- double TakeProfit0 = NormalizeDouble(10744.75,1); double TakeProfit1 = MathCeil(10744.75); double TakeProfit2 = MathFloor(10744.75); double TakeProfit3 = MathRound(10744.75); Alert(DoubleToString(TakeProfit0,3)," -:- ",DoubleToString(TakeProfit1,3)," -:- ",DoubleToString(TakeProfit2,3)," -:- ",DoubleToString(TakeProfit3,3)); Print(DoubleToString(TakeProfit0,3)," -:- ",DoubleToString(TakeProfit1,3)," -:- ",DoubleToString(TakeProfit2,3)," -:- ",DoubleToString(TakeProfit3,3)); } //+------------------------------------------------------------------+ |
|
|||
void OnStart()
{ //--- double TakeProfit = NormalizeDouble(10744.75*(1+(10/100)),1); Alert(DoubleToString(TakeProfit,3)); Print(DoubleToString(TakeProfit,3)); } //+------------------------------------------------------------------+ Auch falsch: ergibt dann 10744,8 Er braucht aber .25 oder .5 oder .75 oder .0 und wenn dann double TakeProfit = NormalizeDouble(10744.75*(1+(10.0/100.0)),1); TakeProfit = 11819.2 Das wäre aber auch nicht das, was er braucht! traderdoc
__________________
Ich erfülle Euch gern Eure EA-, Indikator- und Script-Programmierungswünsche auf Honorarbasis. Geändert von traderdoc (26.01.15 um 20:38 Uhr) |
|
|||
Auf die Schnelle mal eine Hilfslösung:
Code:
double TP_Prozent = 10.0; double TakeProfit = NormalizeDouble(OrderOpenPrice()*(1+(TP_Prozent/100.0)),2); int TP = TakeProfit; double Nachkomma = TakeProfit - TP; if (Nachkomma <= 0.12) TakeProfit = TP; if (Nachkomma > 0.12 && Nachkomma <= 0.37) TakeProfit = TP + 0.25; if (Nachkomma > 0.37 && Nachkomma <= 0.62) TakeProfit = TP + 0.5; if (Nachkomma > 0.62 && Nachkomma <= 0.87) TakeProfit = TP + 0.75; if (Nachkomma > 0.87) TakeProfit = TP + 1.0;
__________________
Ich erfülle Euch gern Eure EA-, Indikator- und Script-Programmierungswünsche auf Honorarbasis. |
Lesezeichen |
Stichworte |
digits, digits problem, mql4, nachkomma stellen, nachkomma stellen problem, nachkommastellen, programmierung, programmierung metatrader |
Themen-Optionen | Thema durchsuchen |
Ansicht | |
|
|