[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 171

 

Hi all, I wrote an EA! In the tester, everything works, but in the real account, it refuses to open positions! Note that he closes manually opened positions very well, but, precisely to open, does not want to ... What to do?


CODE:


//+------------------------------------------------------------------+
//| DOKTRADE.mq4 |
//| DOKSTER@YANDEX.RU |
//| DOKSTER@YANDEX.RU |
//+------------------------------------------------------------------+
#property copyright "DOKSTER@YANDEX.RU"
#property link "DOKSTER@YANDEX.RU"

extern double LOT = 0.01; // LOTS
extern double KOF = 2;
extern double SAF = 5;
extern int FRC = 21;

int start()

{


int CNT;

int TOTAL;
int SPREAD;

double SPR;
double SPRW;

double FRCU;
double FRCU; double FRCD;

double EMAH;
double EMAM;;
double EMAL; double EMAL;

double OPEN;
double CLOSE;

double DFB;
double DFS;

EMAH = iMA(NULL,0,34,8,MODE_SMA,PRICE_HIGH,1);
EMAM = iMA(NULL,0,34,8,MODE_SMA,PRICE_MEDIAN,1);
EMAL = iMA(NULL,0,34,8,MODE_SMA,PRICE_LOW,1);

OPEN = iOpen(NULL,0,1);
CLOSE = iClose(NULL,0,1);

FRCU = High[iHighest(NULL,0,MODE_HIGH,FRC,1)];
FRCD = Low[iLowest(NULL,0,MODE_LOW,FRC,1)];

DFB = (CLOSE-FRCD);
DFS = (FRCU-CLOSE);

SPR = MarketInfo(Symbol(),MODE_SPREAD);
SPRW = (SPR*Point);

TOTAL = OrdersTotal();

if(TOTAL<1)

{

{ if (OPEN<EMAH&&CLOSE>EMAH)

OrderSend(Symbol(),OP_BUY,LOT,Ask,3,FRCD-(SAF*Point),CLOSE+(DFB*KOF), "DOKTRADE",15775,0,Green);


if (OPEN>EMAL&&CLOSE<EMAL)

OrderSend(Symbol(),OP_SELL,LOT,Bid,3,FRCU+((SAF*Point)+SPRW),CLOSE-(DFS*KOF), "DOKTRADE",15885,0,Red);

return(0);

}
}

for(CNT=0;CNT<TOTAL;CNT++)

{

OrderSelect(CNT,SELECT_BY_POS,MODE_TRADES);

{

if (OrderType()==OP_BUY && OrderSymbol()==Symbol())

{

if (OPEN>EMAL&&CLOSE<EMAL)

OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);

return(0);

}

if (OrderType()==OP_SELL && OrderSymbol()==Symbol())

{

if (OPEN<EMAH&&CLOSE>EMAH)

OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);

return(0);

}

}

}

}
 

Good afternoon!

Guys, please help me figure out where I'm going wrong. I have Aroon Up&Dn indicator.

I am trying to put it into my Expert Advisor... It does not want to open orders:

extern int     _Aroon_Period = 14;
extern int     _TimeF = 60;
extern int     _Point = 10;
extern double  _lots=0.01;
extern int     _Prof = 150;
int start()
  {
//----
   double _Up1, _Up2, _Dn1, _Dn2;
   if (Volume[0]>1) return;
   if (_Point<MarketInfo(Symbol(),MODE_STOPLEVEL)) _Point=MarketInfo(Symbol(),MODE_STOPLEVEL);
   _Up1=iCustom(NULL,_TimeF,"Aroon_Up_Down",_Aroon_Period,1,1); // пробовал 0 и AroonUpBuffer
   _Up2=iCustom(NULL,_TimeF,"Aroon_Up_Down",_Aroon_Period,1,2);
   _Dn1=iCustom(NULL,_TimeF,"Aroon_Up_Down",_Aroon_Period,2,1);
   _Dn2=iCustom(NULL,_TimeF,"Aroon_Up_Down",_Aroon_Period,2,2);  // пробовал 1 и AroonDnBuffer

   if (_Up1>_Dn1  && _Up2<_Dn2) 
   
   {      
       _OrderDelete(OP_SELLSTOP);
      _price=NormalizeDouble((High[1]+_Point*Point),MarketInfo(Symbol(),MODE_DIGITS));
      _OrderModify(OP_SELL);
      OrderSend(Symbol(),OP_BUYSTOP,_lots,_price,5,0,_price+_Prof*Point,0,0,0,Green);
   }
   if ( _Up1<_Dn1  && _Up2>_Dn2 ) 
   
   {     
      _OrderDelete(OP_BUYSTOP);
      _price=NormalizeDouble((Low[1]-_Point*Point),MarketInfo(Symbol(),MODE_DIGITS));
      _OrderModify(OP_BUY);
      OrderSend(Symbol(),OP_SELLSTOP,_lots,_price,5,0,_price-_Prof*Point,0,0,0,Red);
   }

//---- OrderSendError
   return(0);
  }
Files:
 
7sintez:

Hi all, I wrote an EA! In the tester, everything works, but in the real account, it refuses to open positions! Note that he closes manually opened positions very well, but, precisely to open, does not want to ... What do I do?


First of all, look at errors in log... For price parameters when sending order NormalizeDouble is highly recommended.

 
splxgf:

To start with, look at the errors in the logbook... For price parameters when sending an order NormalizeDouble is highly recommended.

Thanks for the tip, but if you can be more specific... I can't see anything in my journal, except synchronization! Please advise, may be something to add somewhere? Yes, and closes normally... Ie at the closing everything works...!
 
And another question - can the operation of any other script affect the operation of this EA?
 
Finished with NormalizeDouble... No reaction! What should I change in the settings?
 
splxgf:

You can go to https://docs.mql4.com/ru/array/ArrayMaximum

on an array of High.

If you can be more specific, I couldn't figure it out. I need to find the highest value between High[i] and High[1]. Thank you!
 
93408:

Good afternoon!

Guys, please help me figure out where I'm going wrong. I have Aroon Up&Dn indicator.

I am trying to put it into my Expert Advisor... It does not want to open orders:


I think because of this

if (Volume[0]>1) return;

 
7sintez:
Thanks for the tip, but if you can be more specific... Because the log doesn't show anything apart from the synchronisation! Please advise, may be something to add somewhere? Yes, and closes normally... I.e. on closing everything works...!

Actually, it's nonsense to ask such questions to an expert writer :) So, you are not mature enough to be a beginner. If you want to check check positions and limit values for closeness to the open price, you'll probably learn a thing or two about Chinese grammar.
 
Roger:


I think that's why.

if (Volume[0]>1) return;

No, that's not it.

Thank you all, I've got it. It worked