What indicators do not redraw themselves??? - page 2

 

Here is timer code from UniversalMACrossEA.mq4

//----------------------- TIME FILTER

if (UseHourTrade)

{

if(!(Hour()>=StartHour && Hour()<=EndHour))

{

Comment("Non-Trading Hours!");

return(0);

}

}

It seems to work well.

https://www.mql5.com/en/forum/general

Files:
 

That is good for one time period. I need 3 time periods. How do you code 3 time periods so it will work??

Dave

 

Hans123Trader has 2 timers and a third could be added. My timer would need only 1 with a setting of 3 am-12 am NY time. Most trading is done then.

Files:
 

I will tell with all my experience, this is one messed up language. This takes the cake! A simple ' or ' statement would work in other languages. Leave it up to the programmers of this language to make our lives difficult.

Any other suggestions that could use my original coding versus a bunch of if, else conditional statements. This complicates the dung out of my coding. I am not that strong a coder.

Just don't get me started about the compiler error troubleshooting. Most of the time it basically says you got a problem, and lets you figure out where it is - big help! Talk about low level language programming like I used 30 years ago!! It may be powerful, but it lacks bigtime in various areas. It's about one step above assembly language. I think RadioShack came out with the TRS model 80 back then.

 

A Friend coded this for me - Works great!!!

if (UseHourTrade)

{

int a=0;

int b=0;

int c=0;

if(!(Hour()>=FromHourTrade1 && Hour()<=ToHourTrade1)) a=1;

if(!(Hour()>=FromHourTrade2 && Hour()<=ToHourTrade2)) b=1;

if(!(Hour()>=FromHourTrade3 && Hour()<=ToHourTrade3)) c=1;

if(a==1 && b==1 && c==1)

{

Comment(

"\n"," * SOLAR WIND EXPERT ADVISOR *",

"\n",

"\n", " - PROGRAM IN SLEEP CYCLE - ",

"\n",

"\n"," > NON-TRADING HOURS! <");

return(0);

}

}

Note: Unfortunately, the solarwind indicator is useless to write an EA from - It repaints itself! All indicators that have ++ used in the logic loop are virtually useless to try to write an EA for, because they all repaint themselves and that messes up the EA timing and optimization. They may be ok visually, but they don't work well in an EA. Most indicators do repaint themselves. You must use an indicator that has -- in the logic loop, and even then other conditions can mess up a EA. This is why so many EA's end up not working!!!

Dave

<<<

 
I have a strange feeling that this one will be changing past. Why?

Here is the explenation: Code:

for (shift = CountBars; shift>=0; shift--)

So u count from left side of the screen to right. So lets say we have 2000 bars on the chart. The first index (shift) will be 2000 second 1999 next 1998 and so on. Let's continoue.

Code:

if( High[shift-1] > High[shift] && Low[shift-1] > Low[shift] && uptrend != 3)

Let's say that we are on bar that is indexed as 0 (current bar). How the conditions would look like ?

Code:

if( High[0-1] > High[0] && Low[0-1] > Low[0] && uptrend != 3)

So, to do that - metatrader should look in the cystal ball and predict the future. But wait till we close bar :

Code:

if( High[1-1] > High[0] && Low[1-1] > Low[0] && uptrend != 3)

now we compared the same bar but after the next bar was closed:

Code:

if( High[2-1] > High[0] && Low[2-1] > Low[0] && uptrend != 3)

Now we are changing the past

If u want to have indicator that will not change the past u should code it like that:

Code:

if( High[shift+1] > High[0] && Low[shift+1] > Low[0] && uptrend != 3)

https://www.mql5.com/en/forum/174919

Reason: