Questions from Beginners MQL4 MT4 MetaTrader 4 - page 25

 
Viachaslau Baiko:

possible loss of data due to type conversion

Try it.

Files:
 
Renat Akhtyamov:
Show me the line from the code to which the compiler points

There are a lot of lines like that, which is why I asked for an adapted module for the new terminals. But thanks for your willingness to help)

 
Alekseu Fedotov:
Thanks, I'll give it a try!
 
Viachaslau Baiko:

There are a lot of lines like that, which is why I asked for an adapted module for the new terminals. But thanks for your willingness to help)

Right on this line :

" possible loss of data due to type conversion"

should be the line number and position in the code line with the error.

That's how easy, you can fix all errors, knowing the exact location in the code

 
Renat Akhtyamov:

right on this line :

" possible loss of data due to type conversion"

there should be a line number and a position in the code line with the error.

That is an easy way to fix all the errors, knowing the exact location in the code.

I have taken the Expert Advisor offeredby Alekseu Fedotov and tried to modify it to suit my needs.

My needs are the following: At a crossover of the wands, we open a position, and close it at the opposite crossover. If possible, we transfer the position to Breakeven.

But in the end nothing is opened. I am racking my brains. What may be the problem?

Files:
4Tester.mq4  20 kb
 
Viachaslau Baiko:

I took the EA offeredby Alekseu Fedotov and tried to modify it to suit my needs.

My needs are the following: If they are crossed, we open a position. If they are crossed again, we close it. If possible, we transfer the position to Breakeven.

But in the end nothing is opened. I am racking my brains. What may be the problem?

I'm not sure what the problem is, but I'd like to see a line of code with an error from CMM, for the last time.
 
Renat Akhtyamov:
show the line from the code with the error from CMM, for the last time I offer to help.
There was an error on my part. I made the logic of the program wrong. And it was easier for me to redo it. There is no error in CMM's code.
 
Please advise if it is possible to do the following with mql4 or mql5:

after the price crosses a vertical level, to colour part of the background another colour, as indicated in the picture.

Thank you.
Files:
Immagine1.JPG  100 kb
 
Renat Akhtyamov:
show a code snippet on how you read the signal from the indicator in your EA
extern int     stoploss             = 200,
               takeprofit           = 400,
               slippage             = 10,
               Magic                = 777;          

extern double  Lot                  = 0.5,
               buy_level            = 15;      
            

void OnTick()
{
   for (int i=0; i<OrdersTotal(); i++)                        
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
   if (OrderSymbol()==Symbol() && Magic==OrderMagicNumber())return;
  
   double STO = iStochastic(NULL,15,2,3,1,MODE_SMA,0,MODE_SIGNAL,0);
   double SL=0,TP=0;
  
   if (STO > buy_level)
  
  
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits);
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*  Point,Digits);    
      if (OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError());
      PlaySound("timeout.wav");
      Print("Ордер успешно размещен");
}
}
 
TimBerg:
extern int     stoploss             = 200,
               takeprofit           = 400,
               slippage             = 10,
               Magic                = 777;          

extern double  Lot                  = 0.5,
               buy_level            = 15;      
            

void OnTick()
{
   for (int i=0; i<OrdersTotal(); i++)                        
   if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
   if (OrderSymbol()==Symbol() && Magic==OrderMagicNumber())return;
  
   double STO = iStochastic(NULL,15,2,3,1,MODE_SMA,0,MODE_SIGNAL,0);
   double SL=0,TP=0;
  
   if (STO > buy_level)
  
  
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits);
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*  Point,Digits);    
      if (OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError());
      PlaySound("timeout.wav");
      Print("Ордер успешно размещен");
}
}

Right here:

iStochastic(NULL,15,2,3,1,MODE_SMA,0,MODE_SIGNAL,0);

change period (timeframe) to 1,5,15,30,60,240,1440,10080,43200 //M1.M5.M30 ... etc.

or enter Period() instead of 15, then when you switch TF manually, the current one will be automatically set