I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, oneSell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. Yes, and only buy orders are opened HAYDNT ?!
//
EA code
//--- input parametersexterndouble MaxRisk=1.0;
externdouble FixLot = 0.01;
externdouble Exponent=2.0;
externint Magic = 888;
// костылиexternint TakeProfit=100;
externint StopLoss=100;
int init()
return(0);
}
int deinit()
{
//----//----return(0);
}
int start()
{
//----int Count=0;
double b0,b1;
int ticket;
// параметры индикатораint SF = 5; // original 5int RSI_Period = 14; // original 14double DARFACTOR = 4.236; //original 4.236//------------ Параметры из индикатора QQEA -----------------------// Buffer0 -- красная жирнаяstring Buffer0 = iCustom(NULL, 0, "QQEA" , SF, RSI_Period, DARFACTOR,0 , 0);
// Buffer1 -- жёлтый пунктирstring Buffer1 = iCustom(NULL, 0, "QQEA" , SF, RSI_Period, DARFACTOR,1 , 0);
b0=StrToDouble(Buffer0);
b1=StrToDouble(Buffer1);
double Lot=GetLot(MaxRisk);
// если лот <0 выводим сообщение об ошибкеif(Lot==0)
{
Alert("Недостаточно средств!");
return(0);
}
if (Lot!=0 && b0>b1) // если лот <> 0 и красная выше жёлтой
{
ticket=NewOrder(OP_BUY,Lot);
if (ExistOrders(Symbol(), 1, 888, 0) == true ) // проверяем наличие ордера sell
{
CloseOrder();
}
}
if (Lot!=0 && b0<b1) // если лот <> 0 и красная выше жёлтой
{
ticket=NewOrder(OP_SELL,Lot);
if (ExistOrders(Symbol(), 0, 888, 0) == true ) // проверяем наличие ордера buy
{
CloseOrder();
}
}
Comment("Red line: ",b0,"Yellow line: ",b1);
return(0);
}
//-------------------------------------------------------------//расчёт лотаdouble GetLot(int Risk)
{double Free =AccountFreeMargin();
double One_Lot =MarketInfo(Symbol(),MODE_MARGINREQUIRED);
double Min_Lot =MarketInfo(Symbol(),MODE_MINLOT);
double Max_Lot =MarketInfo(Symbol(),MODE_MAXLOT);
double Step =MarketInfo(Symbol(),MODE_LOTSTEP);
double Lot =MathFloor(Free*Risk/100/One_Lot/Step)*Step;
if(Lot<Min_Lot) Lot=Min_Lot;
if(Lot>Max_Lot) Lot=Max_Lot;
if(Lot*One_Lot>Free) return(0.0);
return(Lot);}
bool ExistOrders(string sy="", int op=-1, int Magic=-1, datetime ot=0)
{
int i, k=OrdersTotal(), ty;
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
ty=OrderType();
if (ty>1 && ty<6) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || ty==op)) {
if (Magic<0 || OrderMagicNumber()==Magic) {
if (ot<=OrderOpenTime()) return(True);
}
}
}
}
}
return(False);
}
//открытие нового ордераint NewOrder(int Cmd,double Lot)
{double TP=0; //тейкпрофитdouble SL=0; //стоплоссdouble PR=0; //Ценаwhile(!IsTradeAllowed()) Sleep(100);
if(Cmd==OP_BUY)
{PR=Ask;
if(TakeProfit>0) TP=Ask+TakeProfit*Point;
if(StopLoss>0) SL=Ask-StopLoss*Point;}
if(Cmd==OP_SELL)
{PR=Bid;
if(TakeProfit>0) TP=Bid-TakeProfit*Point;
if(StopLoss>0) SL=Bid+StopLoss*Point;}
int tic=OrderSend(Symbol(),Cmd,Lot,PR,3,SL,TP," ",0,0,Green);
if(tic<0) Print("Ошибка открытия ордера: " ,GetLastError());
return(tic);}
// закрытие ордераvoid CloseOrder()
{double PR=0;
while(!IsTradeAllowed()) Sleep(100);
if(OrderType()==OP_BUY) PR=Bid;
if(OrderType()==OP_SELL) PR=Ask;
if(!OrderClose(OrderTicket(),OrderLots(),PR,3,Red))
Print("Ошибка закрытия ордера: " ,GetLastError());
return;}
I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, one Sell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. Yes, and only buy orders are opened HAYDNT ?!
I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, one Sell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. And only buy orders are opened.
Help with the arrays. It doesn't work the way I want it to.
There is a price array p[]. I need to create a new array, the length of which is one element less, and it is counted as the difference between two adjacent elements from the first array. If the difference is negative, then multiply by -1.
Help with the arrays. It doesn't work the way I want it to.
There is a price array p[]. I need to create a new array, the length of which is one element less, and it is counted as the difference between two adjacent elements from the first array. If the difference is negative, then multiply by -1.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, one Sell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. Yes, and only buy orders are opened HAYDNT ?!
EA code
I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, one Sell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. Yes, and only buy orders are opened HAYDNT ?!
//
EA code
I am writing an EA based on QQEA indicator. So, the idea for the EA is: when the red line crosses the yellow line upwards, one Buy order should open, and when the red line crosses the yellow line downwards, one Sell order should open. But I am not able to open just one order. The orders are opened as long as the condition is fulfilled. And only buy orders are opened.
//
EA code
Let me ask you a question.
On what basis is the string type used?
guys EA uses two different timeframes (30 and 60), tell me what period to put in the tester, and whether the test period in the EA will not change?
What do these log entries mean:
2012.01.31 14:34:45 Memory handler: cannot allocate 10436536 bytes of memory
2012.01.31 14:34:45:45 HistoryBase: not enough memory 'EURGBP1' [206996 bars]
? Is it possible to fix if there is any problem?
Help with the arrays. It doesn't work the way I want it to.
There is a price array p[]. I need to create a new array, the length of which is one element less, and it is counted as the difference between two adjacent elements from the first array. If the difference is negative, then multiply by -1.
there is p [6]={1, 5, 9, 4, 6, 2, 3}
We should get
p_diff[5] = {-1*(1-5), -1*(5-9), 9-4, -1*(4-6), 6-2, -1*(2-3)} i.e. p_diff[5] = {4, 4, 5, 2, 4, 1}
What do these log entries mean:
2012.01.31 14:34:45 Memory handler: cannot allocate 10436536 bytes of memory
2012.01.31 14:34:45:45 HistoryBase: not enough memory 'EURGBP1' [206996 bars]
? Is it possible to fix if there is any problem?
Help with the arrays. It doesn't work the way I want it to.
There is a price array p[]. I need to create a new array, the length of which is one element less, and it is counted as the difference between two adjacent elements from the first array. If the difference is negative, then multiply by -1.
there is p [6]={1, 5, 9, 4, 6, 2, 3}
We should get
p_diff[5] = {-1*(1-5), -1*(5-9), 9-4, -1*(4-6), 6-2, -1*(2-3)} i.e. p_diff[5] = {4, 4, 5, 2, 4, 1}
The function returns the absolute value (modulo value) of the number passed to it