MQL4 - Get Price Difference between Position and current price

Работа завершена

Время выполнения 10 часов

Техническое задание

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

 

  

Откликнулись

1
Разработчик 1
Оценка
(82)
Проекты
150
29%
Арбитраж
9
44% / 11%
Просрочено
46
31%
Свободен
2
Разработчик 2
Оценка
(1235)
Проекты
2820
80%
Арбитраж
156
22% / 43%
Просрочено
488
17%
Свободен
3
Разработчик 3
Оценка
(20)
Проекты
46
54%
Арбитраж
3
67% / 0%
Просрочено
14
30%
Свободен
4
Разработчик 4
Оценка
(339)
Проекты
809
73%
Арбитраж
30
33% / 37%
Просрочено
194
24%
Свободен
5
Разработчик 5
Оценка
(62)
Проекты
140
46%
Арбитраж
19
42% / 16%
Просрочено
32
23%
Свободен
6
Разработчик 6
Оценка
(803)
Проекты
1374
72%
Арбитраж
113
28% / 48%
Просрочено
342
25%
Работает
Похожие заказы
If i can get the done asap that would be awesome This EA uses the indicator so name of the indicator must me matched in the expert for the ea to function properly those with experience understand im sure thank you I want to change 1 EA & indicator name these are the name changes i need for the ea 4 total Bank Executive PLUS Bank Specialist PLUS Bank Stimulus PLUS Bank wealth PLUS these are the name changes i need for
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

Информация о проекте

Бюджет
10 - 20 USD
Исполнителю
9 - 18 USD
Сроки выполнения
от 1 до 2 дн.