![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
//| 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 года
тогда работал
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
Shorting at bids, not ascas + stops above the entry price and takeaways below.
Was:
Became:
Pros and cons have also changed (although highlighted in bold, but it's not noticeable on the screen).
Good luck
on top of that
mql 5 has been written for you. Object oriented. Inherit Ctrade and you will be happy. Don't reinvent the wheel.
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
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
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
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