Danke für deine Antwort, könntest du nochmal einen Blick drüber werfen habe es jetzt mal aufgerufen.
HTML-Code:
//+------------------------------------------------------------------+
//| breakOut_TRF_v4.0.0.mq4 |
//| Copyright 2021, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern int hidden_sl = 10;
extern int hidden_tp = 20;
int magicNumber = 123456;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//
CheckForSignal();
//
stealthControl();
}
//+------------------------------------------------------------------+
//| Function "CheckForSignal()" |
//+------------------------------------------------------------------+
void CheckForSignal(){
static datetime candletime=0;
if(candletime!=Time[0]){
double upArrow=iCustom(Symbol(),PERIOD_CURRENT,"breakOut_TRF_v4.0.0",0,1);
if(upArrow != EMPTY_VALUE){
buyEnterTrade(OP_BUY,1.0,Ask,100,0,0);
}
double downArrow=iCustom(Symbol(),PERIOD_CURRENT,"breakOut_TRF_v4.0.0",1,1);
if(downArrow != EMPTY_VALUE){
sellEnterTrade(OP_SELL,1.0,Bid,100,0,0);
}
candletime=Time[0];
}
}
//+------------------------------------------------------------------+
//| buyEnterTrade function |
//+------------------------------------------------------------------+
void buyEnterTrade(int type,double volumen,double price,int slippage,double stoploss,double takeprofit){
int longTicket=OrderSend(Symbol(),type,volumen,price,slippage,stoploss,takeprofit,"Funktion: buyEnterTrade",magicNumber,0,clrGreen);
}
//+------------------------------------------------------------------+
//| sellEnterTrade function |
//+------------------------------------------------------------------+
void sellEnterTrade(int type,double volumen,double price, int slippage,double stoploss, double takeprofit){
int shortTicket=OrderSend(Symbol(),type,volumen,price,slippage,stoploss,takeprofit,"Funktion: sellEnterTrade",magicNumber,0,clrRed);
}
//+------------------------------------------------------------------+
//| stopLoss function |
//+------------------------------------------------------------------+
void stealthControl(){
double myPoint=Point();
if(Digits()==5 || Digits()==3){
myPoint *=10;
}
int totalorders = OrdersTotal();
for(int i=totalorders-1;i>=0;i--){
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderSymbol()==Symbol()){
//profitTargeting
if (OrderType() == OP_BUY && OrderOpenPrice()+hidden_tp*myPoint<=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID),10, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()-hidden_tp*myPoint>=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 10, Red );
//looseTargeting
if (OrderType() == OP_BUY && OrderOpenPrice()-hidden_sl*myPoint>=Bid ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 10, Red );
if (OrderType() == OP_SELL && OrderOpenPrice()+hidden_sl*myPoint<=Ask ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 10, Red );
}
}
return;
}
//+------------------------------------------------------------------+