I have never studied programming, but I want to write an EA - page 2

 
Vladimir Karputov:

Just reading the reference without setting the objectives (even if very simple) does not do anything. It's like learning karate by looking at pictures lying on the sofa :)

The reference is exactly the point, with examples. Textbooks for dummies, like how to get mail on 280 pages is a waste of time. everything can be explained in 10-15 minutes

 
Sergey Lobzankin:

I've never studied programming, but I want to write an EA.

Talk to the pros. Don't spare any money for good ideas. Everyone should be in their place.

 
Sergey Lobzankin:

good afternoon boys and girls,
here are some variables globally
I want to get the opening prices in the log.



but I'm getting some strange nonsense.
What's wrong?



like this:

datetime prevdaytime; // здесь храним время предыдущего дня
datetime  time[];      // сюда будем получать новое текущее время
double open[];        // сюда будем получать текущие цены открытия
//+------------------------------------------------------------------+
void OnTick()
  {
   CopyTime(_Symbol,PERIOD_D1,0,1,time); // получаем время дневного бара

   if(time[0]!=prevdaytime) // если время дневного бара отличается от предидущего
     {
      CopyOpen(_Symbol,PERIOD_D1,0,1,open); // копируем новую цену open  
      Print("Time: ",TimeToString(time[0],TIME_DATE)," |  Price Open: ",DoubleToString(open[0],_Digits)); // выводим в журнал
      prevdaytime=time[0]; // запоминаем последнее время нового бара
     }
  }
//+------------------------------------------------------------------+
 
Can you tell me the best way to do it?
Should the trailing stop be written as a separate function or should it be added to the existing OrderModify function?
 
Morexod:

sounds something like this.

I've never studied surgery, but I want to do surgery, so here's an axe, a drill and a file. What's wrong with that?

Yeah, I'm currently being tormented by one guy in VK. He cannot program, but wants to write a scalper. He says he is going to make a program out of pieces from other programs.

And then there's the customer, he's decided that if you change all the pros to minuses and vice versa in the EA, he'll stop leaking and start chopping cabbage ))

 
Sergey Lobzankin:
Please advise how to do it better?
Should the trailing stop be written as a separate function or integrated into the existing OrderModify function?

As a separate function, of course. There are good examples in the kodobase. In general, there is a rule that if some piece of code performs a meaningful action, it must be implemented in a separate function.

You can write a 100500-screen sheet in OnTick and then you feel like spitting from this rubbish spaghetti code.

 
Guys, well, I think I've picked up a few things



I still have a lot of work to do, but all in all, it feels good.
Thanks for the tip on a few things,
 

Off topic:


Sergei, how did you publish the signal ? is it purely manual trading with improvised means ?

 
Sergey Lobzankin:
Guys, I think I've got something



, of course, I still have a lot to polish, but in general, it is nice.
Thanks for your comments here and there,

So, the man does not know programming, but has written an Expert Advisor. And we are panting here, studying MQL for some reason ))

 

that's better :)