Ask! - page 149

 
abundance:
... It says there can be one test expression only...

the expression may be a complex one using some logical operator. Example:

for(i=0; i<10 && a+i<15; i+=2)
 

TSF Indicator

Hi, how can i pick data from an indicator from an expert advisor?

I use a third-party TSF indicator and i wanto to use the values on my automate ea to make trading.... how can this be done?

I tried to take the code of the indicator to the ea, but for some reasons this does not work well...

Thanks.

 
Michel:
the expression may be a complex one using some logical operator. Example:
for(i=0; i<10 && a+i<15; i+=2)

Thank you. I cld understand what you said. But the two examples given in the lesson I quoted don't seem to fall into this category. There is a comma between i<15 and i0 and i<. I suspect there was typo error. What do you think? Need to get it out of the way to proceed further. Thx.

 

Thanks Lux and thank you Wolfe for your specific code. I am not good with code yet, but had found a specific example on the web that I already worked into EA:

int ExOrdersTotal(int MagicNumber)

{

int total = OrdersTotal();

int extotal = 0;

for(int cnt = 0 ; cnt < total ; cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if ( OrderMagicNumber()==MagicNumber)

extotal++;

}

return (extotal);

}

I get an Error code:

"("- function definition unexpected

and have already defined MagicNumber

I have the EA set up on 5 pairs (with different magic numbers), but still no trades. I am beginning to suspect something is wrong.

These EAs are modified from Gordago's Elder 3X screens

which were modeled after MT4 MACD Sample. I have always had trouble with multiple pairs and orders with EAs that are modeled after these, but the Gordago has shown good backtesting results (I have had to modify code for optimization).

I will try with yours Wolfe, if I don't see a trade soon.

Thanks

Chili

 
JForex78:
Totally makes sense. How will you see a M5 10MA on a H1 chart?

10/12=0.84. Can you put a 0.84 MA on a H1 chart? No.

It works the other way though - H1 10MA = M5 120MA.

So my question is, how do I see a cross of 5MA on a higher Timeframe like H4.

Thanks.

You could use the iMA function and write your own MA indicator. Just set the time frame to H4 and drop it on your 5M chart. You'd have to do some extra coding to draw the same level for every 48 5M bars too. Not sure how much help an indicator like this would be but haven't looked at it too much.

Lux

 

Indicator crashing MT4

(Orginally posted in the Digital Filters/ Jurik thread)

Hi folks, I'm in desperate need of some coder assistance.

I've been loving these Jurik tools, but I've hit a wall and my hair is coming out in clumps trying to get past this... The real killer is that this code initially worked, then as I developed a bit more it all went wrong and now I can't even revert without drama.

The situation is this: I took the JMA and patched together a MTF indicator based on the iMax MTF I found here - sorry I can't remember who wrote that one, but thanks, it's sweet. It worked fine until I got a bit clever and tried to incorporate two JMAs with different length into the calculation. The two versions are below.

Ever since I made the second mod this indicator and some others, plus an EA with JMA in it cause MT4 to crash immediately and even commenting out all the JMA doesn't help.

All the JMA indicators from here still work fine, so that suggests to me it's an issue of the code rather than the JMA - well, obviously... Hopefully it's either the way I'm calling the JMA function (although it worked before) or there's some fatal error like an infinite loop or whatever. It compiles, but crashes MT4 straight away...

The first attachment is an old version and it works, so you can see what I'm trying to do - but I don't have that mq4 any more, sorry. The current mq4 'should' be the same, but crashes, and the real indicator I'm trying to achieve is the final file, JMA2- which also crashes. Come on gurus, I'm crossing my fingers,

rjc.

 

I will try with yours Wolfe, if I don't see a trade soon.

Thanks

Chili

Good luck Chili.

 

Programming SundayStartUp of EA

Variables used - StartDay=0, StartHour=5, StartMinute =30.

if(UseSundayStartup==true)

{

if (!(Day()>=StartDay))

{Comment("Day Start Time Not Yet!");

return(0);}

else if(!(Hour()>=StartHour))

{Comment("Day Start Time Not Yet!");

return(0);}

else if(!(Minute()>=StartMinute)){

Comment("Day Start Time Not Yet!");

return(0);

}

}

It works ok to start the Sunday. Problem happens that if I need to or have to reboot the system during the week for whatever reason, the system returns to the Comment("Day Start Time Not Yet!").

I have not been able to resolve this problem - Any suggestions on code to allow the program to run if rebooted at a later date with a earlier Hour and Minute??

Dave

 

Take a look at global variables or you could write to a file.

Lux

 
Reason: