Einzelnen Beitrag anzeigen
  #16 (permalink)  
Alt 25.08.14
dieter23 dieter23 ist offline
Mitglied
 
Registriert seit: Sep 2013
Beiträge: 31
dieter23 befindet sich auf einem aufstrebenden Ast
Standard

klappt leider nicht.
Hier mal die koml. int start() Funktion.


double TSTP = TrailingStop * PointValue;
PointValue = MarketInfo(OrderSymbol(), MODE_POINT);

//-------------------------------------------------------------------+
int init()
{
if(Digits == 3 || Digits == 5)

{
string BrokerType = "5-Digit Broker";
BrokerMultiplier = 10;
}
}
//

int start()
{


Comment("Copyright © 2014 *** Robot_Dax ***"+"\n"+
"TimeStart " , TimeStart, "\n",
"TimeEnd " , TimeEnd, "\n",
"MaxPrice ", Max_Price, "\n",
"MinPrice " , Min_Price, "\n",
"Akt.Preis ", Ask, "\n");


if (MoneyManagement)
{
if (Risk<1 || Risk>100)
{
Comment("Invalid Risk Value.");
return(0);
}
else
{
Lots=MathFloor((AccountFreeMargin()*AccountLeverag e()*Risk*Point*BrokerMultiplier*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo( Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_M INLOT);
}
}
datetime Time_Start = StrToTime(StringConcatenate(Day(),".",Month(),".", Year()," ",TimeStart, ":00"));
datetime Time_End = StrToTime(StringConcatenate(Day(),".",Month(),".", Year()," ",TimeEnd, ":00"));
datetime Time_CloseOrder = StrToTime(StringConcatenate(Day(),".",Month(),".", Year()," ",TimeCloseOrder,":00"));

if (Time_CloseOrder>Time_End) if (CurTime()>=Time_CloseOrder) CLOSEORDERS();

int tip;
if (Orders>OrdersTotal()) tip=CloseOrder();
Orders=OrdersTotal();

if (ORDERS(0)==0 && tip==0 && (CurTime()<Time_CloseOrder || Time_CloseOrder<=Time_End) && TradeDay!=TimeDay(CurTime()))
{
int BarStart = iBarShift(NULL,0,Time_Start,false);
int BarEnd = iBarShift(NULL,0,Time_End ,false);
Max_Price=iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH,B arStart-BarEnd,BarEnd));
Min_Price=iLow (NULL,0,iLowest (NULL,0,MODE_LOW, BarStart-BarEnd,BarEnd));

if (TimeCurrent()>Time_End && ObjectFind("bar0"+Time_End)==-1)
{
ObjectCreate("bar0"+Time_End, OBJ_RECTANGLE, 0, 0,0, 0,0);
ObjectSet ("bar0"+Time_End, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet ("bar0"+Time_End, OBJPROP_COLOR, Blue);
ObjectSet ("bar0"+Time_End, OBJPROP_BACK, true);
ObjectSet ("bar0"+Time_End, OBJPROP_TIME1 ,Time_Start);
ObjectSet ("bar0"+Time_End, OBJPROP_PRICE1,Max_Price);
ObjectSet ("bar0"+Time_End, OBJPROP_TIME2 ,Time_End);
ObjectSet ("bar0"+Time_End, OBJPROP_PRICE2,Min_Price);
}


if(Bid > Max_Price && order == 0)
{
OrderSend(Symbol(), OP_BUY, Lots, Ask,Slippage, Ask-SL,Ask+TP, "br", Magic, 0, Green);
order=order+1;
}

if(Ask < Min_Price && order == 0)
{
OrderSend(Symbol(), OP_SELL, Lots, Bid,Slippage, Bid+SL,Bid-TP, "br", Magic, 0, Green);
order=order+1;

}
if (order > 0)
{
trailing();
}
return(0);

}



if (No_Loss) No_Loss();
if (tip==1 && TradeDay!=TimeDay(CurTime()))
{
Lots=Lots*K_martin;

if (tipOrders==0) OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP ,NULL,Magic,Blue);
if (tipOrders==1) OrderSend(Symbol(),OP_BUY ,Lots,Ask,Slippage,SL,TP,NULL,Magic,Blue);
}
return(0);
}

//+-----------------------------------------------------------------+
int trailing()
{
for (int i = 0; i < OrdersTotal(); i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (OrderType() == OP_BUY)
{ if ((Bid - OrderOpenPrice()) > TSTP)
{ if (OrderStopLoss() < (Bid - TSTP))
{
OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TSTP, OrderTakeProfit(), Red);
}}}}

if (OrderType() == OP_SELL)
{ if ((OrderOpenPrice() - Ask) > TrailingStop * PointValue)
{ if ((OrderStopLoss() > (Ask + TrailingStop * PointValue)) || (OrderStopLoss() == 0))
{
OrderModify(OrderTicket(), OrderOpenPrice(), Ask + TSTP, OrderTakeProfit(), Red);
}}}
return;

}