How to select the order that have profit? - page 2

 

Thanks diostar.

I change it now but it doesn't repair the problem becouse in my code was smaller not higher value so there should be action faster....

 

"I change it now but it doesn't repair the problem becouse in my code was smaller not higher value so there should be action faster...."

What sort of "action faster" are you hoping, expecting, to experience? You have to define this (fortunately or unfortunately), then only you can test/verify, hence improve/work on this "action faster" thingy of yours.

 
diostar:

"I change it now but it doesn't repair the problem becouse in my code was smaller not higher value so there should be action faster...."

What sort of "action faster" are you hoping, expecting, to experience? You have to define this (fortunately or unfortunately), then only you can test/verify, hence improve/work on this "action faster" thingy of yours.

        for ( i =   OrdersTotal () - 1   ; i >= 0 ; i -- )
        if (OrderSelect(i, SELECT_BY_POS)
        && OrderSymbol () == Symbol() 
        && OrderType () == OP_SELL 
        && diference <= OrderProfit () )
           { 
           

Now it's almost in every tick true.


So what do you suggesst? I had thinking that if I am using double diference = 20 * Point than it is 20 pips so this is easier/faster to break this by the course than break 200 pips...

Do you say that it should be written some how in currency ?

Do you know how?

 
BorysekPL:

So what do you suggesst? I had thinking that if I am using double diference = 20 * Point than it is 20 pips so this is easier/faster to break this by the course than break 200 pips...

Do you say that it should be written some how in currency ?

  1. EA's should adjust for 4/5 digit brokers. Your 20 * Point is NOT 20 pips on a 5 digit broker. (20 * pips2dbl is always 20 pips)
    //+------------------------------------------------------------------+
    //| expert initialization function                                   |
    //+------------------------------------------------------------------+
    int     magic.number;                           // Export to ModifyStops
    string  TF.text,                                // Export to Decide
            trading.disabled;                       // Export to start
    //++++ These are adjusted for 5 digit brokers.
    int     pips2points;    // slippage  3 pips    3=points    30=points
    double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
    int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)
    int     init(){
         if (Digits % 2 == 1){      // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345
                    pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
        } else {    pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; }
        // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
    

  2. pips < OrderProfit() is meaningless. You have three choices. look for a Dollar profit
    #define DOLLARS200 200.00
    :
    DOLLARS200 < OrderProfit()
    or convert profit into pips
    double  PointValuePerLot(string pair="") {
        /* Value in account currency of a Point of Symbol.
         * In tester I had a sale: open=1.35883 close=1.35736 (0.00147)
         * gain$=97.32/6.62 lots/147 points=$0.10/point or $1.00/pip.
         * IBFX demo/mini       EURUSD TICKVALUE=0.1 MAXLOT=50 LOTSIZE=10,000
         * IBFX demo/standard   EURUSD TICKVALUE=1.0 MAXLOT=50 LOTSIZE=100,000
         *                                  $1.00/point or $10.00/pip.
         *
         * https://www.mql5.com/en/forum/127584 CB: MODE_TICKSIZE will usually return the
         * same value as MODE_POINT (or Point for the current symbol), however, an
         * example of where to use MODE_TICKSIZE would be as part of a ratio with
         * MODE_TICKVALUE when performing money management calculations which need
         * to take account of the pair and the account currency. The reason I use
         * this ratio is that although TV and TS may constantly be returned as
         * something like 7.00 and 0.00001 respectively, I've seen this
         * (intermittently) change to 14.00 and 0.00002 respectively (just example
         * tick values to illustrate).
         * https://www.mql5.com/en/forum/135345 zzuegg reports for non-currency DE30:
         * MarketInfo(Symbol(),MODE_TICKSIZE) returns 0.5
         * MarketInfo(Symbol(),MODE_DIGITS) return 1
         * Point = 0.1
         * Prices to open must be a multiple of ticksize */
        if (pair == "") pair = Symbol();
        return(  MarketInfo(pair, MODE_TICKVALUE)
               / MarketInfo(pair, MODE_TICKSIZE) ); // Not Point.
    }
    :
    double  perLotPerPoint  = PointValuePerLot(symbolOrder),
            OrderPips       = OrderProfit() / OrderLots() / perLotPerPoint;
    :
    if( diference <= OrderPips )
    
    Or just compare prices
    && Bid > OrderOpenPrice()
    && Bid < OrderOpenPrice() + diference // Buy between 0 and 'diference' pips

 
BorysekPL:

Now it's almost in every tick true.


So what do you suggesst? I had thinking that if I am using double diference = 20 * Point than it is 20 pips so this is easier/faster to break this by the course than break 200 pips...

Do you say that it should be written some how in currency ?

Do you know how?

I saw the other helper assistance who stays ard here, WHoredr, you can't miss him, whose piece of code which returns proper TickValue of the Symbol() you load.

The code is GOOD, if not, FABULOUSLY ELEGANT by anyone's standard. Short, sweet and cooking, just the way anyone will be please. Very easy to use.

Me - I have been doing this the other way ever since MQL was born, converting currency directly into pips, instead of your likings and logic.

I don't want this to get this complicated for you. So bottomline, go seek WHOredr on this matter. He is a good-hearted, inteliigent man, I'm sure.

 

diostar

Me - I have been doing this the other way ever since MQL was born, converting currency directly into pips, instead of your likings and logic.

I don't want this to get this complicated for you. So bottomline, go seek WHOredr on this matter. He is a good-hearted, inteliigent man, I'm sure.

*

*

*

I'm going creazy:)

Your language is complicated for me so I have hope that I will understand everything.... Like in the history with beer and mug....... :)

WHRoeder

My broker is 4 digits.

double diference = 200 * Point;

&& Bid > OrderOpenPrice()
&& Bid < OrderOpenPrice() + diference // Buy between 0 and 'diference' pips

But there is on every tick still true...


 
  1. may not always be. Fix it now or loose trades later.
  2. Will be unless order is going wrong OR you reach 200 pips. So?
 

I see that now it's like diference is 0pips.

I haven't reach 200 pips.

Everything else is going good couse I've give sleep(2000) behind every action too see how it works step by step.

It,s like EA

&& Bid > OrderOpenPrice()
&& Bid < OrderOpenPrice() + diference // Buy between 0 and 'diference' pips

didn't read diference.

How to use?

#define DOLLARS200 200.00
:
DOLLARS200 < OrderProfit()

I try like that:

#define DOLLARS10 10.00
        for ( i =   OrdersTotal () - 1   ; i >= 0 ; i -- )
        if (OrderSelect(i, SELECT_BY_POS)
        && OrderSymbol () == Symbol() 
        && OrderType () == OP_BUY 
        && Bid > OrderOpenPrice()
        && Bid < OrderOpenPrice() + DOLLARS10 )
           {                                                                                                
But still the same - DOLLARS10 is 0
 
  1. Bid < OrderOpenPrice() + DOLLARS10 )

    What does price + dollars mean? NOTHING

    REREAD my post #2


  2. #define DOLLARS10 10.00
    But still the same - DOLLARS10 is 0

    How do you come up with what?


  3. Everything else is going good couse I've give sleep(2000) behind every action too see how it works step by step.
    Sleep doesn't work in the tester
  4. But there is on every tick still true...

    So start printing values and figure out WHY

      && OrderSymbol () == Symbol() 
            && OrderType () == OP_BUY 
            && Bid > OrderOpenPrice()
            && Bid < OrderOpenPrice() + DOLLARS10 ){
    Print("Found@",i,OrderTicket(), " ",Symbol()," type(", OrderType(),
         ") OP(",OrderOpenPrice(),") < "Bid(",Bid,") < OP+$10(", OrderOpenPrice()+DOLLARS10,")");

    THINK

 
BorysekPL:

diostar

Me - I have been doing this the other way ever since MQL was born, converting currency directly into pips, instead of your likings and logic.

I don't want this to get this complicated for you. So bottomline, go seek WHOredr on this matter. He is a good-hearted, inteliigent man, I'm sure.

*

*

*

I'm going creazy:)

Your language is complicated for me so I have hope that I will understand everything.... Like in the history with beer and mug....... :)

You does seem to be going in circles, but there is no reason to get crazy. Maybe this a better approach:


Say, the other day some fortune-teller tells you your lucky number. Let say that number is 33.333. (a highly precise fortune-teller, I guess - uses double) .

So nowadays, people are smarter, they put that in MQL, instead of using lucky charms to hang around their necks, like in the old ways.

double  MyLuckyNumber = 33.333333; <------ Let say that number is 33.333. (a highly precise fortune-teller, I guess - uses double) 

if(OrderProfit()>= MyLuckyNumber) { close .....} <------ You decide to use this number to close trades, take profit. 

You decide to use this number to close trades, take profit. If anything exceeds this, bad things can happen. With this, you trade 1 standard lot.

Instantly like magic, your 1 lot gains slightly more than 1 PIP. Your reaction - how much profit? Then you see 33.33, or rather $33.33 USD (say you account currency in USD). Close trade.


After a few days of doing this, you begin to realise, you're not making that much by closing on just slightly more than 1 PIP on every trade, because of that 33.3333.

Problem is too, you cannot make do without this Lucky Number. So, you decide to close when 33.3333 PIPS exceed....that way, you're going make more.


See the difference??

Reason: