[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 128

 
hoz:

You can put 0(zero), because usually you don't need to expire. But you probably have it as a precaution, so that you don't have to return to this point.
So, it is 0 in standard function, while in presentation it is necessary to specify, that the subsequent parameters (color) should work. I don't use expiration at all in the pending, I delete only by condition.
 

Gentlemen programmers,


Please help me to understand.

I have inserted this code https://www.mql5.com/ru/code/8811 for virtual trading as a function in my indicator.

It works in real time and performs virtual trading of any complexity.

Can I use it as a trigger on the history by walking bar? Or may I write a new code?


My thanks.

 
abdul1:

Gentlemen programmers,

Please help me to understand.

I have inserted this code https://www.mql5.com/ru/code/8811 for virtual trading as a function in my indicator.

It works in real time and performs virtual trading of any complexity.

Can I use it as a trigger on the history by walking bar? Or may I write a new code?

My thanks.

It's better to ask the codebase of the author where you downloaded it.
 

borilunad, you have, for example, if the function has both B.U. and TPAAL, the cycle and selection of orders, as I understand it, is in the function start and is triggered on ticking?

I'm trying to figure out how to combine all this and my brain has already started to overload my brain, I need the B.T. to work only when the stop price is below minimum threshold, i.e. open price+ minimum take. I have this variable priceBU. And then the traal has moved on. I'm trying a separate function right away for practice, it's easier for me to understand. I'll get to yours as soon as everything starts working.

In the start I wrote so:

int start()
{
   int g;
   for (g = OrdersTotal() - 1; g >= 0; g--)
   {
       if (!OrderSelect(g,SELECT_BY_POS)) continue;
       if (i_magic != -1) if (OrderMagicNumber() != i_magic) continue;
       if (OrderSymbol() != Symbol()) continue;
       
      if (OrderStopLoss() <= priceBU)
      {
          MovingStopLossToBU();
      }
      {
          ticket = OrderTicket();
          TrailingStop("", -1, -1);
      }
   }

Did I do it right, or should I do it differently? It all seems to work correctly, but somehow it is written simply, without any conditions...

 
hoz:

borilunad, you have, for example, if the function has both B.U. and TPAAL, the cycle and selection of orders, as I understand it, is in the function start and is triggered by a ticking?

I'm trying to figure out how to combine all this and my brain has already started to overload my brain, I need the B.T. to work only when the stop price is below minimum threshold, i.e. open price + minimum take. I have this variable priceBU. And then the traal has moved on. I'm trying a separate function right away for practice, it's easier for me to understand. I'll get to yours as soon as everything starts working.

In the start I wrote so:

Did I do it right, or should I do it differently? It all seems to work correctly, but somehow it is written simply, without any conditions...

Exactly, the function must be called when the conditions are fulfilled, and the conditions must be adequate to the market, respect the distances to the price and always have the necessary variation from the spread and others (I have prev), which will protect against violations and errors due to spontaneous price movements. And of course, the ticking! So why call the function every tick, therefore the conditions should be prescribed at the start. Especially on the Real, yours will not "seemingly", but certainly will not work, we will get errors one after another. And I doubt it will work on Demo, too. And what do I see in Demo? - Look at my Trawl, you also need to translate into B/S and set SL and TP, and do the same for Sell, and put it all in one loop of enumeration and position selection, and you will have a well working block of all modifications, calling just one function, and no hassle. ;)
 
hoz:



So I have a test for that:

If stop - new stop (in b.u.) is not zero... then we modify... If not, we don't modify. That's why it's not clear to me how this happens. After all, I understand that I need to check for equality of past and new stop and I've done it.

if (ND(OrderStopLoss()) - ND(priceBU * pt) != 0.0) - we need it like this, if ND(...) - this is normalization.

 
borilunad:
Exactly, the function must be called when the conditions are fulfilled, and the conditions must be adequate to the market, respect distance to the price and always have the necessary gap (mine prev), which prevents violations and errors due to spontaneous price movements. And of course, the ticking! So why call the function every tick, therefore the conditions should be prescribed at the start. Especially on the Real, yours will not "seemingly", but certainly will not work, we will get errors one after another. And I doubt it will work on Demo, too. And what do I see in Demo? - Look at my Trawl, you also need to translate into B/S and set SL and TP, and do the same for Sell, and put it all in one loop of enumeration and position selection, and you will have a well working block of all modifications, calling just one function, and no hassle. ;)


Wow. It's like I've been born again. Before it was easier, and now I'm thinking how to make it any different. I made a loop at the start. Now I'm gonna have to rewrite everything...

One strange thing. You say it won't work. But as many experts as I've seen, everything is called by separate functions and works... I agree that it consumes more resources, but... why there will be bundles of errors is a mystery to me.

It's a mystery to me because I've seen so many scoops and it's written in the same way as mine. But I've never seen one loop and a choice at the start, and then everything is chained to it... I've never seen...

 
hoz:


Wow. It's like I was born again. It used to be easier, but now I'm wondering how to redo anything at all. I made a loop at the start. Now I have to rewrite everything.

One strange thing. You say it won't work. But as many experts as I've seen, everything is called with separate functions and works... I agree that it eats up more resources, but... why there will be bundles of errors is a mystery to me.

It's a mystery to me because I've seen so many scoops and it's written in the same way as mine. I've never seen one cycle and a choice at the start, and then everything clings to it...

Codebase has a lot of different solutions and different level. I started with modifications and gradually came to this construction, which is not at all new, but for me it is convenient. I have plenty of off-start functions without modifications. For opening an order and/or position there is also one function. Instead, I do a lot of checks before opening, also with functions outside the start. To close a position, I use many conditions with even more functions for various checks.

It is just this function that I use for modifications but modifications are different and involve different conditions, checks and protective measures. I can't cram it all into one function and it makes no sense. I access it when all conditions are met and everything has been calculated, and I only give it the last step. If something is wrong, it doesn't send it, returns it, rechecks the data and tries again, and only the exact price and exact data is sent to the DC, which is immediately accepted and set. The main thing is not to disturb the brokerage company too much.

Once again, we recommend to try just two lines of conditions to set a new value of SL in trawling and you will understand that we need to be very thorough here. By the way, this block, developed by me, wanders from one TS to another with slight modifications. Everything else, especially the closure has to be done anew, depending on the selected TS algorithm. And finally, I don't insist on anything, I just share what I've tried and tested, and I don't exclude that someone may offer you something more acceptable for you. So try, try out, try it out, but never bet on Real at random, some half-finished product.

Why am I telling you this, because every beginner here wants to bang out a quick fix and make "dough". This should be a gift for a job well done. And those who are not yet out of childhood, do not enjoy the work and only want to play, the market will not forgive him.

Good night! And tomorrow, with a clear head, back to work again!

 
Valerius:


There don't seem to be any experts who can answer this very simple question, just two programmers getting together in a get-together and that's it... What is the purpose of this forum, then?

 
Valerius:


There don't seem to be any experts who can answer this very simple question, just two programmers getting together in a get-together and that's it... What is the purpose of this forum, then?

Your question has already been answered a hundred times - if you are comparing two fractional numbers, normalize both before comparing