MQL4 - Get Price Difference between Position and current price

MQL4 Experts Scripts

Tâche terminée

Temps d'exécution 10 heures

Spécifications

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

 

  

Répondu

1
Développeur 1
Évaluation
(82)
Projets
150
29%
Arbitrage
9
44% / 11%
En retard
46
31%
Gratuit
2
Développeur 2
Évaluation
(1235)
Projets
2820
80%
Arbitrage
156
22% / 43%
En retard
488
17%
Gratuit
3
Développeur 3
Évaluation
(20)
Projets
46
54%
Arbitrage
3
67% / 0%
En retard
14
30%
Gratuit
4
Développeur 4
Évaluation
(339)
Projets
809
73%
Arbitrage
30
33% / 37%
En retard
194
24%
Gratuit
5
Développeur 5
Évaluation
(62)
Projets
140
46%
Arbitrage
19
42% / 16%
En retard
32
23%
Gratuit
6
Développeur 6
Évaluation
(803)
Projets
1374
72%
Arbitrage
113
28% / 48%
En retard
342
25%
Travail
Commandes similaires
EA execute a buy trade whenever SMA crossed over or a sell trade when SMA crossed under. EA continues to execute trade when TP is not met and an opposite signal is created by the SMA. EA only closes the sum of open trades when meeting a predetermined Target Price (TP). Incorporate money and trading time management. Developed EA comes with the source code. Details will be discussed when developer is selected
Hi, I would Like an EA ORDER PANEL for MT5 which allows me to place limit orders . The only addition I would like compared to other order panels, is an o ption to place a reversal trade if the original idea is stopped out. For example: I place a Short trade at 1.2120 with a 20 pip Stop Loss and a 100 pip target IF the SL is hit, then I want a Long trade to be place at 1.2120 with the same size SL and TP (20pip and
Together with a source code (in MQl4 and MQL5) of an EA which I will supply, I need the Hedging_Wedger to be recopied several times as series in form of MT4, MT5
i want you to convert my python grid bot script to mql5 for all forex pairs. Price can be negotiable. it is grid bot that is working properly in python . but i need you to convert this into mql5 for algo trading
The EA is in below VPS Server: 176.57.188.42 User: administrator Password: Test123! Kindly access the vps to check out the EA, the name of the EA I'm referring to is called TOPGUN 2.0 The job is to replicate the same EA in the server and code a very similar one based on the exact functionality in that existing EA. if u can do it kindly reach out
Hello, Great programmers please need help with new project 5 digit pairs = Major currencies. Logic. Lot fixed and percentage lot size Expert advisor Place Stop orders at Closed Candle only not Grid or Matin. expert advisor but Short term trade strategy example: SELL Stop order at Price----- 1.11920 Stop loss at price----------0.00005 = 1.11920 + 0.00005 Take profit at price--------0.00100 = 1.11920 - 0.00100 Trail
Around 3,000 lines of code. This is NOT for a newbie or someone who will just try to figure it out and waste each other's time. Need a PRO who can work fast, smart, and follow the instructions exactly. NO creativity, NO improvising, NO doing what you feel is best. NO scatter brain working on 5 projects at once. Finish mine carefully and promptly then you take another job. If I say candle body it means the close price
hello everyone I need to create an ea that creates signals based on the indicator on trading view and transmits it directly to mt5, so that the signals are created on trading view and orders are opened in mt5
Create a basic EA with 2 indicators and 3 conditions with stop loss and trailing stops. The lot size is one full lot, 1.0 EUR/USD, 100,000 Euros and stated clearly in the code
Dear Potential Partner, I am a seasoned software engineer currently employed as a Quant Developer at an innovative start-up. With a solid foundation in the financial industry and forex trading, I have recently expanded my portfolio to include freelance work, developing highly successful projects and profitable Expert Advisors (EAs). I am now seeking a strategic partner to help me capitalize on these achievements and

Informations sur le projet

Budget
10 - 20 USD
Pour le développeur
9 - 18 USD
Délais
de 1 à 2 jour(s)