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

 
memo_mqlcom #: NOT evaluating all ticks toward the end of the candle close.
       if((time_in_candle % 100) == 0)

This assumes that there are ticks during each second of the day — they don't. What if there are no ticks during a specific period? There can be minutes between ticks during the Asian session.

static datetime lastAlert=0;
datetime prevAlert=lastAlert; lastAlert=TimeCurrent();
if(lastAlert - prevAlert >= 100) …
 

Thank you @William Roeder, I believe you identified the root cause! I wasn't even considering the possibility of 'no Ticks' within the time window that I define.

That said, I ran a quick test without the Alerts for EURUSD, and get almost no Ticks in unless I extend the trade window as large as an hour before the candle close -- which is not realistic (?)

I tried using OnTimer() to use time as a trigger, and it looks great, but unfortunately it doesn't work with StrategyTester :(

Any other ideas that I can try?

 

Hello! I am having trouble using Array Elements in Boolean Inequalities for If Statements.

I have 14 moving averages. Hardcoded, they crash MT4.

In an array they work. I can't use iMAOnArray because there is no Price parameter, which is absolutely necessary.

When I compare hardcoded MA's in an inequality statement, in this case for a If parameter, it is equated as True or False.

But when I compare MA's as Array Elements the same way, there is no pass.

So I'm at an impass. I can't hardcode the MA's because it crashes MT4. I can't use iMAOnArray because there is no Price parameter. And I can't use the Array Elements in inequalities.

I've tried parsing the Array Elements into integers, and no go.

I've tried equating a new variable to the Arrayed moving average, and no go.

What do I do?

 
William Roeder #:
  1. You are using a LWMA period of three.
              On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 programming forum (2012)
              build 2504 & 2506 Bug - General - MQL5 programming forum - Page 2 #17 (2020)

  2. The ENUM_APPLIED_PRICE PRICE_HIGH is two. Two+two/3000 =two=PRICE_HIGH

  3. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Code debugging - Developing programs - MetaEditor Help
              Error Handling and Logging in MQL5 - MQL5 Articles (2015)
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

Thank you!
 
memo_mqlcom #: @William Roeder, I believe you identified the root cause! I wasn't even considering the possibility of 'no Ticks' within the time window that I define.

The window that you defined was once second wide.

 

Some arrows disappear if I refresh the chart. The only thing I need is for it not to erase those arrows, to be as reliable when running the visual backtest. Could anyone give me a hand?

Files:
 
Zuko Lee #: Some arrows disappear if I refresh the chart.
  1. <deleted>

  2.       for(i=0; i<limit; i++){
             if(Buffer1[i] > Buffer2[i] && Buffer1[i-1] < Buffer2[i-1])
    Your indicator is repainting. It is comparing future buffer with the current. It is useless for trading.
 

I need some help, please.

I want to allow a user to change the colours of trendlines to his preferred colours.

I have tried various combinations of ENUM_OBJECT_PROPERTY_INTEGER, OBJPROP_COLOR and clrRed (for example) but I can't get it to work.

Could somebody help me with the correct code, please? 

Many thanks,

.

 
Buckets #:

I need some help, please.

I want to allow a user to change the colours of trendlines to his preferred colours.

I have tried various combinations of ENUM_OBJECT_PROPERTY_INTEGER, OBJPROP_COLOR and clrRed (for example) but I can't get it to work.

Could somebody help me with the correct code, please? 

Many thanks,

.

Post the code that you have tried.

 

This is one of the combinations I tried.

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH1=clrPaleGoldenrod;

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH4=clrBurlyWood;

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourD1=clrSaddleBrown;

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourW1=clrLawnGreen;

extern ENUM_OBJECT_PROPERTY_INTEGER OBJPROP_COLOR; int ColourH1=clrGreen;

Reason: