| / | Forum |
|
BorysekPL
2011.09.24 19:19
I' ve try this method but without effects: for (i = OrdersTotal () - 1 ; i >= 0 ; i -- ) {//for2 if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol () == Symbol() && diference <= OrderProfit () ) Also I can use OrderOpenPrice like that: int course = Bid ; for (i = OrdersTotal () - 1 ; i >= 0 ; i -- ) {//for2 if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol () == Symbol() && course + diference <= OrderOpenPrice () ) But still without effects:( There could be more orders on the market not only this order. I only know that on this price level is only one order and if it is here, than it is with some plus or neutral profit. |
|
Error 146 ("Trade context busy") and How to Deal with It The article deals with conflict-free trading of several experts on one МТ 4 Client Terminal. It will be useful for those who have basic command of working with the terminal and programming in MQL 4. |
|
Roger
2011.09.24 20:39
Try to replace && course + diference <= OrderOpenPrice () ) to && course + diference - OrderOpenPrice ()<Point ) |
|
WHRoeder
2011.09.24 21:06
BorysekPL: I' ve try this method but without effects: for (i = OrdersTotal () - 1 ; i >= 0 ; i -- ) {//for2 if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol () == Symbol() && diference <= OrderProfit () )
|
|
BorysekPL
2011.09.26 19:35
for ( i = OrdersTotal () - 1 ; i >= 0 ; i -- ) if (OrderSelect(i, SELECT_BY_POS) && OrderMagicNumber () == Ticket && OrderSymbol () == Symbol() && OrderType () == OP_BUY && diference <= OrderProfit () ) { This is also doesn't working:( Looking for help from anybody who knows what is wrong or another method to select order that have profit. I am looking for open orders only that have profit >= variable. |
|
RaptorUK
2011.09.26 19:48
You have the code already . . . I made some small modifications . . . for ( i = OrdersTotal()-1; i>=0; i-- ) if (OrderSelect(i, SELECT_BY_POS) && OrderMagicNumber() == MagicNumber // if you don't use a Magic Number leave this out && OrderSymbol() == Symbol() && OrderType() < OP_BUYLIMIT // this selects BUY and SELL orders && OrderProfit() >= variable ) { |
|
diostar
2011.09.26 20:17
BorysekPL: Can the prb be...This is also doesn't working:( Looking for help from anybody who knows what is wrong or another method to select order that have profit. I am looking for open orders only that have profit >= variable. && diference <= OrderProfit () )<--------- what type of variable you "define" diference? is it pips? price? dollars? or dime? your base currency?
|
|
WHRoeder
2011.09.26 20:27
&& OrderMagicNumber () == Ticket
will never be true. |
|
WHRoeder
2011.09.26 20:28
BorysekPL: will never be true.This is also doesn't working:( && OrderMagicNumber () == Ticket
|
|
BorysekPL
2011.09.26 22:23
1.DIOSTAR Can the prb be... && diference <= OrderProfit () )<--------- what type of variable you "define" diference? is it pips? price? dollars? or dime? your base currency?
double point = MarketInfo(Symbol(),MODE_POINT); double diference = 20 * point; 2.RaptorUK You have the code already . . . I made some small modifications . . . for ( i = OrdersTotal()-1; i>=0; i-- ) if (OrderSelect(i, SELECT_BY_POS) && OrderMagicNumber() == MagicNumber // if you don't use a Magic Number leave this out && OrderSymbol() == Symbol() && OrderType() < OP_BUYLIMIT // this selects BUY and SELL orders && OrderProfit() >= variable ) { Why You have use?: && OrderType() < OP_BUYLIMIT ? |
|
RaptorUK
2011.09.27 00:12
BorysekPL: Why You have use?: && OrderType() < OP_BUYLIMIT ? You said . . "or another method to select order that have profit." this selects BUY or SELL orders . . see here: http://docs.mql4.com/constants/trading if you want just BUY orders use OrderType() == OP_BUY, if you want just SELL orders use OrderType() == OP_SELL |
|
diostar
2011.09.27 06:17
Then the problem is obvious: double point = MarketInfo(Symbol(),MODE_POINT); double diference = 20 * point; -------------------------------> diference is always 20*Point = 20 PIP (or 0.2 if fractional-point instrument) but:
&& diference <= OrderProfit () )<--------- OrderProfit () returns PROFIT in terms of BASE CURRENCY, (not PIP) In terms of computational, the above condition may be OK and not erroneous because it gives a BOOLEAN result. In terms of common sense, it is no sense to compare one value (in PIPS) with another value in (Dollars, Dimes, Pennis, etc, your BASE currncy). As an illustration only; Case 0: Suppose Profit for 10 Lot goes above 20 Dollars (not pips), then TRUE. Pips gain = 0.2 Pips. Case 1: Suppose Profit for 1 Lot goes above 20 Dollars (not pips), then TRUE. Pips gain = 2 Pips. Case 2: Suppose Profit for 0.1 Lot goes above 20 Dollars (not pips), then TRUE. Pips gain = 20 Pips. Case 3: Suppose Profit for 0.01 Lot order goes above 20 Dollars (not pips), then TRUE. Pips gain = 200 Pips??? Conclusion: It may be right computationally only, but senseless to compare such varying PIPs against a fixed amount in (Dollars, Dimes, Pennis, etc, your BASE currncy). |