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

 
Hello friends!

I want to know if could be possible to code a script that add sell and buy buttons with fixed stop lost and take profit on MT4's charts.

any help or genuineness will be very appreciated.   
 
_stealth #: I want to know if could be possible to code a script that add sell and buy buttons with fixed stop lost and take profit on MT4's charts. any help or genuineness will be very appreciated.   

Yes it is possible!

  • Usually people who cannot code do not receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
 

How should i solve this problem?

I have 100 variables with the name indexed (like buffer_1, buffer_2, buffer_3 etc), and i want to do a "for" cycle on them.

like:

for (int i=0; i=99; i++)
{
switch (Buffer_i)
{
case x: Do stuff with Buffer_i; break;
case y: Do other stuff with Buffer_ i; break;
} //switch
} //for

Of course this doesnt work.

I am sure im missing a function like integertostring or i dont know, but i cant make it syntactically right.

I have checked like 100 codes but everyone only indexing arrays :( And i have read i cant put variables into arrays...) 

So how should i do it?

Thank you in advance :)
 
@Laszlo Basso #: How should i solve this problem? I have 100 variables with the name indexed (like buffer_1, buffer_2, buffer_3 etc), and i want to do a "for" cycle on them.
I am not sure what you want to do, but if you want to index the buffers dynamically, then either use a two dimensional array, or if these are indicator buffers, then use an array of a structure that has the buffer as a member variable.
 

Those were just name of the variables, but i guess it wasnt a fortunate choice :) It could be ema_period_1, ema_period_2, etc, or anything like this

I would use a two dimensional array, but it wont let me add variables, as i get "constant expression required" error message.

Basically i just want to run a for cycle on a bunch of indexed variable, and i dont know how to use "i" as a dynamic index.

Like this:

for (int i=0; i<=x; i++) // x=number of variables in total
{
switch (EMA_Period_i) // where "i" would be the index, but ofc I got the message EMA_Period_i is not defined.
{
case 2: SetIndexStyle(i, DRAW_LINE,STYLE_SOLID,2,clrDarkViolet);break; //"i" would be the index of the indicator buffer here
case 4: .....
case 20:...etc
 
} //switch
} //for
 

@Laszlo Basso@Galore Fire

You are not allowed to have more than one MQL5 Community Account.

Please choose one and have the other deleted, by contact the Service Desk with a deletion request, or you could risk being banned on both accounts.

 
Fernando Carreiro #:

@Laszlo Basso@Galore Fire

You are not allowed to have more than one MQL5 Community Account.

Please choose one and have the other deleted, by contact the Service Desk with a deletion request, or you could risk being banned on both accounts.


Sorry this was an accident, i will delete my other profile tonight.

About my question, should i create its own thread?

 

I wrote an expert in MQL 5, which downloads this html page 

and parses it.

For debugging i added a lot of print messages like this:

PrintFormat("The file has been successfully downloaded, File size %d byte.",ArraySize(result));

When i started the expert from MetaEditor, the file was downloaded, and the messages were shown in the journal.

I made some changes for linkage to the MetaTrader, and now when i start the expert agan, the file is downloaded, but no more messages are shown.

Does anybody has any idea how i can see again the print messages in the journal again?

The logic is added in the onInit() method.

Now i started the expert again and all i see in the journal are the following messages:

MQL5 debugger starting 'my_fourth_EA.ex5' on history

MQL5 debugger connected


Thanks, 

Ivaylo

 
Comments that do not relate to this topic, have been moved to "[Alberto Tortella] I need an help in recall BUY and SELL STOP orders".
 
I have 5 separate mql4 indicators.  Can you put all 5 indicators in one mql4 file? One of the indicators I only have the .ex file?

Thanks