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

 
trader781:

I don't understand where to put it and why it's not (-1)

there is an input parameter bool

void OnTick

{analysis of order opening, trailing stop}

void Trailing Stop

{corresponds to close conditions

if yes we cover all there is

}

In fact, return; It's a void

I do not know what logics you have there. How do you expect me to guess what you have there?
 
trader781:

by three points

1 extern point where we set whether we want to open the second or more orders

2) a condition where we have to open the first order

3) close order point

I can send you the code but it is the same for everyone

So why do you litter the thread if you do not need help?

You will not find useful messages in a thousand useless pages

P.S. Or is your goal to stuff your posts to the maximum?
 
trader781:
Then I ask for a diagram of the switch on these three points. Then I'll delete my posts if you consider it rubbish.

What is this point?

1 extern point where we set whether we want to open the second or more orders

2) a condition where we have to open the first order

3) point of order closing

Do you even know what you want?

You can't set an order in point 2, you can't close it, and it can only be deleted. In general, everything you have is somehow logically incoherent and vague, you need to be a deputy.

 

There is this part of the code:

if(ObjectFind(0,nm)<0) {
    ObjectCreate(0,nm,OBJ_TEXT,0,0,0);
    ObjectSetString(0,nm,OBJPROP_PRICE, TIME(0)+Period()*60*3); // сдвиг вправо на 3 свечи
}

Question:Period() returns a sane value up to M30, from H1 a set of digits, and the marker can no longer be shifted in this way.

How to shift by N - candlesticks regardless of the period? I don't have to write a separate function, do I?

 
Vitaly Muzichenko:

There is this part of the code:

if(ObjectFind(0,nm)<0) {
    ObjectCreate(0,nm,OBJ_TEXT,0,0,0);
    ObjectSetString(0,nm,OBJPROP_PRICE, TIME(0)+Period()*60*3); // сдвиг вправо на 3 свечи
}

Question:Period() returns a sane value up to M30, from H1 a set of digits, and it's no longer possible to offset the mark in this way.

How to shift by N - candlesticks regardless of the period? I don't have to write a separate function, do I?

PeriodSeconds(PERIOD_CURRENT)*3
 
Artyom Trishkin:
PeriodSeconds(PERIOD_CURRENT)*3

Thank you!

The question is: How correct is this entry, it is at the beginning of the program, while throughout the program a lot of Time[0] and Time[1] are used, and not to be called every time, it is written in a variable. There seems to be no errors outside the array, but everything is superficially defined:

datetime TM[], TIME0, TIME1;

//------------
void OnTimer()

ArraySetAsSeries(TM, true);
  if(CopyTime(_Symbol, PERIOD_CURRENT, 0, 2, TM)==-1) return;
   TIME0 = TM[0];
   TIME1 = TM[1];

Thanks!

 
Vitaly Muzichenko:

What is this point?

1 extern point where we set whether we want to open the second or more orders

2) a condition where we have to open the first order

3) point of order closing

Do you even know what you want?

You can't set an order in point 2, you can't close it, and it can only be deleted. In general, you are always somehow logically incoherent and vague, you need to be a deputy.

please. Here is the extern bool parameter OpenOrders=false;//+---open order

I need it to open orders, close them and then just hang on the chart without eating up resources

at the moment it is self-sawed (it works, but unacceptable for a panel element)

Files:
 
trader781:

please. Here is the extern bool parameter OpenOrders=false;//+---open order

I need it to open an order, close it, and then just hang on the chart without eating up resources

at the moment it is self-sawed (it works, but unacceptable for a panel element)

I would have done so. Add "Disabled" to the code

P.S. Replace line 72 with "if(! Disabled) return;". I think the logic of the flag is clear.
Files:
 
Vitaly Muzichenko:

I would do the following. Add "Disabled" to the code.

P.S. Replace line 72 with "if(! Disabled) return;". I think the logic of the flag is clear.

No, it's not clear. Going back to where we came from.

1) Disabled=true

initialize to true inite

pass to ontik if(!Disabled) return;

open close

Disabled=false; exit. Everything is fine.

2) Disabled=false

initialize ontik to true

pass to ontic if(!Disabled) return;

open close

Disabled=false; exit. Where do I open the next order? Some variant should allow this.

Now do you understand why I asked you to describe the logic?

I have an option of 2 EAs too.

 
trader781:

No, I don't understand. Back to where we came from.

1) Disabled=true

Initialize in the inite to true

pass to ontik if(!Disabled) return;

open close

Disabled=false; exit. Everything is fine.

2) Disabled=false

initialize ontik to true

pass to ontic if(!Disabled) return;

open close

Disabled=false; exit. Where do I open the next order? Some variant should allow this.

Now do you understand why I asked you to describe the logic?

I have an option of 2 EAs too.

It is not clear. If you need to stop the EA, then the suggested variant copes with this, if there is no need to stop it, then let it trade and do not limit it in any way. If you want to trade on demand after the stop, it is sufficient to switch the time, Disabled will become true and the program will continue to work
Reason: