[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 751

 
ToLik_SRGV:

The bug is obvious; it opens positions on every tick, since the losing order in the history is not going anywhere, so it finds it on every tick and fills the values of the control variables with the same values, and then the block of opening deals triggers.


How to make it so that it would not look for it again, or rather would not look for something that has already been worked out

 
FoxUA:

How do I make it so that it does not look for it again, or rather does not look for something that has already been worked on?

Take out this block:

for(int cnt=OrdersHistoryTotal();cnt>0;cnt--)
     {
 OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
{if(OrderMagicNumber()== mag &&
OrderSymbol()==Symbol()) 
{ if (OrderType() == OP_BUY )  {b=1; if (OrderClosePrice()==OrderTakeProfit()) bt=1; 
if (OrderClosePrice()==OrderStopLoss()) bs=1; bl=OrderLots()*100; break;}
if (OrderType() == OP_SELL)  {s=1; if (OrderClosePrice()==OrderTakeProfit()) st=1; 
if (OrderClosePrice()==OrderStopLoss()) ss=1; sl=OrderLots()*100; break;}
            }
            
            
         }
      }

And replace it with this one:

   for(int cnt=OrdersHistoryTotal();cnt>0;cnt--){
      static int num_ticket;
      if(!OrderSelect(cnt-1, SELECT_BY_POS, MODE_HISTORY))break;
      if(OrderMagicNumber()== mag && OrderSymbol()==Symbol()){      
      if(num_ticket != OrderTicket())num_ticket = OrderTicket(); else break;
         if(OrderType() == OP_BUY){
            b=1;
            if(OrderClosePrice()==OrderTakeProfit())bt=1;
            if(OrderClosePrice()==OrderStopLoss())bs=1;
            bl=OrderLots()*100;
            num_ticket = OrderTicket();
            break;
         }
         if(OrderType() == OP_SELL){
            s=1;
            if(OrderClosePrice()==OrderTakeProfit())st=1; 
            if(OrderClosePrice()==OrderStopLoss())ss=1;
            sl=OrderLots()*100;
            num_ticket = OrderTicket();
            break;
         }
      }
   }

It differs in that, among other things, it remembers the ticket number of the last losing trade, respectively, checks it, and does not allow opening by the same signal.

 
ToLik_SRGV:

Throw this unit away:


Thank you so much for the test. It seems to be working.

 
Abzasc:

Something like that, I guess.

SZY The code insertion button "SRC" is awkward to use, it's not easy to read.


Thank you very much ! I wrote int for UseHourTrade2 instead of boole ))
 

Good afternoon, friends.

I would like to consult with you on this issue:

I am currently working on an indicator, which transfers to the window of the first currency pair readings (ZigZag), formed on the second currency pair.

But, I have encountered a problem:

for example, if there is a big "gap" in quotes: one pair is quoted as 1.4237, and the other as 0.8345, then these indicators appear "scattered" across the screen, which is not very convenient visually ...

How would you perform conversion of indicator "coordinates" from the second pair, taking into account quotes of the first pair (how to make the price "relative")?

Thank you very much in advance for the advice, recommendation.

 
Morzh09:

Good afternoon, friends.

I would like to consult with you on this issue:

I am currently working on an indicator, which transfers to the window of the first currency pair readings (ZigZag), formed on the second currency pair.

But, I have encountered a problem:

for example, if there is a big "gap" in quotes: one pair is quoted as 1.4237, and the other as 0.8345, then these indicators appear "scattered" across the screen, which is not very convenient visually ...

How would you perform conversion of indicator "coordinates" from the second pair, taking into account quotes of the first pair (how to make the price "relative")?

Thank you very much in advance for the advice, recommendation.

Look at the link. The scaling itself is done there in an original way.

https://www.mql5.com/ru/code/7933

 

Hello!

Can you tell me how to simplify this?

if (Balance > 600)

{

Lot_mod = 0.1;

}

if (Balance > 700)

{

Lot_mod = 0.11;

}

if (Balance > 800)

{

Lot_mod = 0.12;

}

if (Balance > 900)

{

Lot_mod = 0.13;

}

And so on.... Because it's too sprawling in this form.

Thank you!

 
Lim1:

Hello!

Can you please tell me how this can be simplified -

And so on.... It's too sprawling in this form.

Thank you!





An equation of the form y=a*x+b will help
 
Lim1:

Hello!

Could you please tell me how to simplify this -





determine the formula for calculating the lot and that's it, otherwise you'll have to worry about
 

Lim1, try it like this:

int BalanceExcessIn100s = MathFloor( ( Balance - 600 ) / 100.01 );
Lot_mod = BalanceExcessIn100s * 0.01 + 0.1;
Reason: