Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 373

 
PaMyC:


Thanks so much it helped), just removed the point and miracles all done))))

Just as I thought the error was very small but so nasty...


You're welcome)
 
vadynik:


I just want to understand, here I make a function

But sl goes both up and down behind the bid, which is natural) so the closing condition will not work)

so how to make that sl would go only in one direction?


You are missing one condition: if the calculated distance from the bin to the new calculated stop is less than from the bin to the current stop, then modify the stop (move it to the price), if not, then leave it alone, until the necessary condition is met
 
Ekburg:

You are missing one condition: if the calculated distance from the bin to the new calculated stop is less than from the bin to the current stop, then modify the stop (move it to the price), if not, do not touch it, until the necessary condition is met
I don't want to modify it - we need a virtual trawl
 
vadynik:
I don't want to modify it, I need a virtual trawl

I wrote out of habit)) Just try what I advised, similarly in your virtual trawl.
 

Gentlemen, my request still stands (see page 369). I will repeat it here:


Дорогие товарищи, друзья! Трудно выразить, как я благодарен вам за предыдущую помощь мне в написании советника (в конце 350-х стр. этой темы). Теперь мне снова нужна ваша помощь, надеюсь, вы вновь её окажете.

Итак, мне нужно прописать в советнике следующее:

Советник должен работать на экстремумах EMA. На максимумах ЕМA он должен выставлять отложенный ордер на открытие шорта по цене, равной цене лоя свечи разворота мувинга минус определённый процент от этой цены (например, лой свечи разворота * 0,99) В отложенном ордере также должны быть прописаны стоп-лосс и тейк-профит в процентах от этого самого лоя свечи разворота мувинга. Но это не всё. Также при наличии максимума EMA советник должен выставить стоп-лоссы во всех открытых лонгах по данному активу на той же отметке, на которой должен открыться шорт. Таким образом, при достижении расчётной цены (см. выше) должны быть закрыты имеющиеся лонги (по выставленным ранее советником стоп-лоссам) и открыт шорт.

При минимуме EMA всё наоборот: Имеется свеча, где мувинг развернулся вверх. На следующей свече советник должен начать следить за ценой и когда она превысит отметку: хай свечи разворота + определённый процент (например, хай свечи разворота * 1,01 ), то в существующих открытых шортах должны быть выставлены стоп лоссы по этой цене (хай свечи разворота + определённый %) и должен быть выставлен отложенный ордер на открытие лонга по этой же цене (со стоп-лоссом и тейк-профитом в %-х от хая свечи разворота).


Таким образом, советник при развороте мувинга (имеется ввиду завершённый разворот, то есть разворот на предыдущих двух свечах, текущая свеча в расчёт не идёт, мувинг может разворачиваться на текущем баре, но в итоге не развернуться на нём, эти развороты в течение текущего мувинга, если в итоге закрытия бара разворота нет - в расчёт не идут).

Так вот, при максимуме мувинга советник должен выставлять на определённой (см. выше) отметке стоп-лосс на имеющихся лонгах и выставлять отложенный ордер на открытие шорта по этой же отметке (со стоп-лоссом и тейк-профитом).

При минимуме мувинга всё наоборот - советник выставляет стоп-лосс в открытых шортах на определённой отметке (см. выше) и выставляет отложенный ордер на открытие лонга по этой же отметке (со стоп-лоссом и тейк-профитом).

Таким образом, по советнику не возможно будет выйти в кэш, всегда будем либо в лонге, либо в шорте. При закрытии лонга одновременно открывается шорт и наоборот.


Я пробовал поколдовать над имеющимся у меня рабочим советником (он работает на пересечении двух EMA), модифицировать его нужным образом. Но, ввиду слабых знаний в Cи++ и свойственного мне отвращения к программированию, это не получилось. Вот ссылка на советник, который я пытался модифицировать в нужный мне: https://www.mql5.com/ru/code/8463?source=terminal4_codebase

Я понимаю, что помощь мне требуется большая, задача не из лёгких, поэтому в виде бонуса подарю помогшим мне мои результаты исследований пары BTC/USD (биткойны/доллары) биржи btc-e. Я определил наиболее подходящий мувинг (чтоб поменьше ложных сигналов и вовремя срабатывал на хороших движениях), наилучшие параметры по нему (те самые проценты от хая/лоя свечи разворота), наиболее подходящие тейк-профиты. В эксельке считал сие. Экселька эта - с меня, в виде знака признательности. Может и вам пригодится.

Я не хочу тупо торговать по этому советнику. Он мне нужен, чтобы следил за рынком, когда я за ним не слежу (ибо круглосуточно следить не получается). А когда я у монитора, то торгую по линиям поддержки/сопротивления по определённой методике, но и при этом мне помогает система EMA - для определения точек пробоя уровней, выставления стопов.

Жду помощи в написании советника и на неё уповаю.

I will add one nuance: if there is a reversal of the moving average (for example, a reversal upwards), a position on the reversal is not opened (the price does not reach the high of the reversal candle + a certain %), then there is a reversal of the moving average, then the order to open a long remains in force. It remains at the same level until a new reversal occurs, with the high of the reversal being lower than the high of the first reversal. If the second reversal is higher than the high of the first reversal, the order to open a position on the low of the 1st reversal candle remains in place.

 
okidoki543:

Gentlemen, my request still stands (see page 369). I will repeat it here:

I will add one nuance: if there is a reversal of the muvinj (for example, its reversal upwards), the position on the reversal is not opened (the price does not reach the high of the reversal candle + a certain %), then there is a reversal of the muvinj, the order to open a long remains in force. It remains at the same level until there is a new reversal upwards with the high of the reversal candle being lower than the high of the first reversal. If the second reversal is higher than the high of the first reversal, the order to open a position on the low of the first reversal candle remains.


You have a good chance to make some real money when you have a good trade (that has been verified by experience and your wallet).

The order is not a good one. people write here and try to do something, not look for a freebie.

If you feel pity for money, earn on your idea:

- There are many contests and special promotions from different dts, if you trade well, you can make real money with nothing (tested by experience and my wallet).

 
vadynik:


I added the condition, but it is still going backwards)


not the right condition, you calculate the distance from the price to the price of the order, and you need from the price to the current stop!)

If a short is standing, then it is directed to the first block, if a long is standing, then it is directed to the second block, and then the trailing stops.

If short is on, then it goes to the first block, if long, then to the second, after that - calculations, checks and trailing.

 
ALXIMIKS:


Dear Sir, send your ToR to a special section of the forum, they will help and advise you.

Thank you for your prompting.
 
If anyone wants to help me (see above), I am open to collaboration.
 

Hi all. help to understand this situation.

why in one case, testF2, when I take Buf0[i]=iCCI(NULL,0,8,PRICE_OPEN,i-1)-iCCI(NULL,0,8,PRICE_OPEN,i); everything happens great as it should,

but in another case, testF1, with the same actions Buf0[i]=iMA(NULL,0,8,0,MODE_EMA,PRICE_OPEN,i-1)-iMA(NULL,0,8,1,MODE_SMA,PRICE_OPEN,i); the last bar is collapsed? why it does not happen in case of iCCI but iMA collapses??????

Is there any way to fix it?

Files:
testf1.mq4  1 kb
testf2.mq4  1 kb
Reason: