Help Me, How Script to Filter Profit Open Position

 

Helllo everyone, i need your help,

How script/ function  to filter profit, example :

I Have 10 Buys Open Position. I need to calculate  4 Buys open Position with highest profits.

Thank You

 
asror bersemi: Helllo everyone, i need your help, How script/ function  to filter profit, example :I Have 10 Buys Open Position. I need to calculate  4 Buys open Position with highest profits. Thank You

If you don't show your own code attempting to do what you want, then we will just assume that you don't know how to code at all.

And if that is the case, we will just tell you to hire someone to code it for you (quick but costs money), or to put in the effort to learn to code yourself (does not cost money but will take many months, maybe longer).

 
Fernando Carreiro:

If you don't show your own code attempting to do what you want, then we will just assume that you don't know how to code at all.

And if that is the case, we will just tell you to hire someone to code it for you (quick but costs money), or to put in the effort to learn to code yourself (does not cost money but will take many months, maybe longer).

this my code :

<Deleted. Edit your post and format your code properly using the "Alt-S" or by clicking the code Icon "</>" in the posting toolbar.>

but cant work for read 4 from 10 buys position with highest profit  

 

Please re-edit your post and format your code properly using the "Alt-S" or by clicking the code Icon "</>" in the posting toolbar.

Also please explain what you are doing in your code because it does not seem to do what you explained you want it to do. You seem to just be adding the profit of 4 orders but don't even check if there are open trades or not.

 
asror bersemi: How script/ function  to filter profit, example:I Have 10 Buys Open Position. I need to calculate  4 Buys open Position with highest profits.
  1. Use "OrdersTotal()" to obtain the count of currently open positions.
  2. Create an array of this maximum size base on the above count
  3. Create an index variable for the array and set it to an initial value of "0".
  4. Loop through all the open positions using "OrderSelect()" to select them.
  5. Filter by symbol "OrderSymbol()", magic number "OrderMagicNumer()" and if necessary, by type "OrderType()".
  6. Obtain the profit for the position using "OrderProfit()".
  7. Save the profit value in the array at the current array index, and increment the array index variable.
  8. After the loop is concluded, sort the array, in descending order with with "ArraySort()", based on the count obtained from the array index variable.
  9. Create a new variable for the total profit and set it to an initial value of "0.00".
  10. Loop through the first 4 (or less based on array index count) elements of the array, and add the value to the total profit variable.
 
Fernando Carreiro:
  1. Use "OrdersTotal()" to obtain the count of currently open positions.
  2. Create an array of this maximum size base on the above count
  3. Create an index variable for the array and set it to an initial value of "0".
  4. Loop through all the open positions using "OrderSelect()" to select them.
  5. Filter by symbol "OrderSymbol()", magic number "OrderMagicNumer()" and if necessary, by type "OrderType()".
  6. Obtain the profit for the position using "OrderProfit()".
  7. Save the profit value in the array at the current array index, and increment the array index variable.
  8. After the loop is concluded, sort the array, in descending order with with "ArraySort()", based on the count obtained from the array index variable.
  9. Create a new variable for the total profit and set it to an initial value of "0.00".
  10. Loop through the first 4 (or less based on array index count) elements of the array, and add the value to the total profit variable.

Thank You Very Much for ur explain...i will try the algoritm

 
asror bersemi:

Please do as you were asked.

Fernando Carreiro:

Please re-edit your post and format your code properly using the "Alt-S" or by clicking the code Icon "</>" in the posting toolbar.

 
Keith Watford:

Please do as you were asked.

ok thank you 

 
asror bersemi:ok thank you 

And yet, you still did not correct your post and properly format the code! Don't expect any further help until you comply.

 
Fernando Carreiro:

And yet, you still did not correct your post and properly format the code! Don't expect any further help until you comply.

still get solution, i have not right code now 

 
asror bersemi: still get solution, i have not right code now 

Respect the rules of the forum and fix your post!