expert advisor - miscellaneous questions - page 35

 

#sparam - Open

I just catch this different " sparam " methods in my main code.
Now I try to choose one method of them, but struggle to choose one of them, even I researched about that in mql4 documentation.

Q:  Which method is right, and why, please?

Thanks in advance.

// # 1
if(sparam==button)
{
  // here code
}

// # 2
if(id==CHARTEVENT_OBJECT_CLICK && sparam==button)
{
  // here code
}

// # 3 ( was 2 I just forgot to change )
if(id==CHARTEVENT_OBJECT_CLICK)
{
  if(sparam==button)
    {
     // here code
    }
}
 

#1 is usually placed inside the click event so that would give you the same as # 2 And also the same as the other # 2

 
#sparam - Closed

Marco vd Heijden:

#1 is usually placed inside the click event so that would give you the same as # 2 And also the same as the other # 2

Thanks so much more.

 

#Delete Order Objects / OnTrade() - Open

Latest 2 hours I spent my time for researching OnTrade() function, finally I know that function does not work in MT4. ( please someone say: you are wrong that it works )

So, price won't hit Stop Loss and Take Profit levels in each ticks, each seconds, each minutes as usually ( if I am right ).
That I try to when Price hits Stop Loss and Take Profit then that #Ticket objects could delete.
I know I can put " My_OrderObjectsDelete() " in OnTimer() and OnTick() - I try to find function like OnTrade().

I need advice for that where can I put " My_OrderObjectsDelete() ", please.

Thanks in advance.

 
It's a bit hard for me to understand what you want.

In mt4 if an open order has hit STP or TGT you find it in the Order-History. So if you cant' find it any more in the OrdersTotal() check the list of OrdersHistoryTotal().

But what if you track STP and TGT again Bid and Ask and check the Orders only if theses checks were successful - no matter where you have placed it in InTick() or OnTimer().
 
Carl Schreiber:
It's a bit hard for me to understand what you want.
In mt4 if an open order has hit STP or TGT you find it in the Order-History. So if you cant' find it any more in the OrdersTotal() check the list of OrdersHistoryTotal().
But what if you track STP and TGT again Bid and Ask and check the Orders only if theses checks were successful - no matter where you have placed it in InTick() or OnTimer().

I think you understand me correctly, thanks for your comment.

But my concern is: I would not like to that part of code continuously runs, because Price indicator should not hits each ticks my Stop Loss and Take Profit Levels.

( I already know how can I delete that objects after order closed - also you check this comment - Function Name is  " deleteobjs() " - #238 )

 

#Delete Order Objects / OnTrade() - Closed

I will put my function either OnTick() or OnTimer().

 

#StringLen - Open

I still research about this concern - but I can't any similar forums - and anything else.

I try to count number of digits. Below code gives me different results, please help me.

Bid_Len = StringLen( IntegerToString( change_to_points( Bid ) ) );

// Results
// EURUSD = 1.23456 > 123456
// NZDUSD = 0.12345 > 12345
Thanks in advance.
 
Max Enrik:

#StringLen - Open

I still research about this concern - but I can't any similar forums - and anything else.

I try to count number of digits. Below code gives me different results, please help me.

Bid_Len = StringLen( IntegerToString( change_to_points( Bid ) ) );

// Results
// EURUSD = 1.23456 > 123456
// NZDUSD = 0.12345 > 12345
Thanks in advance.
Please can you explain more about what you are trying to do here?
 
honest_knave:
Please can you explain more about what you are trying to do here?

Thanks for your prompt reply.

Below image shows what I want to do.

StringLen-1

( just quickly made )

I hope it will help you that you understand me more clearly. 

// 2nd time edited

I hope this can be help more.

StringLen - explain - 1 

Reason: