[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 73

 

Hello. How do I raise it to a degree in MQL4?

 
Diver-si >> :
Hello. This is a big forum and I'm a total nerd at programming. Is it possible to write an EA or point me in the direction of one. Buy entry on crossing stocha 30, on given TF, if on a higher TF stocha rises and > 30, but < 70. On the sell - crossing 70, if on the higher TF stochastics is falling and > 30, but < 70. Exit at take or stop with an option to change values.

It is done. I have done everything that I was asked to do.

Files:
ctoh_1.rar  6 kb
 
Skydiver >> :

Done. I think I've done everything you asked for.

>>Thank you very much!!!!

 
Diver-si >> :

Thank you so much!!!!

Have you worked with this strategy before? Have you been successful?

 
Skydiver >> :

Have you worked with this strategy before? >> Have you been successful?

It's not a strategy, just need to test one assumption. By the way, why is the EA not making trades? I don't understand why.

 
В ветке "Корректное открытие нескольких позиций" приведён следующий код:


 if(iSAR(NULL,0,step0,0.1,0)<Close[0] )
         
         
        {
          RefreshRates();
      ticket = (OrderSend( Symbol(), OP_BUY,GetSizeLot(), Ask, slippage,
       Bid-StopLoss*Point,Ask+TakeProfit*Point,NameExpert,
               0, Green ) );
if(ticket<1) {Print("Ошибка открытия 1-го ордера BUY #",GetLastError());return (0); }  
if (ticket>0) //Sleep(10000);
          { //если 1-я позиция открылась, открываем вторую
          RefreshRates();       
         ticket_1 = (OrderSend( Symbol(), OP_BUY,GetSizeLot(), Ask, slippage,
       Bid-StopLoss*Point,Ask+TakeProfit*Point,NameExpert,
              0, Green ) ); 
if(ticket_1<1) {Print("Ошибка открытия 2 ордера BUY #",GetLastError());return (0); }    
if (ticket_1>0) // Sleep(10000);
         { // если вторая позиция открылась, открываем третью 
          RefreshRates();
      ticket_2 = (OrderSend( Symbol(), OP_BUY,GetSizeLot(), Ask, slippage,
       Bid-StopLoss*Point,Ask+TakeProfit*Point,NameExpert,
              0, Green ) );
           if(ticket_2<1)
          {Print("Ошибка открытия 3 ордера BUY #",GetLastError());return (0); }   
         } 
       }    
     }

            
      if(iSAR(NULL,0,step0,0.1,0)>Close[0])
    {
        
        //---- открываем СЕЛЛ позицию
      RefreshRates();
      ticket = (OrderSend( Symbol(), OP_SELL,GetSizeLot(), Bid, slippage,
        Ask+StopLoss*Point,Bid-TakeProfit*Point, NameExpert,
              0, Red ));
              
           if(ticket<1) {Print("Ошибка открытия 1-го ордера SELL #",GetLastError());return (0); }  
if (ticket>0) //Sleep(10000);
          { //если 1-я позиция открылась, открываем вторую
       RefreshRates();      
      ticket_1 = (OrderSend( Symbol(), OP_SELL,GetSizeLot(), Bid, slippage,
        Ask+StopLoss*Point,Bid-TakeProfit*Point, NameExpert,
             0, Red ));
             
          if(ticket_1<1) {Print("Ошибка открытия 2 ордера SELL #",GetLastError());return (0); }    
if (ticket_1>0) // Sleep(10000);
         { // если вторая позиция открылась, открываем третью        
      RefreshRates(); 
      ticket_2 = (OrderSend( Symbol(), OP_SELL,GetSizeLot(), Bid, slippage,
        Ask+StopLoss*Point,Bid-TakeProfit*Point, NameExpert,
              0, Red ));               
                if(ticket_2<1)
          {Print("Ошибка открытия 3 ордера SELL #",GetLastError());return (0); }   
         } 
       }    
     }
   
    return(0);
    
}



Can you please tell me how to insert a condition in this construction if(iSAR(NULL,0,step0,0.1,0)<Close[0]), which means that if, for example, buy positions are open, then sell positions are not opened until all buy positions are closed. In other words, a cycle of trading, we buy 3 positions, wait until all three are closed. Positions are closed only by Stop Loss or Take Profit. All positions are closed, wait for the signal, get a signal, buy or sell (depending on the signal) 3 positions, etc. The "Useful functions from KimIV" have been studied. You can use functions CountOrders(), ExistOrders(), ExistPositions(). But how do I practically insert them? The construct if((iSAR(NULL,0,step0,0.1,0)>Close[0])&& ExistPositions(NULL,OP_SELL)==false) does not work. I understand that I need to insert a logical variable but how do I do this in practice? I don't understand something.

 
anat >> :



Could you please tell me how to insert a condition in this code if(iSAR(NULL,0,step0,0.1,0)<Close[0]), in which, for example, if we have opened Buy positions, we don't open Sell positions until all Buy positions are closed. In other words, a cycle of trading, we buy 3 positions, wait until all three are closed. Positions are closed only by Stop Loss or Take Profit. All positions are closed, wait for the signal, get a signal, buy or sell (depending on the signal) 3 positions, etc. The "Useful functions from KimIV" have been studied. You can use functions CountOrders(), ExistOrders(), ExistPositions(). But how do I practically insert them? The construct if((iSAR(NULL,0,step0,0.1,0)>Close[0])&& ExistPositions(NULL,OP_SELL)==false) does not work. I understand that I need to insert a logical variable but how do I do this in practice? I don't understand something.


You can open them, but then automatically overlap them on the opposite side. And it is much easier to do it with a separate EA than to add some additional code into a ready-made EA. Corrector.mq4



 
(NULL,PERIOD_M1, 14, 0, 1, PRICE_CLOSE, 1, 1 ) < Ask) { // if price is above the line then sell <--------- is this correct?



(NULL,PERIOD_M1, 14, 0, 1, PRICE_CLOSE, 2, 1 ) > Bid) { // if price is below the line then buy <----- is the logic correct or am I confusing something?



Help plz...

 
1Rakso писал(а) >>
(NULL,PERIOD_M1, 14, 0, 1, PRICE_CLOSE, 1, 1 )

What is this design anyway?

Reason: