Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 626

 
Ihor Herasko:

Write your own ticks and put them in the strategy tester.

but anything more user-friendly?

 
Andrey Sokolov:

but something more user-friendly?

can't you write what you won't do yourself? thenhttps://www.mql5.com/ru/job

here is the articlehttps://www.mql5.com/ru/articles/4566

you read it, make quotations according to your own laws of distribution

if MT4 needs its own charts and ticks, then read the article, export quotes from MT5 and import them into MT4

it cannot be simpler

If you can program for MT4, open the PeriodConverter script from MT4 in MetaEditor, the code there is clear and quite compact in size, it will not take you much time to figure it out, then create your own chart and test it

ZS: I remembered I posted on the forum a script to create charts with Wehrstrass function.

https://www.mql5.com/ru/forum/86386/page988#comment_7843056

 

Hello. The function Returns a flag for the existence of a position or order near the market (function found on the forum). For the test code, it should open a position if around 200 pips above and below the current price, there are no positions. Why does it open a position on every tick at almost the same price?

//+------------------------------------------------------------------+
//|                                                    testprpos.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//--- input parameters
input int      Input1;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(!ExistOPNearMarket(Symbol(),-1,200))
     {
      int ticket=OrderSend(Symbol(),OP_BUY,1,Ask,300,0,0,"_",16384,0,clrGreen);
      if(ticket<0)
        {
         Print("OrderSend завершилась с ошибкой #",GetLastError());
        }
      else
         Print("Функция OrderSend успешно выполнена");
      //--- 

     }

  }
//+------------------------------------------------------------------+
bool ExistOPNearMarket(string sy="",int op=-1,int mn=-1,int ds=1000000) 
  {
   int i,k=OrdersTotal(),ot;

   if(sy=="" || sy=="0") sy=Symbol();
   double p=MarketInfo(sy,MODE_POINT);
   if(p==0) if(StringFind(sy,"JPY")<0) p=0.0001; else p=0.01;
   for(i=0; i<k; i++) 
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) 
        {
         ot=OrderType();
         if((OrderSymbol()==sy) && (op<0 || ot==op)) 
           {
            if(mn<0 || OrderMagicNumber()==mn) 
              {
               if(ot==OP_BUY || ot==OP_BUYLIMIT || ot==OP_BUYSTOP) 
                 {
                  if(MathAbs(MarketInfo(sy, MODE_ASK)-OrderOpenPrice())<ds*p) return(True);
                 }
               if(ot==OP_SELL || ot==OP_SELLLIMIT || ot==OP_SELLSTOP) 
                 {
                  if(MathAbs(OrderOpenPrice()-MarketInfo(sy, MODE_BID))<ds*p) return(True);
                 }
              }
           }
        }
     }
   return(False);
  }
//+------------------------------------------------------------------+
 
I have a problem with the migration of EAs, the buttons have become inactive, I can't migrate, has anyone experienced this?
 
Aleksei Petrenko:
I have a problem with the migration of EAs, the buttons have become inactive, I can't migrate, has anyone experienced this?
 
Aleksei Petrenko:


 
Ghabo:

Hello. The function Returns a flag for the existence of a position or order near the market (function found on the forum). For the test code, it should open a position if around 200 pips above and below the current price, there are no positions. Why does it open a position on every tick at almost the same price?

Check the number of parameters when calling

ExistOPNearMarket(Symbol(),-1,200)

and its description

 
Galim_V:

Check the number of parameters when calling

and its description

Thank you.
 
I have a binary bot on python, question: how can I send it a signal from the robot from the terminal without crutches?
 

Can you tell me how to calculate the collateral for a transaction?


Tried two approaches

(0.1 * Ask*MarketInfo(Symbol(),MODE_LOTSIZE))/AccountInfoInteger(ACCOUNT_LEVERAGE)


And this one

FreeMarginCheck=AccountFreeMarginCheck(Symbol(),OP_BUY,0.1);

 double val=AccountFreeMargin()-FreeMarginCheck;



The first one gives strange results on EURJPY if my deposit currency is USD. Do I need to add something to the formula?

The second one works also occasionally, sometimes with correct values, sometimes with some nonsense (it depends on the deposit)

Reason: