How to code? - page 38

 

Confused.

For some reason, For loops are being completely skipped in any EAs that I write. The documentation makes no mention of any kind of limitation on the loops and I'm really at a loss to understand it.

Is this a bug or are there some context rules that I havn't figured out yet?

Manxxx

 
Manxxx:
For some reason, For loops are being completely skipped in any EAs that I write. The documentation makes no mention of any kind of limitation on the loops and I'm really at a loss to understand it.

Is this a bug or are there some context rules that I havn't figured out yet?

Manxxx

The latter.......

 

Looking for ideas

I'm not new to programming at all but I am new to EAs and I've reached a point where a fresh perspective might be helpful.

I've written a number of EAs that are all pretty much loosers, some using multiple indicators, some just one, etc.

Recently I decided to start really simple and build up so I built a really simple Envelope EA. Nothing spectacular at all but this simple little thing is hitting 37% Model Quality which is better then I've done so far. It actually finishes a 2 month run with more money then it started with.

For the moment I have it set to hunt for Buy opportinities only. Breaking the lower envelope is the trigger. (Like I said its really simple). The EA only takes one position at a time.

The issue I'm encountering is down trends and sudden spikes in the price followed by severe retracements. Naturally the price action does hit the lower envelope limit and triggers a buy. on a down trend, this naturally means the EA really suffers. Trailing stops are in place and they helped gain a little more profit but stop losses really steal it all back and usually at exactly the same spots in the price action. In my case one such spot is Aug 31/07 at 14:05 right after the spike in EUR/USD.

I've tried various MAs with a number of settings but none seem to provide a solution to the realy bad spikes without killing most gains. I've tried adding in some indicators (CCI, MFI, RSI) but the effect tends to just move the problem from one part of the chart to another. I've played with my envelope size as well but to avoid the spike, I end up expanding the envelope so much that it never finds any opportunies to buy.

Such problems will be common and I'd really like to find a way to beat this problem. I don't need code, just suggestions.

Thanks

Manxxx

 

Help Plotting Daily open price on 4 Hour Chart

I'm trying to build an indicator that displays the Period 1 daily open price on a 4 HOUR chart.

I've tried the following, but none of them work correctly

iOpen("GBPJPY",PERIOD_D1,i);

and

iMA("GBPJPY",PERIOD_D1,1,0,MODE_EMA,PRICE_OPEN,i);

The Daily open price continues to change or elevate through out the day. The open price should always stay the open price, until the next day begins, no?

If I switch to daily charts, it's o.k. It's just the smaller time frames. Is metatrader not set up properly to plot larger time frame data on smaller time frame charts?

Thank you in advance

 

Is this possible to code?

I've been at this 4 weeks and still no clue,

it's roughly this,

if OP_BUY EUR/USD minus OP_SELL USD/CHF equals minus 100 ignore other trades and

close both orders together

I've tried everything loops within loops etc and nothing works

I'm working on money management and am pulling my hair out any help or clue very welcomed.

with thanks

 
mish:
I've been at this 4 weeks and still no clue,

it's roughly this,

if OP_BUY EUR/USD minus OP_SELL USD/CHF equals minus 100 ignore other trades and

close both orders together

I've tried everything loops within loops etc and nothing works

I'm working on money management and am pulling my hair out any help or clue very welcomed.

with thanks

I presume this is a hedge and you are referring to the accrued profit of each, above. You need find what these are using OrderSelect and OrderProfit() functions, then:

if (MathMax(EU_Profit,UC_Profit) + MathMin(EU_Profit,UC_Profit) < -100)

{

OrderClose(EU_Ticket...

OrderClose(EC_Ticket...

}

Hmmm... seems too simple to spend 4 weeks on so you are probably trying to do something else.....

 

thankyou omelette

I'm not a programmer just put bits and pieces and hope they work using some logic of course!

Thankyou very much!

 

Logs of an Indicator

Trivial question: I'm writing a new Personal Indicator for the first time. I can't view my logs that I make with the command Print("...") in the start{} method. Where I can view them on MetaTrader 4?

 

Is this possible to code?

After looking at omelettes answer it's not what I need but certainly thankyou!

The problem:

Using one symbol for simplicity lets choose EUR/USD

If I have multiple BUY && SELL positions

I need to choose only one BUY position and only one SELL position

That together equal a variable of lets say of exactly -100

Every other order is untouched

Which BUY or SELL is irrelevant

The logic behind this is to keep BUY && SELL ratios correct for money management, a kind of stoploss that uses OrderClose() for both BUY && SELL

any help warmly appreciated

and thankyou

 

Is this possible to code?

I have uploaded my feeble attempts to program relating to my last post, theres are many mistakes of course, it doesn't work!

Thankyou

Files:
advice.txt  2 kb
Reason: