MQL4 - Get Price Difference between Position and current price

MQL4 Esperti Script

Lavoro terminato

Tempo di esecuzione 10 ore

Specifiche

MQL4 - Get Price Difference between Position and current price

 

Basically I want the following code

 

If i got 0 position, bool validGap = 0;

Then it open e.g UJ long at 99.00

 Now i got 1 order

UJ long at 99.00

My setting is gap 25 Points

if UJ goes to 99.25, i want to open 1 more position (add to winner)

or if UJ goes to 98.75 , I want to open 1 more position ( add to loser )

 

Take note the amount of digits or what symbol I playing need to be dynamic, no hardcoding.


My current code is something like this, however the EA keep open position despite there is no  25 * one Pip gap

 

Consider my gapTrade is value 25 

 

 double SL,TP,onePip;
 int Ticket;

onePip = 0.00;

if (MarketInfo(OrderSymbol(), MODE_POINT) == 0.00001) onePip = 0.0001;
else if (MarketInfo(OrderSymbol(), MODE_POINT) == 0.001) onePip = 0.01;
else onePip = MarketInfo(OrderSymbol(), MODE_POINT);

/***********************************/      
    
   //check if price match
   
   double currentPrice;
   currentPrice = MarketInfo(Symbol(),MODE_BID);
  
 bool validGap = false; // Initial - Not Okay.
 
  
   double minValue,maxValue,priceDiff;
   priceDiff = 0.00;
   minValue = 9999.0;
   
   for (int ii=OrdersTotal()-1 ; ii>=0 ; ii--)
   {
      if (!OrderSelect(ii,SELECT_BY_POS)) continue;
      if (OrderSymbol() == Symbol())
               if (OrderOpenPrice()  > maxValue)
               {
               maxValue = OrderOpenPrice();
               }
               if (OrderOpenPrice()  < minValue)
               {
               minValue = OrderOpenPrice();
               }
    }
   

  if(direction=="SELL")
  {
  priceDiff = currentPrice - maxValue;

  if( priceDiff > onePip*gapTrade)
  {
  validGap = true;
  }
  }
  
  if(direction=="BUY")
  {
  priceDiff =  minValue - currentPrice;
  //We use max value 
  if( priceDiff > onePip*gapTrade)
  {
  validGap = true;
  }
  }

  //Check if best trade in a buy is in profit
  /* ADD NEW POSITION TO A WINNING 1 */
  
  if(direction=="BUY")
  {
  priceDiff = currentPrice - maxValue;
  if( priceDiff > onePip*gapTrade)
  {
  validGap = true;
  }
  }

  if(direction=="SELL")
  {
  priceDiff = minValue - currentPrice;
  if( priceDiff > onePip*gapTrade)
  {
  validGap = true;
  }
  }

 

  

Con risposta

1
Sviluppatore 1
Valutazioni
(82)
Progetti
150
29%
Arbitraggio
9
44% / 11%
In ritardo
46
31%
Gratuito
2
Sviluppatore 2
Valutazioni
(1235)
Progetti
2820
80%
Arbitraggio
156
22% / 43%
In ritardo
488
17%
Gratuito
3
Sviluppatore 3
Valutazioni
(20)
Progetti
46
54%
Arbitraggio
3
67% / 0%
In ritardo
14
30%
Gratuito
4
Sviluppatore 4
Valutazioni
(339)
Progetti
809
73%
Arbitraggio
30
33% / 37%
In ritardo
194
24%
Gratuito
5
Sviluppatore 5
Valutazioni
(62)
Progetti
140
46%
Arbitraggio
19
42% / 16%
In ritardo
32
23%
Gratuito
6
Sviluppatore 6
Valutazioni
(809)
Progetti
1384
72%
Arbitraggio
113
29% / 48%
In ritardo
343
25%
In elaborazione
Ordini simili
Hi there, I am offering $30 usd for someone to convert four pictures I have to metatrader icons(arrows) that I can use in both MT4 & MT5. We all know that we can change arrows on the chart by using a different arrow code, but the arrows in metatrader are boring and I want to use custom ones. I want the four attached pictures as icons that i can use with indicators that give the option to choose your arrow type. I
I need an expert to decrypt my itf file using on prorealtime. I forgot my password, so I need to generate the source code. I need someone that can help me to derive source code from the itf file I have

Informazioni sul progetto

Budget
10 - 20 USD
Per lo sviluppatore
9 - 18 USD
Scadenze
da 1 a 2 giorno(i)