How to code? - page 108

IN10TION
237
IN10TION  
:: it will not work with indicators like that, even if you loop 1.000.000 times, it will stall everything else, nothing other then that loop will be processed, when the loop is finished then your terminal will continue her normal processes before a new tick.

:: in that 1.000.000 loop it's useless to check/control something else, that's why sleep() function doesn't work.

TheRumpledOne:
Hey, that's a good idea!

I could check the time and if X seconds or minutes have elapsed then exit the loop.

THANKS!!

P.S. This was not for an EA. I don't code EAs.
paco99
5
paco99  

Running a MetaTrader script from the command line

I want to be able to run a script or program from the command line that will execute a buy order. There aren't any rules. When I type it in from the command line, it should buy 1 EURUSD Long position.

How can this be done?

Thanks,

paco

bdht
24
bdht  

Simple arrow based indicator and EA

Hi, Everyone.

Recently I was trying to make a simple EA that would work on an arrow-based indicator. I am trying to make the EA to maintain one order at any given time. If the arrow points down, the previous buy order is closed and sell order is opened. If the arrow points up, the previous sell order is closed and buy order is opened. I am using the tester (visualization mode) to verify my code. It seems that no matter how I try, the EA does not close and open the positions when arrow indicator points up or down. The back test confirms that the EA is not working properly. Instead of opening and closing the orders at the arrow points shown by the indicator, the EA closes/opens order at some different time. I cannot understand why my code doesn't work.

In the beginning of start statement, I have the following code:

if (Time[0] == savedTime) {

return (0);

} else {

savedTime = Time [0];

}

This (I hope) will ensure that the code in the start statement is executed only when new bar has formed. Later in the body of the start subroutine, I query the indicator with iCustom function. The request looks as below:

iCustom (... 1)

The last argument of one specifies the previous formed bar, which is why it is not 0. Yet later I close the opened order with OrderClose and open new one with OrderSend. I suppose that both functions must be able to execute instantaneously.

The bottom line is: I am trying to create an EA based on arrow indicator. The indicator points either up or down. The way I see it (and I am probably incorrect), the only thing that I need to do is to close previous order and open new one when the next bar has formed. I would greatly appreciate any input into this problem.

Thanks to all.

auto_free_onetarmizi
227
auto_free_onetarmizi  

Anybody can tell me how to code for putting expiry date in the indicator?

Thanks.

Sergey Golubev
Moderator
117468
Sergey Golubev  
auto_free_onetarmizi
227
auto_free_onetarmizi  
newdigital:
Look at this thread https://www.mql5.com/en/forum/174194

Thanks for that link. Finally I was found the page that I'm looking for here

Dave137
212
Dave137  

How-To Get 2 Indicators on 1-seperate window??

Can somebody refresh my mind on how to get 2-indicators on one seperate window so they overlap each other??

Thanks for you assistance in advance!

Dave

ryan56
4
ryan56  

EA needed to open orders only

Hi All,

I was just wondering if anyone could help me create an EA that just opens 4 different orders at 00:00AM GMT for any pair.

1 lot buy

1 lot buy

1 lot sell

1 lot sell

to be opened all at 00:00GMT

thanks for assistance

Ryan56

auto_free_Eric_
1060
auto_free_Eric_  
bdht:
Hi, Everyone.

Recently I was trying to make a simple EA that would work on an arrow-based indicator. I am trying to make the EA to maintain one order at any given time. If the arrow points down, the previous buy order is closed and sell order is opened. If the arrow points up, the previous sell order is closed and buy order is opened. I am using the tester (visualization mode) to verify my code. It seems that no matter how I try, the EA does not close and open the positions when arrow indicator points up or down. The back test confirms that the EA is not working properly. Instead of opening and closing the orders at the arrow points shown by the indicator, the EA closes/opens order at some different time. I cannot understand why my code doesn't work.

In the beginning of start statement, I have the following code:

if (Time[0] == savedTime) {

return (0);

} else {

savedTime = Time [0];

}

This (I hope) will ensure that the code in the start statement is executed only when new bar has formed. Later in the body of the start subroutine, I query the indicator with iCustom function. The request looks as below:

iCustom (... 1)

The last argument of one specifies the previous formed bar, which is why it is not 0. Yet later I close the opened order with OrderClose and open new one with OrderSend. I suppose that both functions must be able to execute instantaneously.

The bottom line is: I am trying to create an EA based on arrow indicator. The indicator points either up or down. The way I see it (and I am probably incorrect), the only thing that I need to do is to close previous order and open new one when the next bar has formed. I would greatly appreciate any input into this problem.

Thanks to all.

If you look at your signal only once a bar and your "system" close and reverse when the signal change, it's important to check for exit BEFORE check for entry. If not, when a new entry signal is there, the EA can't enter the trade because the previous one is still open. And when the EA close the position, it will enter only at the next bar because it come in this part of code only once a bar.

Hope that make sense (with my english!).

FerruFx

Sergey Golubev
Moderator
117468
Sergey Golubev  
Dave137:
Can somebody refresh my mind on how to get 2-indicators on one seperate window so they overlap each other??

Thanks for you assistance in advance!

Dave

Look at this page: https://www.mql5.com/en/forum/172923