Download MetaTrader 5
To add comments, please log in or register
How to launch your trading signal and become a provider
muhamad rais abd halim
126
muhamad rais abd halim 2014.12.28 14:10 

Hi,

This is my idea. I want make moving or dynamic taking profit if pending order fill...

PO=pending order, TP=taking profit

Example:

PO3---------------------------- = PO3 trigger, all TP at TP3

 

PO2---------------------------- = PO2 trigger, all TP at TP2

TP3++++++++++++++++

PO1---------------------------- = PO1 trigger, all TP at TP1

TP2++++++++++++++++

 

TP1++++++++++++++++

Carl Schreiber
5939
Carl Schreiber 2014.12.28 14:17  

ok, go a head.

Good luck!

Alain Verleyen
Moderator
28548
Alain Verleyen 2014.12.28 15:09  
hampeh:

Hi,

This is my idea. I want make moving or dynamic taking profit if pending order fill...

PO=pending order, TP=taking profit

Example:

PO3---------------------------- = PO3 trigger, all TP at TP3

 

PO2---------------------------- = PO2 trigger, all TP at TP2

TP3++++++++++++++++

PO1---------------------------- = PO1 trigger, all TP at TP1

TP2++++++++++++++++

 

TP1++++++++++++++++

What is your problem ?
whroeder1
13605
whroeder1 2014.12.28 18:51  
You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
muhamad rais abd halim
126
muhamad rais abd halim 2014.12.29 05:53  

Maybe you can look to my coding....

Still not working on modify taking profit..

All previous value stored in array.....

Thanks in advanced..... 

--------------------

for(i=0;i<ArraySize(OpenPriceBuy);i++)

{

   int minValueIdx=ArrayMinimum(OpenPriceBuy,WHOLE_ARRAY,0);

   if(MarketInfo(Symbol(),MODE_BID)<= minValueIdx)

   { 

      //--- modify order and exit

      if(!OrderModify(buyticket[i],0,0,TPPriceBuy[i],0,Red))

      Print("OrderModify error ",GetLastError());

      OpenPriceBuy[i] = OpenPriceBuy[i+1];

   }

---------------------------------- 

whroeder1
13605
whroeder1 2014.12.29 16:30  
hampeh: Maybe you can look to my coding....
  if(MarketInfo(Symbol(),MODE_BID)<= minValueIdx)
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Why are you using a function all instead of just the predefined variable Bid?
  3. Bid is a double (1.2345) Array indexes are int (0, 1, 2, 3...) What does price <= index possibly mean?
  4. for(i=0;i<ArraySize(OpenPriceBuy);i++){
       :
       OpenPriceBuy[i] = OpenPriceBuy[i+1];
    What happens when i is the last array element [ArraySize(OpenPriceBuy) - 1]?
muhamad rais abd halim
126
muhamad rais abd halim 2015.01.05 05:31  

Thanks all...

I'll update latest code... ASAP... 

muhamad rais abd halim
126
muhamad rais abd halim 2015.01.05 05:52  

fuh....

 

Now i had ordermodify error 1

 

for(int cnt=0 ;cnt<OrdersTotal();cnt++)

{

bool resulttemp = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);


   int maxValueIdx=ArrayMaximum(OpenPriceBuy,WHOLE_ARRAY,0);

   if(MarketInfo(Symbol(),MODE_BID) == OpenPriceBuy[maxValueIdx])

   { 

      j = maxValueIdx+1;

      if(j>ArraySize(OpenPriceBuy))

      {

         j = ArraySize(OpenPriceBuy)-1;

      }


            //Modified TP only for open buy and pending buy (buy limit)

            if(OrdersTotal() > 0 && (OrderType() == OP_BUY || OrderType()== OP_BUYLIMIT))

            {

            if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TPPriceBuy[j],OrderExpiration(),Red))

            { Print("Buy OrderModify error :",GetLastError()); } else {Print(TPPriceBuy[maxValueIdx]," modified to : ",TPPriceBuy[j]);}

            

            

            TPPriceBuy[maxValueIdx] = TPPriceBuy[ArraySize(OpenPriceBuy)-1];

            OpenPriceBuy[maxValueIdx] = OpenPriceBuy[ArraySize(OpenPriceBuy)-1];

            }

      }

   } 

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.01.05 07:08  
It is better you Edit and post your code using SRC (besides video icon).
muhamad rais abd halim
126
muhamad rais abd halim 2015.01.05 07:15  
ok... now i see more beautiful.....
for(int cnt=0 ;cnt<OrdersTotal();cnt++)
{
bool resulttemp = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   int maxValueIdx=ArrayMaximum(OpenPriceBuy,WHOLE_ARRAY,0);
   if(MarketInfo(Symbol(),MODE_BID) == OpenPriceBuy[maxValueIdx])
   { 
      j = maxValueIdx+1;
      if(j>ArraySize(OpenPriceBuy))
      {
        j = ArraySize(OpenPriceBuy)-1;
      }
            //Modified TP only for open buy and pending buy (buy limit)
            if(OrdersTotal() > 0 && (OrderType() == OP_BUY || OrderType()== OP_BUYLIMIT))
            {
            if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),TPPriceBuy[j],OrderExpiration(),Red))

            { Print("Buy OrderModify error :",GetLastError()); } else {Print(TPPriceBuy[maxValueIdx]," modified to : ",TPPriceBuy[j]);}

            TPPriceBuy[maxValueIdx] = TPPriceBuy[ArraySize(OpenPriceBuy)-1];
            OpenPriceBuy[maxValueIdx] = OpenPriceBuy[ArraySize(OpenPriceBuy)-1];
            }
      }
   } 
/
To add comments, please log in or register