[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 596

 
evillive:
Question: in the visual testing mode the indicator lines are drawn only at the end of testing, is this the case for everyone or am I doing something wrong?

all of them.

https://www.mql5.com/ru/forum/131853/page2#463027

 
advise how to correctly open orders with losses and takeaways in an alpari advisor (code)
 
link1:
advise how to correctly open orders with losses and takeaways in an alpari advisor (code)

Do you know how to open orders with FST and TP in an EA (code) correctly?
 
zxc:

Do you know how to "correctly open orders with losses and takeaways" in another brokerage company?

And what is the difference between opening an order in Alpari and opening an order in Oanda or another brokerage company?
 
zxc:

Do you know how to "correctly open orders with losses and takeaways" in another brokerage company?

I have been working with other brokerage companies, my EA works, but not with Alpari, that's why I am asking, maybe there are some peculiarities?
 
link1:

I have a good feeling with other brokerage companies, my EA works, but not with Alpari.


This is where you should have started. In the terminal, when you open an order manually, can you put stops immediately?

What does it say where the order type is? Immediate Execution or Market Execution?

 
zxc:


This is where you should have started. In the terminal, when you open an order manually, can you put stops immediately?

What does it say where the order type is? Immediate execution or market execution?


As for Alpari, if you have market execution, you cannot place SL or TP, only if you have a pending order, you can do it on a demo account, like on a micro one.

I have also paid attention to this issue and I have decided to modify my EA by placing SL and TP without SL and then, to modify it and set SL and TP.

But how to modify it? )) I copied the modification from some Expert Advisor, but there was an error in the code and it didn't compile. To be honest there is no article about modification and example with trailing stop in the tutorial. I just started to learn language and this is my first EA and I don't know how to modify orders properly...

i also think maybe the problem is in the 5 digits? what do you think?

 

How about this? And for take profit in about the same way...

for(int i = 0; i < total; i++)

     {
       OrderSelect(i, SELECT_BY_POS, MODE_TRADES); 
       // check for symbol & magic number
       if(OrderSymbol()==Symbol() && OrderMagicNumber()== Magic) 
         {
           if(OrderType() == OP_BUY)  // long position is opened
            {

                  if(OrderStopLoss()==0)
                   {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*sl,OrderTakeProfit(),0,Orange);
                    return(0);
                   }
            } 
           if(OrderType() == OP_SELL)  // short position is opened
            {

                 if(OrderStopLoss()==0)
                  {
                    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*sl,OrderTakeProfit(),0,Orange);
                    return(0);
                  }
            }
         }
     }

You can not modify the stop loss order at all in this cycle, and close the order when it reaches the stop level, for DC the order will look like without a stop loss, but is closed by the EA clearly when the stop loss level is passed (sl variable):

   for(int i = 0; i < total; i++)
     {
       OrderSelect(i, SELECT_BY_POS, MODE_TRADES); 
       // check for symbol & magic number
       if(OrderSymbol()==Symbol() && OrderMagicNumber()== Magic) 
         {
           if(OrderType() == OP_BUY)  // long position is opened
            {
               if((OrderOpenPrice()-Ask)<Point*sl) // stoploss
                 {
                    OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Aqua);
                 }
               if((Bid-OrderOpenPrice())>Point*(ts+minp)) //trail
                 {
                  if(OrderStopLoss()<(Bid-Point*ts))
                   {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*ts,OrderTakeProfit(),0,Orange);
                   }
                 }
            } 
           if(OrderType() == OP_SELL)  // short position is opened
            {
               if((Bid-OrderOpenPrice())>Point*sl) // stoploss
                 {
                    OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Magenta);
                 }
               if((OrderOpenPrice()-Ask)>Point*(ts+minp)) //trail
                {
                 if(OrderStopLoss()>(Ask+Point*ts))
                  {
                    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*ts,OrderTakeProfit(),0,Orange);
                  }
                }
            }
         }
     }
 
I want to create a 2-dimensional array [ticket][opening price]. the question is what type to declare the array as int or duble?
 
dmmikl86:
I want to create a 2-dimensional array [ticket][opening price]. the question is what type to declare the array as int or dub?

opening price is double
Reason: