How to code? - page 281

 

EA properties

I have a question that someone may have found an answer to. I have noticed some EAs will not display the properties window once loaded onto a chart and some EAs take several goes before the property window pops up while with other EAs the properties window pops up straight away. This happens no matter which way I try to access the EA properties - right click Expert Advisors then properties / left click on the smiley face or F7. Its got me puzzled however there is probably an obvious answer to this that I am not aware of. Thanks for any insight into this.

Regards CJA

 

Try This

ObjectDescription( string name)

Return object description. For objects of OBJ_TEXT and OBJ_LABEL types, the text drawn by these objects will be returned.

 

worked

Thanks very much! That worked. Horrible tutorials and help for mql!!

 
g.pociejewski:
[lang=pl]I'm an author. I attache mq4 file for Avasys. I dont who change in the code function isGoodTime. In my terminal its working. Avasys why you so nervous ?? If you have problem just contact me instead of talking about this on the forum.[/lang]

I figured it out

EA works fine

thanks

 

S&P500 help

Hello everybody. I am fairly new to metatrader programming (only a month or two), but I have been programming in NinjaTrader for about 4-5 years. I have a simple strategy that trade the S&P, Light Sweet Crude, and EURUSD that I have adapted to work on MT4. Besides of few minor changes it is finished. It runs perfectly on EURUSD and Crude, as well as whatever forex pair I put it on for testing. The problem is on the S&P. I guess you need a little background on the strategy for the problem to make sense. It is a pretty simple time breakout strategy. It calculates the High and the Low of a certain period of time, and when a bar close above or below this point it takes a trade (long if above, short if below). So lets assume it closed above and went long. If a bar closes below the low, it closes out the long and goes short at 2x the lot size and tries to make back everything it lost and the original target. It keeps reversing until either target is finally hit, or it has reversed x amount of times (which is set by an external variable). Now, everything as far as I can tell works fine. It takes the trade and doubles as it should and when it hits target it made back all it's loss and also the original target. On the S&P however, every now and then when it hits target it is pretty much break even. It makes back what it lost more or less, but does not make any profit. How I have this in the code is it stores the point value of the target in a double variable named slip. When it reverses, after it closes the trade it takes the Open price - the close price (if long) or close price - open price (if short) adds that to slip, then divides slip in half. In code: slip = (slip + (OrderOpenPrice() - OrderClosePrice()))/2; then it rounds it so that it is a usable price. Since the S&P moves in .25 increments, NormalizeDouble will not work on it, so my work around is to convert it to ticks, then normalizedouble so it is a whole integer, then turn it back into point value. In code:

slip = NormalizeDouble((slip / point), 0);

slip= NormalizeDouble((slip* point), Digits);

So you know, point is a variable that = Point or if it is on S&P = 0.25 (since S&P moves in .25 increments, but my broker at least reports Point as .01)

I believe that the problem would have to be in those 2 little bits of code because the target is OrderOpenPrice() + slip (if long). Any thoughts or suggestions will be GREATLY appreciated.

 

Indicator on Array

I am looking for a solution to apply indicators algorithmics on array of prices.

in MQL4 some indicators has this function, such as: iCCIOnArray, iBandsOnArray...

But indicators such as ADX does not have such function.

Anyone have idea of how I may apply indicator calculation over pre-defined array (not from quotes server)?

 

Meaning of IsTradeAllowed() function

Hi,

I have written an ea which has the following code-lines in his start function:

if(IsTradeAllowed()==false)

{

Alert("You have to activate your ea first or there is a disconnection between the server connection!");

return;

}

Now it is sometimes the problem, that I get this error-Message before I want to open or close a trade with that ea.

The ea is activated and the internet connection exists.

How could this happen?!?!!

 

NEED HELP!!! CCI exit if value lower than the previous value.. help me pls!!!!!

Hi,

i am new to expert advisor. may i know how to set an exit if the current CCI value lower/higher than the previous value?

if(iCCI(NULL,0,7,PRICE_TYPICAL,0)>iCCI(NULL,0,7,PRICE_TYPICAL,1)) ??

I really need help here!~

 
sunshineh:
Hi,

I have written an ea which has the following code-lines in his start function:

if(IsTradeAllowed()==false)

{

Alert("You have to activate your ea first or there is a disconnection between the server connection!");

return;

}

Now it is sometimes the problem, that I get this error-Message before I want to open or close a trade with that ea.

The ea is activated and the internet connection exists.

How could this happen?!?!!

Looks like your coding, check here for an answer

Error 146 ("Trade context busy") and How to Deal with It - MQL4 Articles

 
calvin1006:
Hi,

i am new to expert advisor. may i know how to set an exit if the current CCI value lower/higher than the previous value?

if(iCCI(NULL,0,7,PRICE_TYPICAL,0)>iCCI(NULL,0,7,PRICE_TYPICAL,1)) ??

I really need help here!~

Try something like

if(iCCI(NULL,0,7,PRICE_TYPICAL,0) != iCCI(NULL,0,7,PRICE_TYPICAL,1)) ??

Reason: