[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 206

 

You lost... I turned out to be adequate !

You do have the BROKO-INVESTOR mt4 installed. Or you (most likely) elementary mistook the server when you opened a demo account

It is easy to see by the currency names. Only there to the name of currencies appended ending _FX.

Min. lot there = 0.1 and there in the MARKET OVERVIEW only currencies are present (no stock market instruments)

Do not be stubborn. Go to Broco's website and download mt4 from the Broco-trader section.

Or open a demo account on the server 87.239.184.73:443

But in this case, all the same positions will not open online and the log will give an error. So, go figure out how to programmatically open a position in 2 steps.

 

I have 10 minutes of time. I will now give you a code example of how I open positions in BROKO.

At the very end of your EA code (outside of START) you need to insert this function:

//Для  открытие позиций в условиях рыночного
 //                    исполнения торговых заявок 
int WHCOrderSend(string symbol, 
                 int cmd, 
                 double volume, 
                 double price, 
                 int slippage, 
                 double stoploss, 
                 double takeprofit, 
                 string comment, 
                 int magic, 
                 datetime expiration, 
                 color arrow_color)
{
   int ticket = OrderSend( symbol, cmd, volume, price, slippage, 0, 0, comment, 
                                                    magic, expiration, arrow_color);   
   int check = -1;
   if ( ticket > 0 && ( stoploss != 0 || takeprofit != 0)) {
    if (!OrderModify( ticket, price, stoploss, takeprofit, expiration, arrow_color)) {
         check = GetLastError();
     if ( check != ERR_NO_ERROR) {
       Print("OrderModify error: ", ErrorDescription( check));
         }}} else {
      check = GetLastError();
      if ( check != ERR_NO_ERROR){
         Print("OrderSend error: ", ErrorDescription( check));
      }}   return ( ticket);}

 

The stops in the external parameters will then be set as follows

extern int     Magic = 777;
extern int      StopLoss=90;
extern int      TakeProfit=90;

double SL, TP;
int ticket;
//-- Подключаемые модули --
#include <stderror.mqh>
#include <stdlib.mqh>
//---------------------------------
And the positions themselves open like this:
 
//если условия соответсвуют заданным, 
// открывем позицию бай 
SL=0; TP=0;
if( StopLoss>0)   SL=Ask-Point* StopLoss;
if( TakeProfit>0) TP=Ask+Point* TakeProfit;   
ticket= WHCOrderSend(Symbol(),OP_BUY, Lots,Ask,3, SL, TP,"Dayria_02", Magic,0,Blue);
if( ticket < 0) { Print("Ошибка открытия ордера BUY #", GetLastError()); 
               Sleep(10000);   return (0); }
Similarly, for sell positions:
SL=0; TP=0;
if( StopLoss>0)   SL=Bid+Point* StopLoss;
if( TakeProfit>0) TP=Bid-Point* TakeProfit;   
ticket= WHCOrderSend(Symbol(),OP_SELL, Lots,Bid,3, SL, TP,"Dayria_02", Magic,0,Red);
if( ticket < 0){Print("Ошибка открытия ордера SELL #", GetLastError()); 
                Sleep(10000);   return (0);  }
 

rid, thank you very much for the feedback, I really picked the wrong server. I'm sorting out the code.

 

Don't argue (c) for it's easy to get confused.



The terminal is from Life and the demo is someone else's... ;)

So the priority is the connected server rather than the name of the terminal or the company.

Especially if you're dealing with EMTs like cockroaches... )))

 
kombat >> :

....So it is the server that is connected rather than the name of the terminal or the company.

Especially one where EMTs are spread like cockroaches... )))



Yes, of course.

But for beginners, it is often easier to download a new platform than to introduce a different server.

 
cdover >> :

rid, thank you very much for the feedback, I really picked the wrong server. I'm sorting out the code.

By the way. In the tester the EA should work without modification function.

If you need a quick check of a programmed idea, use the mt4 tester (here it is clearly and intelligently described how to do it)

'Testing and optimising EAs'

 
rid писал(а) >>

By the way. In the tester, the Expert Advisor should work without the modification function.

If you need a quick check of a programmed idea, use the mt4 tester (here it is clearly and intelligently described how to do it)

The tester is an easy and clear description of how to do it)- 'Testing and Optimizing Expert Advisors'.

I am working with the tester and it was really strange, everything works and gives you the optimisation reports.

 
granit77 >> :

That's what I meant when I suggested running the same environment (objects, indicators) with and without the template.

As for the tester slowdown, it's a black hole for me. Sometimes quite harmless Expert Advisors do such tricks that you can hardly believe it, but everything is OK in the log. Therefore I will not dare to give any advice, except for the simplest of cases. I wish I could figure it out myself :))

..But what a thrill it is to discover the solution :)

 

Good afternoon!

Please help me with a question:

I need to write a formula to calculate the collateral for one instrument.

I understand how to extract the total amount of pledge - using a formula,

But how do I decompose this pledge into instruments (currencies)?

After all, there is only buy and sell, and there are lots.

MODE_MARGININIT 29 Initial margin requirement for 1 lot
MODE_MARGINMAINTENANCE 30 Amount of margin requirement to support open positions per 1 lot
MODE_MARGINHEDGED 31 Margin charged on overlapped positions per 1 lot

I need to use these formulas, but it is not clear what is the difference between them and when to use them.

As a result, we need to get the breakdown of the total amount of the margin for certain instruments.

That is, open lots of one instrument use so-and-so amount of the deposit. another instrument uses so much and so much ... and so on.

Maybe someone has some ideas? Thank you.

Reason: