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

 
Vitaly Muzichenko:
You already have a certain price from which you should only trawl using the analog of a simple trawl but a simple trawl is based on the position opening price = OrderOpenPrice() and here it is based on the calculated average price and modifies all positions by one level

Yeah, I got it.

I'm looking at the code I posted earlier and it gives me a picture like this in the tester

It's a function I want to cut the size of those troughs, because there's a drain on one of them.

as a previous example -

I now have a lot of shorts on the rise of dollar-yen and I just want to add the insurance function there (if losses reach a percentage of balance - close all)
Files:
TesterGraph.gif  19 kb
 
vitek2010:

I wasn't talking about ticks I was talking about the need to fix the minimum and maximum readings of the indicator buffer calculated on a smaller timeframe, in the gap of a larger timeframe I will try to show it on the screenshot In this case, the larger the timeframe is taken, and the smaller H1 (but this is the window of different timeframes):

[img]https://charts.mql5.com/13/642/eurgbp-w1-instaforex-group.png[/img]

I will consider the week 05.12 (red crosshair) this bar graph by the indicator shown above clearly shows that the total pair movement at the end of the week was descending by 95 points, but it does not show how many points were descending or ascending during the week.

And here on this screen you can see the dynamics of this indicator on the H1 chart during this week:

[img]https://charts.mql5.com/13/642/eurgbp-h1-instaforex-group.png[/img]

Indicator had minimal value 400 and then went up to 700 and closed on 160 (the difference of numbers on two screens is not important)

i need all these values in one indicator in one bar of the histogram and the minimum, maximum and close (in this case on the wiki). ideally on the current timeframe from the one you specify in the settings of the timeframe

i did it on mt4 insta with the copy of mcl5

In the code you showed above, the reference is to the current TF, so what are we talking about? If you are accessing M5 from W1, then write it that way.

If you work with the current timeframe, then the close price is floating on zero bar, and on the rest - only one Close price, not many, how do I build a histogram on one value?

The pictures are inserted using the appropriate button at the top of the message editing window, there are a lot of useful buttons there, I recommend that you learn.

 
trader781:

Yeah, I got it.

I'm looking at the code I posted earlier and it gives me a picture like this in the tester

that's the function I want to cut the size of those troughs, because there's eventually a drain on one of them

as a previous example -

I opened shorts on yen-dollar rise and I want just to insure it (if losses will reach percentage of balance - close everything)
I would like to use the "bump" function (if losses reach a percentage of the balance). And the terms of TC to refine, if plummet - then the inputs are not there and not there.
 
Vitalie Postolache:
You have to "bump" less often or give up martingale. And refine the terms of the TS, if you are losing - then the inputs are not there and not there.

Thanks for the advice, but I just want the code to work the way I want it to, it's not about profitability/profitability. I just want to see what these functions look like.

Well, I have come across an expression in the previous code(_BuyLot>_SellLot?)Bid:Ask)

How should I interpret it?

 
trader781:

Thanks for the advice, but I just want the code to work the way I want it to, it's not about profitability/profitability. I just want to see what these functions look like.

Well, I have come across an expression in the previous code(_BuyLot>_SellLot?)Bid:Ask)

How should I interpret it?

Read here https://docs.mql4.com/ru/basis/operators/ternary
Условный оператор ?: - Операторы - Основы языка - Справочник MQL4
Условный оператор ?: - Операторы - Основы языка - Справочник MQL4
  • docs.mql4.com
Условный оператор ?: - Операторы - Основы языка - Справочник MQL4
 
trader781:

Thanks for the advice, but I just want the code to work the way I want it to, it's not about profitability/profitability. I just want to see what these functions look like.

Well, I have come across an expression in the previous code(_BuyLot>_SellLot?)Bid:Ask)

How should I interpret it?

It's like this in the transcript. The previous entry is shorter and often looks nicer in the code, but the sense of code execution does not change

if(_BuyLot > _SellLot) {
 xxx = Bid;
 } else {
 xxx = Ask;
}
 
Vitaly Muzichenko:

It's like this in the transcript. The previous entry is shorter and very often looks nicer in the code, but it does not change the sense of code execution

if(_BuyLot > _SellLot) {
 xxx = Bid;
 } else {
 xxx = Ask;
}

where xxx =_BuyLot

else

xxx =_SellLot

right?


Alexey Viktorov:
Read here https://docs.mql4.com/ru/basis/operators/ternary
I have a piece of unremarkable code written in simple language, and still you can hardly make out what it says from my point of view. It's a simple algorithm written by a generator.
 
trader781:

where xxx =_BuyLot

else

xxx =_SellLot

right?

No, it's not.

if(_BuyLot-_SellLot != 0) {
  if(_BuyLot > _SellLot) {
   AllAwerage= NormalizeDouble(Bid-((_BuyProfit+_SellProfit)/(TickValue*(_BuyLot-_SellLot))*_Point),_Digits);
  } else {
   AllAwerage= NormalizeDouble(Ask-((_BuyProfit+_SellProfit)/(TickValue*(_BuyLot-_SellLot))*_Point),_Digits);
  }
} else {
  AllAwerage=0;
}

But that's a lot of lines of code

 
trader781:

where xxx =_BuyLot

else

xxx =_SellLot

right?


I have a piece of unremarkable code written in a simple language, and nevertheless you can hardly make out what's written there from my point of view. A simple algorithm written by a generator.

Wrong. The trap operator assigns a value to a variable, not to the expression being compared.

double price=(_BuyLot>_SellLot?)Bid:Ask);

And it's high time we understood the algorithms, both generated and handwritten. Although sometimes it's easier to hand-write than to figure out what someone has screwed there.

 
Vitalie Postolache:


And the algorithms should be dismantled by now, whether generated or handwritten.

Well, I don't use classes, arrays, macros and import from Windows libraries yet. All in good time.