Ask! - page 147

 
AceFX:
Ben,

Can't thank you enough for the quick and helpful reply. You were absolutely correct and I am a step closer because of it!

I do have one more question however, trying to add a break even point at a level less than the trailing stop but haven't gotten past:

extern bool UseBreak_Even = True;

extern int Break_Even = 20;

...

Any chance on some advice here as well?

Thanks again and take care!

-Ace

Hi, Breakeven is an easy function, you just need to understand what you need and then you'll be able to think of what you write to make it happen.

1. Breakeven = moving stoploss to order open price when stoploss is below open (for buy, above open for sell).

To check if its below we usually use this: OrderStopLoss()<OrderOpenPrice()

2. Before you move to breakeven you need to check if conditions are true. I use something like this:

if(bid>orderopenprice()+breakeven*point) move

3. Moving. I use something like this:

ordermodify(symbol(),bla-bla-bla,,,stoploss,takeprofit,0);

bla-bla-bla = set of parameters that don't change for opened orders like order open price (can be changed for pending orders)

stoploss = I usually put orderopenprice() here to that the order is closed at 0 pip profit.

takeprofit = if you don't want TP to change, just enter OrderTakeProfit() (case sensitive!)

Hope this helps and yes it leaves you to do the job yourself.

Oh, and how to find the order you want to modify:

for(int i=0;i<=OrdersTotal();i++) {

if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;

if(OrderSymbol()!=Symbol()) continue;

if(OrderMagicNumber!=MagicNumber) continue;

if(your-condition-here) your-action-here;

}

That should do the job just fine this cycle simply cycles through orders and finds each and every order currently opened. It then filters out orders with different magic number (you'll need to define magic number first) and those with different symbol (currency pair).

Hope this helps

nck

thanks but the code is useless without the goldminer1 and goldminer2 indicators

New EA is attached. Couldn't test it for obvious reasons so please don't blame me if it doesn't work the way it should. It should close existing order when a new signal is received but there could be a conflict of signals because different indicators are used for buy and sell.

Have fun with the new EA!

Files:
 

Trade size per tick or bar in MT4

Hi,

I hope someone with good knowledge of MT4 internals can answer my question and this answer might benefit everybody: I cannot find anywere how to get a trade size for incoming ticks or for a bar. This seems to be a basic market characteristic but MarketInfo function does not provide it. Is it possible in MT4 at all?

Thanks

 
atkfam:
Hi,

I hope someone with good knowledge of MT4 internals can answer my question and this answer might benefit everybody: I cannot find anywere how to get a trade size for incoming ticks or for a bar. This seems to be a basic market characteristic but MarketInfo function does not provide it. Is it possible in MT4 at all?

Thanks

double Volume[]

Series array that contains tick volumes of each bar of the current chart.

double iVolume( string symbol, int timeframe, int shift)

Returns Tick Volume value for the bar of indicated symbol with timeframe and shift. If local history is empty (not loaded), function returns 0.

For the current chart, the information about bars tick volumes is in the predefined array named Volume[].

Is this what you were looking for? Volumes are based on number of ticks received during the bar, might be generated during back-test, differ for every broker. I'm afraid they don't have much value.

 

Trade size per tick or bar in MT4

Shinigami,

Thanks for you response but I am looking for actual trade size associated with each tick. Each tick seems to be a buy/sell transaction and I really would like to know the actual size of such a transaction. Is it 100 standard lots or 1 lot or microlot? It makes a difference.

 

Hello coders and fellow traders, I have a question but more about logic .

I am (unsuccessfully) trying for quite some time to do a simple EA and hopefully you will help me to do a next step.

I have a custom indicator ( 2MA CrossoverWithPrice ) and I would like to make a buy when the blue arrows appear and sell when red arrow appears.

I called the indicator with iCustom function like this:

iCustom(NULL,0,"2MA CrossoverWithPrice",0,0,CLR_NONE);

and compiled the EA and it seems everything is ok since I get alert on chart when I attach it ( says that custom indicator is attached)

What bothers me is that I don't know what to do next,how to tell the EA to buy and sell because the indicator creates 2 types of arrows.

Can anybody help me in any way? advice or anything please?

 

Trade Context busy

Hi does anyone know of a way to keep sending a close or open to your broker if you keep getting trade context busy signal?

 

adding MA levels to an indicator

Afraid I can't help with the above questions as I'd bet I'm the newest wanabe programmer here

I have successfully (finally!) done my first simple indicator which simply places 4 EMAs onto a chart - and they can be adjusted WOW! I'm chuffed actually

Wot I'd now like to do is have the option of adding levels to one or more of the EMAs. Does anyone know how to do this in the code? Also is it possible to have them as an extern variable - to be able to vary the levels - or to do this would if have to be another parameter?

Once I can crack this, I'll add show boolean things so I can turn each EMA off - small steps at a time. The theory is, find the best fitting EMA and add levels showing the range (maybe 2 levels up and two down).

Thanks in advance,

Dave

 
willmalou:
Hi does anyone know of a way to keep sending a close or open to your broker if you keep getting trade context busy signal?

You'd have to put the ordersend in a loop and check the response from your broker. If the response is -1 send the order again. You might want to put a slight delay before you send it again using the Sleep function.

Good luck

Lux

 
atomi50:
Hello coders and fellow traders, I have a question but more about logic .

I am (unsuccessfully) trying for quite some time to do a simple EA and hopefully you will help me to do a next step.

I have a custom indicator ( 2MA CrossoverWithPrice ) and I would like to make a buy when the blue arrows appear and sell when red arrow appears.

I called the indicator with iCustom function like this:

iCustom(NULL,0,"2MA CrossoverWithPrice",0,0,CLR_NONE);

and compiled the EA and it seems everything is ok since I get alert on chart when I attach it ( says that custom indicator is attached)

What bothers me is that I don't know what to do next,how to tell the EA to buy and sell because the indicator creates 2 types of arrows.

Can anybody help me in any way? advice or anything please?

Well you're using the icustom incorrectly for a start. The last variable should be the bar that you want to check, usually 0 or 1, or it could be a variable. Not sure why you're sending a color?

The second to last variable is the buffer you're trying to return. If it's only got the two arrows I'd guess buffers 0 and 1. So what you'd do is check if either are set to something other than 0 or NULL, depending on the indicator. You'd need to look at the indicator code to figure out which buffer is related to which arrow and then use them accordingly.

Read up on the icustom function again.

Good luck

Lux

 

Plot Lower TF MA-Cross on Higher TF Chart?

Hi,

I want to know how do I plot a Lower Timeframe MA cross on a Higher Timeframe chart.

e.g. I want to plot an arrow on H1 chart when M15 's MA5 and MA10 cross.

Please let me know.

Thanks,

JForex.

Reason: