How to code? - page 105

 
 
 

Can anyone code this 'simple' task?

I want to grab the highest and lowest values of an indicator over an entire chart. A while ago I tried what I thought should have worked, from within an EA, but it didn't.

(Sorry I don't have that attempt now to show you.)

Any ideas?

Big Be

 

You could use an array then load it up with values. Then do a simple sort to move the highest value to the top. Then do the same for the lowest.

For example you'd compare item 2 to item 1. If 2 is higher put it in item 1. Then compare 3 to 1 and repeat to the end of the array.

You'd just do the initial loading of the array in the init() function then with every new bar just compare the value to item 1 of the array.

Hope that helps

Lux

 

Need help with trade managegement robot.

Hi

I need to write ea which will put awaitng order and do the following when it triggers:

1. Variables ("buy"/"sell",position1_lots,position2_lots,position3_lots,entry_price,stoploss,TP1,TP2)

2.Open (buy/sell) trade with 3 positions at (entry_price) with (stoploss).

3.Close position_1 at (TP1) and move stop loss to breakeven for 2 left positions.

4.Close position_2 at (TP2) & let the last one ride or hit breakeven.

I've programmed some indicators but i really dont have much idea how to write this robot.

 

big be...

First find the bar with the ihighest array

then, use the bar and the findings in logical order for your indicator.

 

Invisible TP/SL

Hello everyone.

I'm trying to code in an effective and reliable invisible stoploss, trailing stop and takeprofit into my EAs. So far, my code just looks for the bid/ask to equal the stoploss or takeprofit value. If the price equals that value, then close the trade.

The problem I'm having is that sometimes the price seems to skip. There is no progressive movement of price. How do I then get around that problem? and make an invisible TP/SL which is guaranteed to close the trade where necessary?

 
:: the only way to close is NOT to use " == " in your code, instead everything have to close higher or lower then your price, use... higher " >= " price or lower " <= " price, yes price doesn't go like 1 2 3, it can jump from 1 to 5 in volatile market (like big news announcements), hope this helps a little
Ronald Raygun:
Hello everyone.

I'm trying to code in an effective and reliable invisible stoploss, trailing stop and takeprofit into my EAs. So far, my code just looks for the bid/ask to equal the stoploss or takeprofit value. If the price equals that value, then close the trade.

The problem I'm having is that sometimes the price seems to skip. There is no progressive movement of price. How do I then get around that problem? and make an invisible TP/SL which is guaranteed to close the trade where necessary?
 

Can anyone code this 'simple' task?

luxinterior and ajk,

Thanks. I tried one of those methods before (I will have to find what I did) and it worked great for price but not for an indicator.

Have you successfully done it?

The indicator doesn't matter, if could be any of MT4's built-ins.

Big Be

 
Big Be:
I want to grab the highest and lowest values of an indicator over an entire chart. A while ago I tried what I thought should have worked, from within an EA, but it didn't.

(Sorry I don't have that attempt now to show you.)

Any ideas?

Big Be

using the iHighest function:

int iHighest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

set the count to "Bars" so.

iHighest(NULL, 0, 3, Bars, 0);

At least that what I think would work. Just check in your chart settings how many bars you keep in history. Default I think is 52,000 bars.

Reason: