How to code? - page 128

 

Could someone please tell me the code I need to make the EA open trades quicker. For some reason my EA may open a trade 1 minute or two later. Just wondering what code to add to have the EA check trade conditions more often. I have EachTick = True but that is at the very beginning of the EA. Should that be changed?

How do I add more loop subroutines?

Thanks

 
matrixebiz:
Could someone please tell me the code I need to make the EA open trades quicker. For some reason my EA may open a trade 1 minute or two later. Just wondering what code to add to have the EA check trade conditions more often. I have EachTick = True but that is at the very beginning of the EA. Should that be changed?

How do I add more loop subroutines?

Thanks

If the EA check already each tick, your issue may be that some pairs are very quiet and have ticks spaced by minutes sometimes.

FerruFx

 
 

Looping without Freezing MetaTrader

I have an EA (or perhaps it should be a script) that needs to continously loop and monitor current orders. What is the best method to do this such that it won't lock up MetaTrader?

 
dwmcqueen:
I have an EA (or perhaps it should be a script) that needs to continously loop and monitor current orders. What is the best method to do this such that it won't lock up MetaTrader?

Use a sleep function at the end of your loop.

Example:

while (OrderProfit() < 999999)

{

Code you want to loop here;

Sleep(1000);

}

Sleep(1000) will give you about a 1 second delay. I have had success with this in experts. It DOES NOT work in indicators, I'm not sure why.

Hope this helps.

 

Why can't I pull the values from an indicator

I'm attaching a blank EA that will put the values, or so I thought, of the indicator in a comment section.

The indicator in question is TrendStrength_v2.mq4. I can't post it because it belongs to Igorad and I don't have his permission. But, in the secure forum where he posted it ( I don't remember where ) is the source code.

Igorad, if you need it, let me know. I can get it to you.

I'm trying to pull values but All I get are the same values over and over again. put the EA in a backtest just to grab values and you'll see what I mean.

If anyone has this indicator, are you getting the same problems?

Any help would be great!

THANKS IN ADVANCE!

Files:
blank_ea.mq4  3 kb
 

Retracement: piece of code needed

Hi All,

I wonder if somebody has a piece of mql coding (or help me to make it ) for retracement implementation.

Here is what I need exactly (for BUY).

Let's have 15 min chart, shouldn't matter actually and a High for period from T1 to T2. Now, my current price is equal to that High, but I don't want to enter that breakout because I'm smart and want to wait for price's retracement (pullback). Then the future price makes a new High I'll wait for next candle to open and then that new candle makes another new High only then I enter.

What worries me in coding is obviouosely I want everything to be happened withing several candles. If price goes all a way down (opposite direction) and then back up I don't want that breakout triggered at all.

I probably want too much.

Thanks,

Orest

 

TrendStrength availbility

Is this version (or any newer ones) available in the Elite section? Or the public section?

Flytox:
It's TrendStrength v2.2
 

How does one add the LSMA to EA'S

I am new to this code writing stuff. But the EMA Cross.mq4. only use the EMA as is its trend. How can I add or change the trend to the LSMA? This trend indicator seems to be more reliable than the EMA or the others that are offer in the MQ4 language. Where does one find the code for this LSMA and where do you place it in the code. I would like to add the LSMA to this EA also. The 100 pips. Any ideas? Here is some of the code for the 100 pips. I beleive that this is where the EA find the trend.

if(timeframe==0) {timeframe=Period();}

double diClose0=iClose(Symbol(),timeframe,0);

double diMA1=iMA(Symbol(),timeframe,7,0,MODE_SMA,PRICE_OPEN,0);

double diClose2=iClose(Symbol(),timeframe,0);

double diMA3=iMA(Symbol(),timeframe,6,0,MODE_SMA,PRICE_OPEN,0);

As you can see the 100 pips uses the SMA. How do we change that to the LSMA the language does not support that indicator or does it? Iam lost.

Moving Average calculation method used with iAlligator(), iEnvelopes(), iEnvelopesOnArray, iForce(), iGator(), iMA(), iMAOnArray(), iStdDev(), iStdDevOnArray(), iStochastic() indicators.

It can be any of the following values:

Constant Value Description

MODE_SMA 0 Simple moving average,

MODE_EMA 1 Exponential moving average,

MODE_SMMA 2 Smoothed moving average,

MODE_LWMA 3 Linear weighted moving average.

 

Here are the EA's I was talking about in the previous post. The one is Ema Cross and the other is 100 pips

Files:
Reason: