How to code? - page 25

 

Thanks ryanklefas for your reply.

I try to understand this and see if i can do something by myself!

FerruFx

 

I would guess that your EA eats up memory by creating "the same" label objects again and again. The culprit lines are then the ObjectCreate calls, like

ObjectCreate("Trend_MAfast_5", OBJ_LABEL, WindowFind("xxxxxxx"), 0, 0);[/PHP]

I suggest you wrap those lines into conditional creation, like

[PHP]if ( ObjectFind( "Trend_MAfast_5" ) == -1 ) {

ObjectCreate("Trend_MAfast_5", OBJ_LABEL, WindowFind("xxxxxxx"), 0, 0);

}

so that you re-use the existing objects if they are created already.

Do the same for all ObjectCreate.

 

Thanks ralph.ronnquist!

 

"buy limit order" and "sell limit order" code

Can someone post code for "buy limit order" and "sell limit order" that can be used in an EA.

 

OrderSend(Symbol(),OP_BUYLIMIT,lots,limitprice,slippage,stoploss,takeprofit,"comment",magic#,expiration_time,arrowcolor)

Replace OP_BUYLIMIT with OP_SELLLIMIT for the sell limit order.

Replace each word with the values you choose.

 

i need the code for this indicator!

hi all

i need the code for this indicator(ADX crossing)

i try this code

iADX(NULL, 0, 14, PRICE_CLOSE, MODE_MAIN,0);

but i think there is problem in

 

double iADX( string symbol, int timeframe, int period, int applied_price, int mode, int shift)

this one?

double iADX( string symbol, int timeframe, int period, int applied_price, int mode, int shift)

Calculates the Movement directional index and returns its value.

Parameters:

symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.

timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.

period - Averaging period for calculation.

applied_price - Applied price. It can be any of Applied price enumeration values.

mode - Indicator line index. It can be any of the Indicators line identifiers enumeration value.

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

Sample:

if(iADX(NULL,0,14,PRICE_HIGH,MODE_MAIN,0)>iADX(NULL,0,14,PRICE_HIGH,MODE_PLUSDI,0)) return(0);

see http://docs.mql4.com/indicators/iADX for more

 

hi Shinigami

i dont understand any thing!

can you give me the code for the indicator in Attachment?

Files:
 

There is no need in that. I posted the way you should use the iADX() function

If you don't code its okay not to understand. If you are trying to write an EA, you should be able to understand syntax...

I'll be a bit more specific (if you didn't look into that link)

usage:

iADX(NULL,0,14,PRICE_HIGH,MODE_MAIN,0

NULL as current symbol

0 - current time frame, you can use M1 M15 H4 or whichever you like, you need a window with that period open for running a forward test and quotes history for a backtest, see sticky threads for backtesting modeling quality.

14 - period in bars back from current bar. You calculate iADX for that period. In this example you use 14 bars back from this bar, current bar's number is 0(!)

PRICE_HIGH - Applied price constants. It can be any of the following values:

Constant Value Description

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

(see http://docs.mql4.com/constants/prices)

MODE_MAIN - http://docs.mql4.com/constants/lines you'll find all the information there, hard to explain, never used it before. Basically its

Constant Value Description

MODE_MAIN 0 Base indicator line.

MODE_PLUSDI 1 +DI indicator line.

MODE_MINUSDI 2 -DI indicator line.

0 in the end is shift. If you wish not to use current bar to start calculations, but would like to shift back few bars, use this number. 5 will mean you ignore last 5 bars including current and start calculation of iADX based on 14 previous bars.

I hope that helps...

See links for more information, I just LOVE that resource.

Oh and the code there is colored just like in metaeditor, very useful!

And I really don't understand what you don't understand... Its pretty damn clear in the posted indicator and its quite simple too...

 

Trailing stop code needed

Does anyone have code for a good trailing stop? I'm looking for something that gets progressively tighter as it gets deeper in profit. Thanks.