Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 293

 

https://www.mql5.com/ru/market/product/1144

I have this EA on sale in the Market for 1800 usd, I tested it on EURUSD and it makes money perfectly, on other pairs it trades with zeros, I think it has been adjusted to ticket history, can it be?

 
oDin48:

Share the information, please, because what's the point of writing an owl without having any normal DCs to work with.
I suggest you google it! It's all officially good!
 
SpikeOne:

https://www.mql5.com/ru/market/product/1144

I have this EA on sale in the Market for 1800 usd, I tested it on EURUSD and it makes money perfectly, on other pairs it trades with zeros, I think it has been adjusted to ticket history, can it be?

I think it has something to do with the Ticket History! It's for MT5! You can ask there!
 
TarasBY:

... and what language rules did you sculpt it according to?! For example:

:)


That's the problem, that's what needs to be "formulated" correctly, I've always had a good sense of logic, but it's been a month since I've been able to do it ((((((((
 
niformalka:

That's the problem, that's what needs to be "formulated" correctly, I've always been fine with logic, but I haven't been able to do it for a month now ((((((((

Help is at hand!

Documentation Tutorial TA Code Base Articles

 

"if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100 {"

In my opinion, this example is missing brackets: 3 opening and 2 closing. I advise the author of the owl to check if all the brackets match.

I would write it this way:

if ((iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100)&&(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100)) {

 
oDin48:

"if(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100&&iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100 {"

In my opinion, this example is missing brackets: 3 opening and 2 closing. I advise the author of the owl to check if all the brackets match.

I would write it this way:

if ((iCCI(Symbol,0,14,PRICE_TYPICAL,0)<100)&&(iCCI(Symbol,0,14,PRICE_TYPICAL,0)<-100)) {


tried it, still shows an error at the end of the listing
 
oDin48:

In this example I think there are 3 opening and 2 closing brackets missing. I advise the author of the owl to check if all brackets match.

Also Notepad++ is a good idea, in Notepad itself you choose C++ syntax for mql4 code, in settings menu tabulation should be set to cp3 (by default it seems to be 4). At a glance, there are two benefits:

1. highlighting of similarly named variables throughout the code

2. highlighting of paired brackets wherever they are in code (including vertical highlighting if code is tab-aligned). Any brackets - round, curly or square.

And last but not least, handy find-and-replace (also in selections), labeling (which "marks"), generally a simple and uncomplicated development environment. If you combine it with meta-editor, you get not a studio, of course, but a moderately powerful tandem.

 

Good day to you all!

I have a script that places orders in a CU.

Please help me to change it so that spread is taken into account.

For example a pair GBPCAD spread 10 - more orders are Sell - so TP should be at 1.7010 and stop loss at 1.7000 (1.6999 is ideal))

Thank you


advise how to put in the spoiler

//+------------------------------------------------------------------+
//|                                                    ZeroLevel.mq4 |
//|                                                          VadimVP |
//|                                                poluyan@fxmail.ru |
/*
 Скрипт поставит TakeProfit и StopLoss у открытых ордеров на текущем
 инструменте на уровень безубыточности.
 Расчет ведется только для ордеров текущего инструмента.
 Учитывает своп и комиссии. Работает при любых Digits.
 Точность +/- размер спреда.
 Об успешности изменений сообщит в диалоговом окне.
 Проверьте, включена ли опция "разрешить советнику торговать". 
*/
//| 
//+------------------------------------------------------------------+
#property copyright "VadimVP"
#property link      "poluyan@fxmail.ru"
 
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
   int kol=0;
   int kolOK=0;
   int i=0;
   double lots=0;
   double sum=0;
   double sum1=0;
   for (i=0; i<OrdersTotal(); i++)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_BUY)
      {
       lots=lots+OrderLots();
       sum=sum+OrderLots()*OrderOpenPrice();
       sum1=sum1+OrderProfit( )+OrderSwap( )+OrderCommission( )  ; 
       kol=kol+1;
      }
      if (OrderType()==OP_SELL)
      {
       lots=lots-OrderLots();
       sum=sum-OrderLots()*OrderOpenPrice();
       sum1=sum1+OrderProfit( )+OrderSwap( )+OrderCommission( )  ;
       kol=kol+1;
      }
   }
   double zeroprice=0;
   if (lots!=0) zeroprice=sum/lots;
   zeroprice = (MathRound(zeroprice*MathPow(10,Digits)))/MathPow(10,Digits);

   
//-----
 Alert ("!!!  Пожалуйста дождитель окончания работы скрипта!");
 int res = 0;
 for (i=0; i<OrdersTotal(); i++)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol()!=Symbol()) continue;
        
         if (zeroprice>Ask) 
         { if (OrderType()==OP_BUY) {if (zeroprice == OrderTakeProfit()) res=res+1; else { if (OrderModify(OrderTicket(),0,OrderStopLoss(),zeroprice,0,CLR_NONE)) res = res+1;}    }
           if (OrderType()==OP_SELL){if (zeroprice == OrderStopLoss()) res=res+1; else { if (  OrderModify(OrderTicket(),0,zeroprice,OrderTakeProfit(),0,CLR_NONE)) res = res+1;}     } }
         if (zeroprice<Bid) 
         { if (OrderType()==OP_BUY) {if (zeroprice == OrderStopLoss()) res=res+1; else { if (  OrderModify(OrderTicket(),0,zeroprice,OrderTakeProfit(),0,CLR_NONE)) res = res+1;} }
           if (OrderType()==OP_SELL){if (zeroprice == OrderTakeProfit()) res=res+1; else { if (OrderModify(OrderTicket(),0,OrderStopLoss(),zeroprice,0,CLR_NONE)) res = res+1;}    } } 
          
   }
 Alert ("***************************************************");
 Alert ("Цена безубыточности "+DoubleToStr(zeroprice,Digits));
 if (kol==res) Alert ("Все ордера успешно изменены! Точка безубыточности выставлена. ОК!"); else Alert ("!!! Внимание!!! Не удалось изменить - " +(kol-res)+ " ордера из "+kol+" имеющихся");
 Alert ("************ информация от ZeroLevel script ************");
 
//------

   return(0);
  }
 
MaximuS60:

Good day to you all!

I have a script that places orders in a CU.

Please help me to change it so that spread is taken into account.

For example a pair GBPCAD spread 10 - more orders are Sell - so TP should be at 1.7010 and stop loss at 1.7000 (1.6999 is ideal))

Thank you

advise how to put in the spoiler

The spread changes all the time! You already pay it by opening on Asc and closing on Bid in Bai, and the Sell, of course, the other way round!
Reason: