Download MetaTrader 5

Requests & Ideas (MQL5 only!) - page 4

To add comments, please log in or register
ITM7
56
ITM7  
Vladimir Karputov:

About the "Pending distance" I understood. It turns out that a pending order is a top-up (increase) of a position?


Yes, it's a top up, and I am glad you did this: (InpPriceLevel     = 0;           // (in pips) <0 -> Stop orders, =0 -> Market, >0 -> Limit orders)

Everything looks fine so far, I will backtest and follow the chart to see if its trading accordingly, 

kxj999
10
kxj999  

Hello friends,

I am looking for EA that moves SL to break even at a set target price while also closing 1/3 of my position at that price (so it does 2 things at once) and then close another 1/3 at a different target price keeping the same SL in place.  Does anyone know of an EA for work for MT5? thank you

Vladimir Karputov
Moderator
52594
Vladimir Karputov  
kxj999:

Hello friends,

I am looking for EA that moves SL to break even at a set target price while also closing 1/3 of my position at that price (so it does 2 things at once) and then close another 1/3 at a different target price keeping the same SL in place.  Does anyone know of an EA for work for MT5? thank you


Apply search in the website (the window of search is on the right above) in such phrases: "moves SL" and "break even".


kxj999
10
kxj999  
Vladimir Karputov:

Apply search in the website (the window of search is on the right above) in such phrases: "moves SL" and "break even".



I already search this and what I found those that are similar are for mt4 only and none for mt5.  That is why I am posting here for any help appreciated
Vladimir Karputov
Moderator
52594
Vladimir Karputov  
ITM7:


Yes, it's a top up, and I am glad you did this: (InpPriceLevel     = 0;           // (in pips) <0 -> Stop orders, =0 -> Market, >0 -> Limit orders)

Everything looks fine so far, I will backtest and follow the chart to see if its trading accordingly, 


What results?
ITM7
56
ITM7  
Vladimir Karputov:

Crossing of two iMA version   "1.003".

So far such functions work:

  • lot is calculated as risk percent from balance
  • we find crossing and we open on the market (without the pending orders)


Good day Vladimir, 

Lot size is working fine, 

I back tested the EA and paid attention at the crossing points. I noticed that the positions are being opened before the lines cross. I tried it on the demo account on a 5M time frame to observe the crossings more quickly but the same thing happened.

I thought it was the price values of the MAs like closing, opening price etc. but there is no problem with that. 

The EA is not waiting until the birth of a new bar, it opens position even if the lines have not crossed. I have attached some pictures that explains what I am trying to say, I captured them while backtesting and the same thing is happening when I forward test on the demo account   

I tried to follow the code of the EA, I could not see what was wrong although I did not understand everything, 

I searched the codes of some EAs that mention crossing of MAs and I came across this link in one of them which was very helpful.  : https://book.mql4.com/samples/indicators 

Under " Stochastic Oscillator " at https://book.mql4.com/samples/indicators , is the same thing that must happen when the lines cross but I don't know how to apply that code to the EA in MT5, the code is for MT4 and it seems like the iMA functions are not working the same in MT4 and MT5

Ragards

Usage of Technical Indicators - Simple Programs in MQL4 - MQL4 Tutorial
Usage of Technical Indicators - Simple Programs in MQL4 - MQL4 Tutorial
  • book.mql4.com
Usage of Technical Indicators - Simple Programs in MQL4 - MQL4 Tutorial
Vladimir Karputov
Moderator
52594
Vladimir Karputov  
ITM7:




"Missed_signal_and_premature_position_entry.png " - What were the parameters? Screenshot from the Strategy Tester, the "Inputs" tab
ITM7
56
ITM7  
Vladimir Karputov:

"Missed_signal_and_premature_position_entry.png " - What were the parameters? Screenshot from the Strategy Tester, the "Inputs" tab

Input parameter screen shot attached
Files:
Vladimir Karputov
Moderator
52594
Vladimir Karputov  

I will try to explain:

there is no crossing

crossing is

I will think over the good solution of this problem.

Vladimir Karputov
Moderator
52594
Vladimir Karputov  

Yes, it works!

Crossing of two iMA 1.004:

Crossing of two iMA 1.004

I have applied two-level check of a perpesecheniye.

//--- step 1: check in the arrays bars [0] and [1]
   if(First[0]>Second[0] && First[1]<Second[1]) // buy
     {
      if(!RefreshRates())
        {
         PrevBars=iTime(1);
         return;
        }
      double sl=m_symbol.Bid()-InpStopLoss*m_adjusted_point;
      double tp=m_symbol.Ask()+InpTakeProfit*m_adjusted_point;
      OpenBuy(sl,tp);
      return;
     }
   else if(First[0]<Second[0] && First[1]>Second[1]) // sell
     {
      if(!RefreshRates())
        {
         PrevBars=iTime(1);
         return;
        }
      double sl=m_symbol.Ask()+InpStopLoss*m_adjusted_point;
      double tp=m_symbol.Bid()-InpTakeProfit*m_adjusted_point;
      OpenSell(sl,tp);
      return;
     }
//--- step 2: on a step of 1 crossing haven't found. check in the arrays bars [0] and [2]
   if(First[0]>Second[0] && First[2]<Second[2]) // buy
     {
      if(!RefreshRates())
        {
         PrevBars=iTime(1);
         return;
        }
      double sl=m_symbol.Bid()-InpStopLoss*m_adjusted_point;
      double tp=m_symbol.Ask()+InpTakeProfit*m_adjusted_point;
      OpenBuy(sl,tp);
      return;
     }
   else if(First[0]<Second[2] && First[1]>Second[2]) // sell
     {
      if(!RefreshRates())
        {
         PrevBars=iTime(1);
         return;
        }
      double sl=m_symbol.Ask()+InpStopLoss*m_adjusted_point;
      double tp=m_symbol.Bid()-InpTakeProfit*m_adjusted_point;
      OpenSell(sl,tp);
      return;
     }
  }
Files:
1234567891011...14
To add comments, please log in or register