How to code? - page 107

 

It's an EA, not an indicator, you should not mix both.

 

hi all..

It's an EA, not an indicator, you should not mix both.

actually, i take some code from MACD indicator and from that i make an EA.. can someone help me which code should i correct it??

thanks..

 

Try looking at a few of the EA's you already have. Study the code and try to see if you can figure out some of the logic. Try speaking the flow of the program out loud. It helps a lot!

Good Luck

Lux

 

hi all..

thanks luxinterrior for the reply..

Try looking at a few of the EA's you already have. Study the code and try to see if you can figure out some of the logic. Try speaking the flow of the program out loud. It helps a lot! Good Luck

i have 7 buffer.. buffer1 until buffer7.. each buffer will save MACD bar value.. the EA will open

BUY post when the MACD become 'u' shape..

the condition when..

if (MacdBuffer7>MacdBuffer5&&MacdBuffer5>MacdBuffer3&&MacdBuffer3>MacdBuffer1

&&MacdBuffer1<MacdBuffer2&&MacdBuffer2<MacdBuffer4&&MacdBuffer4<MacdBuffer6) [/CODE]

SELL post when the MACD become 'n' shape..

the condition when..

[CODE] if(MacdBuffer7<MacdBuffer5&&MacdBuffer5<MacdBuffer3&&MacdBuffer3<MacdBuffer1

&&MacdBuffer1>MacdBuffer2&&MacdBuffer2>MacdBuffer4&&MacdBuffer4>MacdBuffer6)

hope anyone can help me solve the problem.. thanks..

 

Is there a way to force the program to calculate?

Right now it waits for the next tick.

I have 6 charts open and the same indicator is on all six charts.

If one chart receives a tick, it updates but the other charts don't so they are "stale".

Thanks.

 
:: if it's suitable then try to form it in a EA, there you can loop & use sleep function, I've tried several simple setups to have only processes/calculations not related to ticks, but then you have the refresh screen issue ... so ... I've changed everything back to normal ... the importance to do so was not that great ... perhaps in MQL5 coming up

:: indicators can't deal with sleep() function

:: you can write a dll, fetch all the windows in your terminal... then do/send a "refresh screen/window" to every child window. But then you have to send dll file together with your indicator to others ... again ... making it complicated ...

TheRumpledOne:
Is there a way to force the program to calculate?

Right now it waits for the next tick.

I have 6 charts open and the same indicator is on all six charts.

If one chart receives a tick, it updates but the other charts don't so they are "stale".

Thanks.
 

Hi there,

I hope you don't mind me butting in here, I'm looking at a similar situation and I have a thaught on the issue... what about if you code a loop at the end of your program that says "if no order is open run through again". and let it loop maybe 3 or 4 times.

If it does that then any missed orders (which happens quite often) should surely get picked up. or is there something wrong with my thinking.

I think it would look something like this...

for (int k = OrdersTotal() ==0; k >=2; k++)

{

if ( ! OrderSelect ( k, SELECT_BY_POS, MODE_TRADES ))continue;

if (k > 2) break;

}

return(0);

}

I'm still new to this so if it doesn't make sense please explain to me why.

 

To Lux, ajk, Raygun, Devil2000, IN10TION

Thanks for the tips.

I will try them and I hope come up with the answer.

I will post later.

Big Be

 
amatrader:
Hi there,

I hope you don't mind me butting in here, I'm looking at a similar situation and I have a thaught on the issue... what about if you code a loop at the end of your program that says "if no order is open run through again". and let it loop maybe 3 or 4 times.

If it does that then any missed orders (which happens quite often) should surely get picked up. or is there something wrong with my thinking.

I think it would look something like this...

I'm still new to this so if it doesn't make sense please explain to me why.

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.

 
:: 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.
Reason: