Hi,
ich habe es mit allem möglichen probiert und es will einfach nicht laufen.
1. Es passt nicht zu meinem Indikator-Bild (Heiken_Ashi_Smoothed). Ich habe den Indikator in den Tester (als template) eingebaut, aber das was ich sehe und was der EA macht, das sind zwei verschiedene Welten.
2. Es werden nur buy orders ausgelöst.
Hier einmal der gesamt Code
Code:
//+------------------------------------------------------------------+
//| ProjectName |
//| Copyright 2012, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
#property version "1.00"
#property strict
double total,ticket;
double Lots=1.0;
int sl =80;
int tp = 200;
double TrailingStop=150;
double val0,val1;
int HA1_Kerze=0;
int Digits();
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
val0 = iCustom(Symbol(), 0, "Heiken_Ashi_Smoothed", 2,4,2,1,0,1);
val1 = iCustom(Symbol(), 0, "Heiken_Ashi_Smoothed", 2,4,2,1,1,1);
if(val0<val1)
{
HA1_Kerze=1; //blauer HA
} else {
HA1_Kerze=-1; //roter HA
}
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
//| Prüfen der Anzahl der Orders
//+------------------------------------------------------------------+
total=OrdersTotal();
if(total==0)
//| Buy
//+------------------------------------------------------------------+
{
if(HA1_Kerze==1)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-sl*Point,Ask+tp*Point,NULL,0,0,clrGreen);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES));
Print("BUY order opend : ",OrderOpenPrice());
}
else Print("Error opening BUY Order : ",GetLastError());
}
//| Sell
//+------------------------------------------------------------------+
if(total==0)
if(HA1_Kerze==-1)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+sl*Point,Bid-tp*Point,NULL,0,0,clrRed);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES));
Print("Sell order opend : ",OrderOpenPrice());
}
else Print("Error opening Sell Order : ",GetLastError());
}
}
//+------------------------------------------------------------------+
//---Zähler & Close Bedingungen
//+------------------------------------------------------------------+
for(int cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
//Check for Trailling Stop
//+------------------------------------------------------------------+
if(TrailingStop>=0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Green);
return;
}
}
}
}
else // got to short Position
{
//Check for TrailingStop
//+------------------------------------------------------------------+
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if(OrderStopLoss()>(Ask+Point*TrailingStop))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return;
}
}
}
}
//+------------------------------------------------------------------+
} // "else" Close
//+------------------------------------------------------------------+
} //"for" Close
//+------------------------------------------------------------------+
} //"void" Close
//+------------------------------------------------------------------+
Ich bin für jede weitere Unterstützung dankbar!