Metatrader 4 invalid SL TP

Valerius

New member
06. März 2016
6
0
0
Hallo.

Ich versuche schon ewig, StopLoss (bzw. Trailing Stop) und TakeProfit in einem EA für den Metatrader 4 auf die Reihe zu bekommen.

Aber egal was ich rein schreibe oder versuche, im Demo des MT4 heißt es immer nur "SL invalid". Broker ist ActivTrades. Er öffnet und schließt zwar Trades wie er soll, aber bei S/L und T/P stehen immer nur Nullen mit nem Punkt irgendwo dazwischen.

Im Anhang die .mq4. Ich kopier das Wichtigste einfach mal hier rein.

Die Werte, die man dazu im MT4 einstellen können soll:

extern int Stoploss=150;
extern string TS1="true=Yes";
extern string TS2="false=No";
extern bool Trailing_Stop=true;
extern int Trailing_Stop_Step=25;
extern int Takeprofit=500;




Die Berechnungen und Bedingungen und so:

int SL_x10=Stoploss*10;
int TSS_x10=Trailing_Stop_Step*10;
int TP_x10=Takeprofit*10;
//-------------------------------------------------------------------------------------------------------------

//Digits SL TP
int DIGI=MarketInfo(Symbol(),(MODE_DIGITS));
if(DIGI==3||DIGI==5){
Stoploss=SL_x10;
Takeprofit=TP_x10;
if(Trailing_Stop==true){
Trailing_Stop_Step=TSS_x10;}}
//-------------------------------------------------------------------------------------------------------------

//SL / TP / TS
double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);

double buy_OOP=NormalizeDouble(MarketInfo(Symbol(),MODE_ASK),_Digits);//"BUY Order Open Price"
if(Stoploss>0)double buy_SL=NormalizeDouble((buy_OOP-Stoploss)*_Point,_Digits);
if(Trailing_Stop_Step>0)double buy_TS_TSS=NormalizeDouble((buy_OOP-Stoploss-Trailing_Stop_Step)*_Point,_Digits);
if(Takeprofit>0)double buy_TP=NormalizeDouble((buy_OOP+Takeprofit)*_Point,_Digits);

double sell_OOP=NormalizeDouble(MarketInfo(Symbol(),MODE_BID),_Digits);//"SELL Order Open Price"
if(Stoploss>0)double sell_SL=NormalizeDouble((sell_OOP+Stoploss)*_Point,_Digits);
if(Trailing_Stop_Step>0)double sell_TS_TSS=NormalizeDouble((sell_OOP+Stoploss+Trailing_Stop_Step)*_Point,_Digits);
if(Takeprofit>0)double sell_TP=NormalizeDouble((sell_OOP-Takeprofit)*_Point,_Digits);
//-------------------------------------------------------------------------------------------------------------

//Trailing Stop
if(Trailing_Stop==true){
if(buy_SL<buy_TS_TSS)buy_SL=buy_TS_TSS;{
if(sell_SL>sell_TS_TSS)sell_SL=sell_TS_TSS;}}


Hab keine Ahnung, warum das nicht funktioniert.

Anhang anzeigen Valerius_SL_TS_TP_ADX_MACD_MT4_EA.mq4