How to code? - page 245

 

Isn't this a little inefficient to post all programming questions under the same link?

 

Ordersend duplicate order?

int start()

{

int ticket,expiration,rp;

double point,bd;

point=MarketInfo(Symbol(),MODE_POINT);

expiration=CurTime()+PERIOD_D1*60;

rp=100;

bd=Bid;

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*1*point,0,0,0,"some comment1",1,expiration,Green);

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*2*point,0,0,0,"some comment2",1,expiration,Green);

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*3*point,0,0,0,"some comment3",1,expiration,Green);

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*4*point,0,0,0,"some comment4",1,expiration,Green);

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*5*point,0,0,0,"some comment5",1,expiration,Green);

ticket=OrderSend(Symbol(),OP_SELLSTOP,1.0,bd-rp*6*point,0,0,0,"some comment6",1,expiration,Green);

}

I want to open only six pending orders. Can you help me pls. Thank you very much!!!

 
YenTrader2:
Isn't this a little inefficient to post all programming questions under the same link?

As inefficient as can be!

 

Mr Coders' Guru, can you help me to create an ea?

codersguru:
jdun,

The easiest way to reverse the code (sell to buy & buy to sell) is changing:

if(signal0 < signal1 ) GlobalVariableSet("TM0",1);

if(signal0 > signal1) GlobalVariableSet("TM0",0);[/CODE]

To:

[CODE]if(signal0 > signal1 ) GlobalVariableSet("TM0",1);

if(signal0 < signal1) GlobalVariableSet("TM0",0);

The function of this ea is to close out all my open positions and pending orders that are not executed at a fixed hour of time. The ea should run on a metatrader4 trade platform. The specs are as follows:

1) at the start of 16:00 hour (interbankfx trade platform's time)

2) close the first open position

3) close the next open position

4) until all the open positions are closed, go to

5) close the first pending order

6) close the next pending order

7) until all the pending oders are closed

8) end

Thank you

 

Adding ATR to an existing code

I just need to know how to add ATR SL, TP, TS to an existing code. Any help would be appreciated.

 
EddieRoyals:
I just need to know how to add ATR SL, TP, TS to an existing code. Any help would be appreciated.

where is the existing code?.

-------------------------------

to add atr value you first take an

say double b = iATR(Symbol(),0,5,1) making sure the value it returns get multiply by the Point of the broker so moving forward in our hypothetical scenario that would be

b = point * iATR(Symbol(),0,3,1);

so far so good from here you can do what you want one way would be to multiply it by another threshold say for e.g 5

so the end result

b = 5 * point * iATR(Symbol(),0,3,1);

there now you play around

-guyver

 

Modifying indicator

HI,

could someone please help me and modify this indicator to check also high and low according to the previous bar. If current candle has HH and HL and histogram value is < 50 then histogram bar is green, if current candle has LH and LL and histogram value is also < 50 then histogram bar is red. Any other result should plot gray histogram bar.

Thank you in advance for any help!

Files:
 

Thanks a lot Guyver. I will give it a go sometime today. Much appreciated!

 
kolesar:
HI,

could someone please help me and modify this indicator to check also high and low according to the previous bar. If current candle has HH and HL and histogram value is < 50 then histogram bar is green, if current candle has LH and LL and histogram value is also < 50 then histogram bar is red. Any other result should plot gray histogram bar.

Thank you in advance for any help!

nothing. no answer, no nothing.

maybe this will help??

 

Adding stoploss

Could someone tell me how to add stoploss for following code.

Thank you.

#define MAGIC 20090101

extern double Lots = 0.2;

extern double OpenPrice = 92.50;

extern double ClosePrice = 92.55;

extern bool gaku = 0;

int CalculateCurrentOrders()

{ int pos=0;

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

{ if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == false) break;

if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC)

{

if(OrderType() == OP_BUY || OrderType() == OP_BUYLIMIT || OrderType() == OP_BUYSTOP) pos++;

if(OrderType() == OP_SELL || OrderType() == OP_SELLLIMIT || OrderType() == OP_SELLSTOP) pos--;

}

}

return(pos);}

int start()

{

if(IsTradeAllowed() == false || CalculateCurrentOrders() != 0) return(0);

if(OpenPrice < ClosePrice && gaku == 0) OrderSend(Symbol(),OP_BUYLIMIT,Lots,OpenPrice,0,0,ClosePrice,"",MAGIC,0,Blue);

else if(OpenPrice > ClosePrice && gaku == 0) OrderSend(Symbol(),OP_SELLLIMIT,Lots,OpenPrice,0,0,ClosePrice,"",MAGIC,0,Red);

else if(OpenPrice < ClosePrice && gaku != 0) {OrderSend(Symbol(),OP_BUYSTOP,Lots,OpenPrice,0,0,ClosePrice,"",MAGIC,0,Blue);

}

else if(OpenPrice > ClosePrice && gaku != 0) {OrderSend(Symbol(),OP_SELLSTOP,Lots,OpenPrice,0,0,ClosePrice,"",MAGIC,0,Red);

}

return(0);

}

Reason: