How to code? - page 116

 

code for Opening Several Pair at simultaneously

Hi CodersGuru, Could you please let me know how to code script or EA for OP_SELL or OP_BUY for several pairs simultaneously at nearly same time.

For Instance : I would like to open BUY or SELL EURUSD and USDJPY at the same time.

Thank you

 

Trades not closing

This seems to be simple to code but my trades do not close when they are supposed to.

In this example trades should close at the cross of the lower time frame.

if (CloseSell1_1 > CloseSell1_2) Order = SIGNAL_CLOSESELL;

Files:
close.jpg  170 kb
 

Hello, what code can I use to check if any Pending orders are open and close them at a specific time?

Thank you

 
 

This is how to close all of your open orders

This Function will close all open trades.

int orders = OrdersTotal();

void CloseAll()

{

if (orders>0)

{

for (int cnt = 0 ; cnt < orders ; cnt++)

{

OrderSelect(0,SELECT_BY_POS,MODE_TRADES);

if (OrderMagicNumber() == MagicNumber)

if(OrderType()==OP_BUY)

OrderClose(OrderTicket(),OrderLots(),Bid,3, Violet);

if(OrderType()==OP_SELL)

OrderClose(OrderTicket(),OrderLots(),Ask,3, Violet);

if(OrderType()==OP_BUYLIMIT)

OrderDelete(ticket,Black);

if(OrderType()==OP_SELLLIMIT)

OrderDelete(ticket,Black);

}

}

}

 

I just want to close the pendings at a specific time.

Thanks

 
matrixebiz:
I just want to close the pendings at a specific time. Thanks

How about adding the code below before takis code:

if (TimeCurrent( ) == (time you wish to close))

not really sure but it might work..

 

Ok, also how can I check current bar or previous bar if a trade was opened?

Thanks

 

i have created a really simple EA. and a system which i use in atleast 3 Timeframe..May problem it doesn't stop opening and i don't want to have 3 EA and 3 chart for one pair.

i need a code that would only do one order for buy and for sell per bar per TF and still open if it is on a different bar. i can have buy and sell and the same bar.

Sometimes i have 3 signal in 3 different TF. i want to take all order but i want only one order per TF and i can still take another order in another TF if it is still open but in a different bar.

example:

1 signal in 4h

1 signal in 1h but it falls in bar for 4h

1 signal in 30 min but only one bar for 1h and 4h.

3 signal will be open.

i am ok with using magic number as means of filter.

can someone help me? thank you very much.

so far this is what i thought:

for 30 mins

if (magicnumber == 123)

{

if (iTime(OrderOpenTime()) != iTime(Symbol(),PERIOD_M30,0))

{//my order code}

}

i don't have MT4 but i know somethings is not right in the logic or code. So guys please help me.

also i think we have similar problem with matrixebiz

 

I have added levels to HMA:

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_color1 Black

#property indicator_color2 Red

#property indicator_width1 2

#property indicator_minimum 0

#property indicator_maximum 100

#property indicator_level1 80

#property indicator_level2 60

#property indicator_level3 40

#property indicator_level4 20

#property indicator_levelcolor DarkSlateGray

But the indicator doesnt appear on a seperate window properly.Any help much appreciated.