Please don't post randomly in any section. Your question is not related to the section you posted.
MT4/mql4 has it's own section on the forum.
I have moved your topic to the correct section, so please don't create another topic.
I have recently created a custom indicator in MT4. It works fine on my charts, but when using iCustom inside an EA it will not fetch the values and returns the max int value of 2123237 or whatever the standard is for empty value. The indicator code is attached below:
And for further reference, the code for the EA i am trying to create is also below:
I am pretty new to coding so I'm sure its something simple, however I cannot seem to figure it out and don't understand what would cause this. When I add the print functions, it prints:
And then just repeats over and over, not accessing the indicator values but shows them perfectly on the chart when running the strategy tester. It appears I am having an issue with the custom 'velocity' indicator as well, however that one is just repeating 0.0 instead of the 214xxx number. If anyone could figure out what is going on and give me a hand with this, I would be eternally grateful. This has been a huge headache. As I stated I am new to this so I would like to know what I am doing wrong and how I can prevent this from happening with future projects.
Thank you!
if you edit all comparisons accordingly, the problem is solved. You edit the remaining code. Example
if(bullish_distance!= 2147483647.0 && bullish_distance>0) ....
-
if(bullish_distance!= 2147483647.0 && bullish_distance>0) ....
Do not hard code numbers. Use the provided symbols (EMPTY_VALUE).
-
double sl = Ask - (Stop * _Point); double tp = Ask + (Profit * _Point);
You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.
-
Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?
-
Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close at a specific Bid price, add the average spread.
MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25 -
The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes.
My GBPJPY shows average spread = 26 points, average maximum spread = 134.
My EURCHF shows average spread = 18 points, average maximum spread = 106.
(your broker will be similar).
Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)
-
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
And for further reference, the code for the EA i am trying to create is also below:
I am pretty new to coding so I'm sure its something simple, however I cannot seem to figure it out and don't understand what would cause this. When I add the print functions, it prints:
And then just repeats over and over, not accessing the indicator values but shows them perfectly on the chart when running the strategy tester. It appears I am having an issue with the custom 'velocity' indicator as well, however that one is just repeating 0.0 instead of the 214xxx number. If anyone could figure out what is going on and give me a hand with this, I would be eternally grateful. This has been a huge headache. As I stated I am new to this so I would like to know what I am doing wrong and how I can prevent this from happening with future projects.
Thank you!