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

 
void OnTick()
  {
      double ma = iMA(Symbol(),PERIOD_CURRENT,21,0,MODE_EMA,PRICE_CLOSE,0);
      double price = Close[1];
      

            if(price>ma && CountBuy() == 0)
               {
                     int ticket = OrderSend(Symbol(),OP_BUY,lot, Ask, 5,Ask - sl*Point,Bid + tp*Point,NULL,magic,0,Red);
                     
               }
   }

Good afternoon everyone, can you please help me to solve this problem, the problem is in logic, I've broken my brain today and I've come to the point where I'm in a mess.

I have written an elementary code sample, there is a signal if candle's close is bigger than waggon, one order is opened.

The signal will stay and stay true for a long time. I am sure you know what I mean,

As a matter of fact, how should I make a signal to buy open one order and that's it, until the situation changes and the close price is lower than the Mask.

 

I need help in writing an EA.

I need an EA whichopens a positionon a match of 2 MA andMACDdivergence (convergence)crossover.We need an EA with TP and SL. The code should be as simple as possible.

Совершение сделок - Торговые операции - Справка по MetaTrader 5
Совершение сделок - Торговые операции - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая деятельность в платформе связана с формированием и отсылкой рыночных и отложенных ордеров для исполнения брокером, а также с управлением текущими позициями путем их модификации или закрытия. Платформа позволяет удобно просматривать торговую историю на счете, настраивать оповещения о событиях на рынке и многое другое. Открытие позиций...
 
a.lxrn:

Good afternoon everyone, can you please help me to solve this problem, the problem is in logic, I've broken my brain today and I've come to the point where I'm in a mess.

I have written an elementary code sample, there is a signal if close of candle is more than waggon, one order is opened.

The signal will stay and stay true for a long time. I am sure you know what I mean,

If I want to open one order in such a way, when I get a buy signal, it should be done until the situation changes and the close price is lower than the price of the Machka.

Your task is not phrased correctly, hence the lack of understanding how to do it.

the problem should look like this: on bar 1, there is a "buy signal", while on bar 2 there is no such a signal - it means it is a buy signal

respectively there will be a prohibition on reopening and a prohibition to trade "in the middle of the signal".

 
Igor Makanu:

You have the wrong task, hence the lack of understanding of how to do it.

The task should look like this: on bar 1 there is a "buy signal", while bar 2 has no such signal - it means it is a buy signal

respectively, there will be a prohibition on reopening and a prohibition to trade "in the middle of the signal"

I do not quite understand. The first bar has closed, the close price is higher than the Mach number, it means that we open an order and let's assume the order has closed at the Take price and its close price is also higher than the Mach number.

What has the second bar got to do with it? I cannot understand, maybe orders should be considered by one signal?

 
ANDREY:

Thank you for the valuable information.

Regarding the mathematical mindset. Since I'm from scratch .... albeit too long .... I have mastered Kovalev's textbook to some extent, and even learned to write primitive codes which compile without errors, and even coded something similar to "grail" ..... it means that my mindset is changing in the direction I need..... as it seems to me.
Please tell me if it's OK ... Can you run MQL5 functions in MetaEditor 4?

Thank you

Here is a classic example of a non-mathematical mindset.

Forum on trading, automated trading systems & strategy testing

Any MQL4 and MQL5 beginners questions, help and discussion on algorithms and codes

a.lxrn, 2020.07.11 14:14

void OnTick()
  {
      double ma = iMA(Symbol(),PERIOD_CURRENT,21,0,MODE_EMA,PRICE_CLOSE,0);
      double price = Close[1];
      

            if(price>ma && CountBuy() == 0)
               {
                     int ticket = OrderSend(Symbol(),OP_BUY,lot, Ask, 5,Ask - sl*Point,Bid + tp*Point,NULL,magic,0,Red);
                     
               }
   }

If i've already started working on this problem, i already tried to open it and i've already lost my mind.

I have written a simple code sample, there is a signal if candle's close is bigger than waggon, one order is opened.

The signal will stay and stay true for a long time. I am sure you know what I mean,

As a matter of fact, how should I make a signal to buy open one order and that's it, until the situation changes and the close price is lower than the Mask.

a.lxrn: nothing personal, no offence meant. No offence taken.
 
a.lxrn:

I don't quite understand, the first bar closed, the closing price is higher than the bag, it means that the order opens, let's say the order closed at the point, and its closing price is also higher than the bag.

What has the second bar got to do with it? I cannot understand, maybe orders should be considered by one signal?

Change the condition, it was less and became more, so it is a buy signal.
 
Alexey Viktorov:

Here's a classic example of a non-mathematical mind-set.

a.lxrn: nothing personal, no offence meant. Don't be offended.

)))) I am not a child to be offended)) I did not go to math school) I am more of a humanitarian, but everyone starts somewhere and gets dumb like me)) that's why I am asking for help

 
Alexey Viktorov:
Change the condition, it was less and became more, so it's a buy signal.

with an example, please?

 
Anton Tsygvintsyev:

I need help in writing an EA.

I need an EA whichopens a positionon a match of 2 MA andMACDdivergence (convergence)crossover.We need an EA with TP and SL. The code should be as simple as possible.

Can you help me?

 
a.lxrn:

with an example, please?

 if( (  Close[1] > ma && Close[2] <= ma )  && CountBuy() == 0)
thebrackets can be removed, I wrote the terms for easy reading
Reason: