expert advisor - miscellaneous questions - page 22

 
Marco vd Heijden:

Please use the styler it's under the Tools tab.
I have no idea what you are trying to accomplish so i have to guess what you want to do this is never good.
But you can look at the example here:
So you can see that you can use ObjectGetDouble directly, there is no need to copy the value to another double because the object itself holds the value, and when you drag the line that value changes automatically, and will be seen the next time you read it.

First of all thanks for your comments which is that comments shows me right ways.
I made a big mistake cause I was trying into Test.mq4 file. Since I started to try into main mq4 file. I am getting right way. Both of that files very differently for me.

Yes, after I tried several times your examples for I could reach my goal in this concern. But I figured out I should just use OnChartEvent() for " HLine " ( and some graphical ) Object creations.
And then I just should use OrderModify() for Take Profit modification, that Take Profit modification should follows " HLine " object. ( First: " HLine " gets currently Take Profit Price and Second: Take Profit follows " HLine " object - and but OrderModify() should not updates while I drags " HLine " obeject )
And now first I started to research about OrderModify().

I feel I could check your example one more time. I hope I can do it.

Thanks for all of your helps Mr.Marco.

 

Mr. Marco once again thanks a lot for everything.

So, just OM function finished. ( Orders Modification ) 
I saw few issues in my OM function which one I solved them by myself.
But continuously I see that OM function needs some updates, because I am trying to test OM function with Take Profit modifies.

So I would like to mention I am still faced new issues ( now Market Closed ).

#1    Which part of codes could I keep?
         I already tried both of below parts of codes. But I did not see any different between them. Looks like both of them does runs good for me.

// I learned this Calculation from thread of @Simon's
for ( i = OrdersTotal() - 1; i >= 0; i-- ){}

// This is from yours Mr. Marco
for ( i = OrdersTotal(); i >= 0; i-- ){}

#2    Is that wrong?
         I use 7x times below part of code in my single EA script. Just 2x for calculation of Sell and Buy functions. And 2x Close of them. I call them by the OnChartEvent() and OnTick()

for ( i = OrdersTotal() - 1; i >= 0; i-- )
  {
   if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
   if(closeothers==false && OrderSymbol()!=Symbol()) continue;
//...
  }



 

Also I have other issues but I am working on them to solve them by myself.

Thanks in advance. 

 

The numbering starts from 0 not 1.

Suppose you have 3 orders. They are:

  • 0
  • 1
  • 2

So you should use this:

for ( i = OrdersTotal() - 1; i >= 0; i-- ){}

If you don't, it isn't a disaster; the OrderSelect will fail on the first pass (i==3) and move to the next iteration.

Sorry, I don't understand your 2nd question.
 

 

For the second question.

I usually tend to squeeze all into one loop but of course you can use several.

 
honest_knave:

If you don't, it isn't a disaster; the OrderSelect will fail on the first pass (i==3) and move to the next iteration.

Marco vd Heijden:

I usually tend to squeeze all into one loop but of course you can use several.

Thank you for your comments. Much appreciate!

 

I already spent few hours for this issues that I could figure out where that comes from?!
Q:   Please let me me what is that? ( I attach image file )

I use your most useful example " Stealth 4.mq4 " for drags Stop Loss and Take Profit, so that was working perfectly latest Friday.
Now market closed I see that messages from Journal window. When I remove OrderModify() code blocks that messages stops.

Have a nice weekend. 

Files:
 

Well you can modify an order when markets closed so thats kinds logical...

It would need a bit more code to make it stop.

 

Max Enrik: When I remove OrderModify() code blocks that messages stops.
  1. This is why I recommend
    Do not trade multiple currencies in one EA
  2. If you only trade one pair/chart in OnTick, you wouldn't have the problem.
 

It's perfectly possible to trade all currencies in one EA.

 
Marco vd Heijden: It's perfectly possible to trade all currencies in one EA.
Never said it wasn't. Said I don't recommend it because of all the problems. One pair/chart simplifies everything. Don't make things harder than necessary.