KARAUL!!! HELP. 4 hours and 45 minutes to go!!! - page 4

 
//+------------------------------------------------------------------+
//| Cempionat2010.mq5 |
//| Victor Pavlyuk |
//| |
//+------------------------------------------------------------------+
#property copyright "Victor Pavljuk"
#property version "1.00"

input int StartHour = 10;
input int EndHour = 20;
input double Lots = 5;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnInit()
{

}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
MqlTradeRequest request;
MqlTradeResult result;
MqlDateTime dt;
bool bord=false, sord=false;
bool bords=false, sords=false;
int i;
ulong ticket;
datetime t[];
double h[], l[], ma[], atr_h[], atr_l[],
lev_h, lev_l,
Spread =NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK) - SymbolInfoDouble(Symbol(),SYMBOL_BID),_Digits);
request.symbol =Symbol();
request.volume =Lots;
request.tp =0;
request.deviation =0;
request.type_filling=ORDER_FILLING_RETURN;

TimeCurrent(dt);
i=(dt.hour+1)*60;
if(CopyTime(Symbol(),0,0,i,t)<i || CopyHigh(Symbol(),0,0,i,h)<i || CopyLow(Symbol(),0,0,i,l)<i)
{
Print("Не удалось скопировать таймсерию!");
return;
}
ArraySetAsSeries(t,true);
ArraySetAsSeries(h,true);
ArraySetAsSeries(l,true);
lev_h=h[0];
lev_l=l[0];
for(i=1;i<ArraySize(t) && MathFloor(t[i]/86400)==MathFloor(t[0]/86400);i++)
{
if(h[i]>lev_h) lev_h=h[i];
if(l[i]<lev_l) lev_l=l[i];
}
lev_h+=Spread+_Point;
lev_l-=_Point;



for(i=0;i<OrdersTotal();i++)
{
ticket=OrderGetTicket(i);
if(OrderGetString(ORDER_SYMBOL)==Symbol())
{

if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_BUY_STOP)
{
if(dt.hour>=StartHour && dt.hour<EndHour )
{
Print("Есть ордер byu2!");
return;
}
else
{
request.action=TRADE_ACTION_REMOVE;
request.order=ticket;
OrderSend(request,result);
return;
}
bords=true;
}
if(OrderGetInteger(ORDER_TYPE)==ORDER_TYPE_SELL_STOP)
{
if(dt.hour>=StartHour && dt.hour<EndHour )
{
Print("Есть ордер Sel2");
return;
}
else
{
request.action=TRADE_ACTION_REMOVE;
request.order=ticket;
OrderSend(request,result);
return;
}
sords=true;
}
}
}

request.action=TRADE_ACTION_PENDING;
if(dt.hour>=StartHour && dt.hour<EndHour)
{
if(bords==false )
{
request.price=NormalizeDouble(lev_h,_Digits);
request.sl=NormalizeDouble(lev_h-1000*_Point,_Digits);
request.tp=NormalizeDouble(lev_h+138*_Point,_Digits);
request.type=ORDER_TYPE_BUY_STOP;
OrderSend(request,result);
}
if(sords==false )
{
request.price=NormalizeDouble(lev_l,_Digits);
request.sl=NormalizeDouble(lev_l+1000*_Point,_Digits);
request.tp=NormalizeDouble(lev_l-138*_Point,_Digits);
request.type=ORDER_TYPE_SELL_STOP;
OrderSend(request,result);
}
}
}
//+------------------------------------------------------------------+

не проходит тест даже советник 2010 года

тогда работал 




 
fyords:

Here you have the reason written down:

So what does it say? And then with that to the reference.

10013

TRADE_RETCODE_INVALID

Incorrect request

ERR_TRADE_SEND_FAILED

4756

Failed to send trade request

 
int OpenShort(double volume=5,
 int slippage=10000,
 string comment="",
 int magic=888)
 {
 MqlTradeRequest my_trade;
 MqlTradeResult my_trade_result;

 my_trade.action=TRADE_ACTION_DEAL;
 my_trade.symbol=Symbol();
 my_trade.volume=NormalizeDouble(volume,1);
 my_trade.price=NormalizeDouble(Bid,_Digits);
 my_trade.sl=NormalizeDouble(Bid + StopLoss*_Point,_Digits);
 my_trade.tp=NormalizeDouble(Bid -  TakeProfit*_Point,_Digits);
 my_trade.deviation=slippage;
 my_trade.type=ORDER_TYPE_SELL;
 my_trade.type_filling=ORDER_FILLING_RETURN;
 my_trade.comment=comment;
 my_trade.magic=magic;

 ResetLastError();

 if(OrderSend(my_trade,my_trade_result))
 {
 Print("Код результата операции - ",my_trade_result.retcode);
 }
 else
 {
 Print("Код результата операции - ",my_trade_result.retcode);
 Print("Ошибка открытия ордера = ",GetLastError());
 }
 return(0);
 }

Shorting at bids, not ascas + stops above the entry price and takeaways below.

Was:

my_trade.sl=NormalizeDouble(Ask-StopLoss*_Point,_Digits);
my_trade.tp=NormalizeDouble(Ask+TakeProfit*_Point,_Digits);

Became:

my_trade.sl=NormalizeDouble(Bid+StopLoss*_Point,_Digits);
my_trade.tp=NormalizeDouble(Bid- TakeProfit*_Point,_Digits);

Pros and cons have also changed (although highlighted in bold, but it's not noticeable on the screen).

Good luck

 

on top of that

MqlTradeRequest my_trade={0};
MqlTradeResult my_trade_result={0};
 

mql 5 has been written for you. Object oriented. Inherit Ctrade and you will be happy. Don't reinvent the wheel.

 
IceBerg:

mql 5 has been written for you. Object oriented. Inherit Ctrade and you will be happy. Don't reinvent the wheel.

Stupid advice two hours before the end - it's harder to figure out the standard library than it is to figure out OrderSend.

Already the bug has been fixed. All that's left to send (if there are no other errors) is

 
IceBerg:

mql 5 has been written for you. Object oriented. Inherit Ctrade and you will be happy. Don't reinvent the wheel.

It's boring to write without mistakes :)

You have to step on it a couple of times and then pick it up.

 

Thank you all for your help.

How do I get rid of

2012.09.21 22:42:08 Core 1 2012.05.08 13:00:00 not enough money [instant buy 5.00 EURUSD at 1.30227 sl: 1.29227 tp: 1.30765]

not pulling out the test for the year

 
pavivas:

Thank you all for your help.

Also, how do you remove

2012.09.21 22:42:08 Core 1 2012.05.08 13:00:00 not enough money [instant buy 5.00 EURUSD at 1.30227 sl: 1.29227 tp: 1.30765]

it does not supersede the test for the year

Reduce lot size below 5.00.
 
fyords:

It's boring to write without mistakes right away :)

You have to step on a rake or two and then pick it up.

That's how you learn from mistakes

Reason: