thank you for your help
but im not sure where I should use that function should I use that insted of some of the conditional lines or use it with them, like I said Im a total beginner.
Is it possible to use a magig number or the comment string to definitly identify the right order?
total=OrdersTotal(); if(total < 1) // << A { ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,0,0,0,"some comment",0,0,Green); // << B ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Bid+50*Point,0,SL_2,0,"some comment",0,0,Green); // << C { for(cnt=1;cnt<total;cnt++) // << D << E {
A) you only do following code if no orders, via total being set to 0. That's okay
B) & C) you create 2 orders. That's okay
D) you start cnt at 1 rather than 0. That's (probably) NOT okay. Indexing starts at 0
E) you limit loop to 'total' which was (and is) set to 0 ! You perhaps need to set total to OrdersTotal() again
A) you only do following code if no orders, via total being set to 0. That's okay
B) & C) you create 2 orders. That's okay
D) you start cnt at 1 rather than 0. That's (probably) NOT okay. Indexing starts at 0
E) you limit loop to 'total' which was (and is) set to 0 ! You perhaps need to set total to OrdersTotal() again
I tried that allso but there sems to be no communication in the program after the ordersend. that is the order select does no work as planned.probably something wrong wit the syntax
int start() { int ticket1,ticket2,total,cnt; double SL_1, SL_2,value ; SL_1=0; SL_2=Bid+20*Point; value=Bid+50*Point; total=OrdersTotal(); if(total < 1) { ticket1=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*Point,0,0,0,"some comment",0,0,Green); { ticket2=OrderSend(Symbol(),OP_BUYSTOP,0.2,Bid+50*Point,0,SL_2,0,"some comment",0,0,Green); { total=OrdersTotal(); if(total < 1) { OrderSelect(ticket1, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_BUY && OrderSymbol()==Symbol()) { if(OrderStopLoss()==0) { if(Ask-OrderOpenPrice()==value) { OrderModify(OrderTicket(),OrderOpenPrice(),SL_2,OrderTakeProfit(),0); return(0); } } } } } } } return(0); }
is this approach possible ?that is name the tickets ticket1 and ticket2 to identify them in the order select?
but still this is not working no executions after the ordersend.
but thanks anyway
SL_1=0; SL_2=Bid+20*Point; value=Bid+50*Point; I think that is stoploss for Buystop order so it must be SL_1=0 ; SL_2 = Bid-20*point; SL_3 = Bid - 50*point; I wish that's be right
now it's working and for both 4 digits & 5 digits platforms
int p=1; int init() { if (Digits == 5 || Digits == 3) { p = 10 ; } return (0); } //+------------------------------------------------------------------+ //| //+------------------------------------------------------------------+ int start() { int ticket,total,cnt; double SL_1, SL_2,value ; SL_1=0; SL_2=Bid-20*p*Point; value=Bid-50*p*Point; total=OrdersTotal(); if(total < 1) { ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+10*p*Point,0,0,0,"some comment",0,0,Green); ticket=OrderSend(Symbol(),OP_BUYSTOP,0.1,Bid+50*p*Point,0,SL_2,0,"some comment",0,0,Green); { for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderType()<=OP_BUY && OrderSymbol()==Symbol()) if(OrderStopLoss()==0) { if(OrderType()==OP_BUY && Ask-OrderOpenPrice()==value) { OrderModify(OrderTicket(),OrderOpenPrice(),SL_2,OrderTakeProfit(),0); return(0); } } } } } return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Im just a beginner in mql4 programming and I´m having a lot of trouble with the following:
I am sending two pending orders the first one just 10 points from the entry and the other one 50 points from entry( the small distance betwen is do to quicker testing results in demo)
the 1st one does not have a stoploss but the second one has a stop loss 30 points away, what i´m trying to do is to let the first order inherit the stoploss from the second order the moment the
second becomes a open order. to my inexperinced opinion I have tried allmost everything exept let the ea physically call the broker and nothing seems to work.
my coding text is mostly copied from varius ea,s i have been looking at for simular effects but so far I have not found anything with exsacly this function.
It is much like a trailing stop but still differs because it does not trail behind at every pip.
here enclosed I send you the most resent approach. If any one has a ansver to my problem or differant approach to the solution i would be very greatfull.
pardon my spelling for english is my second language.
best regards