MQL4 - Get Price Difference between Position and current price

MQL4 Experten Skripte

Auftrag beendet

Ausführungszeit 10 Stunden

Spezifikation

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;
  }
  }

 

  

Bewerbungen

1
Entwickler 1
Bewertung
(82)
Projekte
150
29%
Schlichtung
9
44% / 11%
Frist nicht eingehalten
46
31%
Frei
2
Entwickler 2
Bewertung
(1235)
Projekte
2820
80%
Schlichtung
156
22% / 43%
Frist nicht eingehalten
488
17%
Frei
3
Entwickler 3
Bewertung
(20)
Projekte
46
54%
Schlichtung
3
67% / 0%
Frist nicht eingehalten
14
30%
Frei
4
Entwickler 4
Bewertung
(339)
Projekte
809
73%
Schlichtung
30
33% / 37%
Frist nicht eingehalten
194
24%
Frei
5
Entwickler 5
Bewertung
(62)
Projekte
140
46%
Schlichtung
19
42% / 16%
Frist nicht eingehalten
32
23%
Frei
6
Entwickler 6
Bewertung
(803)
Projekte
1374
72%
Schlichtung
113
28% / 48%
Frist nicht eingehalten
342
25%
Arbeitet
Ähnliche Aufträge
Looking for a skilled freelancer to create a simple indicator that displays key data directly on the chart during a backtest on MetaTrader 4. The indicator should show: - **Balance** - **Profit in $** - **Profit in %** I already have the sample in MT5 (.mq5 file), but I need it converted and optimized for MT4. This is a straightforward task with a quick turnaround time—just 2 hours. I'm offering $250 for this
Hi, I have a Compiled JForex strategy (.jfx file) I would like someone to convert it in to readable source code. Please let me know if you can do this task. Thank you
I want to make something automatic which EMA will automatically trade in my account. For this I want to make a simple robot I want to get this made automatically on a simple EMA
I need a professional who have the full knowledge in Ctrader and I want to add new idea for my ctrader https://ctrader.com/algos/indicators/show/3444/ Let me know if this is what you can do and the price to get it done. Thanks
I am looking for a skilled Thinkorswim script developer for a one-time project. Your task will be to combine 8 distinct Thinkorswim studies (I will provide the code for each) into one Lower Study. The final script should display histogram rows for the individual studies with a bubble color scheme of bright green, dark green, gray, dark red, and bright red
I need some who can develop my strategy and hand me over the source code... I will give you the specific area in the market i want to mark out and then set pending orders to execute once price move into the zone

Projektdetails

Budget
10 - 20 USD
Für die Entwickler
9 - 18 USD
Ausführungsfristen
von 1 bis 2 Tag(e)