[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 589

 
lottamer:


:)))) there is no such condition as NOT to modify! :)))

if ((once your daddy+mother == chik-chik-chik) == TRUE)

QUESTION: under what conditions would you and I not be having a chick-chick-chick conversation right now! :)))

 
Beowulf:
Can you suggest some literature to get me started and create my own EA! Or is it something that mere mortals cannot do? )))
We (mere mortals) can't do it! ;)))
 
lottamer:


1) it is understandable

2) just checked...in Alpari you can't set stop and take on opening. only through subsequent modification...costs of non-dealing-desk

3) there is a strategy.


Then it's as simple as you suggested. After modification, you set a checkbox and check its status before modification.This is if there is one order. If there is more than one, you need to account for the orders yourself. How to do it is in the articles section.
 
TarasBY:
We (mere mortals) don't get it! ;)))



I'm going to read a little bit of my vacuum ))))
 

Can you advise me, when orders are reopened using rollover, is slippage possible for stop and takeaway values? And how will the stop be set if after the rollover the difference between the open and stop price will be less than the stop level?

My task is as follows. If i have an open market order, i should check if it was opened with rollover and if it was, i should get the ticket of the previous order, that was closed. Maybe someone will tell me the search algorithm? I am currently doing the following:

1. I select the first open order.
2. If it was opened from 23:40 to 00:20, then I continue to check this order further (40-minute window is taken just in case, although in theory you could take from 23:50 to 23:59)
3. I remember the ticket, stop and take price
4. I check all closed orders on the history, where the comments contain the word swap and the currency pairs are the same
5. I compare data on stops and takeovers, if they match, here it is the required order pair, if not, I return to step 1

 

The answer has been found (personally), but I'll leave the post for history! :))))

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

but here's the interesting thing about it...

I have a script (I got it off the net). it modifies an open order.

My idea was to take it as a whole, and insert it in my Expert Advisor as a user-defined function, and call it whenever needed.

The problem is that the compiler gives error "'MB_OK' - variable not defined G:\Program_Files_2\MT4-demo\experts\33.mq4 (153, 37)" - 3rd line from the end

But if you compile the script itself, all is clear!

I figured out what MV_OC is...but I don't understand why it works in the script, but it gets warned in the Expert Advisor?

//+------------------------------------------------------------------+
//|                                               Изменить стопы.mq4 |
//|                                                          Мефодий |
//|                                                    ppc-2@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Мефодий"
#property link      "ppc-2@mail.ru"
#include <WinUser32.mqh>

extern  int  StopLoss = 500; 
extern  int  TakeProfit = 500;

// #property show_confirm
// #property show_inputs

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+

int start()
  {
        bool   result;
        double stop_loss,take_profit,point,bid,ask, lotsize;
        int    cmd, total, error, spread;
        string message;
//----
   total=OrdersTotal();

//----
   for(int i=0; i<total; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         //---- print selected order
         OrderPrint();
         cmd=OrderType();
         point=MarketInfo(OrderSymbol(),MODE_POINT);
         bid= MarketInfo(OrderSymbol(),MODE_BID);
         ask= MarketInfo(OrderSymbol(),MODE_ASK);
         spread=MarketInfo(OrderSymbol(),MODE_SPREAD);     
         //---- buy or sell orders are considered
         if(cmd==OP_BUY || cmd==OP_SELL)
          {
            //---- modify first market order
            while(true)
             {
                if(cmd==OP_BUY){
                        string type = "buy";
                        if(OrderStopLoss()!=0)stop_loss=OrderStopLoss();
                        else stop_loss=OrderOpenPrice()-StopLoss*point;
                        if(OrderTakeProfit()!=0)take_profit=OrderTakeProfit();
                        else take_profit=OrderOpenPrice()+TakeProfit*point;
                }
                     
                else{
                        type = "sell";
                        if(OrderStopLoss()!=0)stop_loss=OrderStopLoss();
                        else stop_loss=OrderOpenPrice()+StopLoss*point;
                        if(OrderTakeProfit()!=0)take_profit=OrderTakeProfit();
                        else take_profit=OrderOpenPrice()-TakeProfit*point;
                }   
                result=OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss, take_profit, 0, CLR_NONE);
                if(result!=true) { error=GetLastError(); Print("LastError = ",error);}
                else {error=0;}
                if(error==135) RefreshRates();
                else break;
              }
                if(error==0){
                        message=message+"Ордер #"+OrderTicket()+" - "+type+" - "+DoubleToStr(OrderLots(), 2)+" успешно модифицирован.\n";
                        }
                        else{
                                if(error == 130){string error_desc = " - Неправильные стопы";} else error_desc = "";
                                if(error != 1)
                        message=message+"Ошибка модификации ордера #"+OrderTicket()+" - "+type+" - "+DoubleToStr(OrderLots(), 2)+". "+error_desc+" \n";
                        }

              //---- print modified order (it still selected after modify)
              OrderPrint();
              continue;             
           }
        }
      else { Print( "Error when order select ", GetLastError()); break;}
     }
        int ret=MessageBox(message, NULL, MB_OK);
        //if(ret==IDOK) return(0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
 

It turns out that the line #include <WinUser32.mqh> must be present.

and this file is in include

 

let me brag...

you don't need any flags when modifying.

it is enough under if condition (cross-means for example)... to take reference to use function BUY and MODIFY in brackets {}

and in this way, the condition will propagate to both actions :))

like this

{My_buy ();

My_modify (); }

:))))))))))))))))))))))))

 

lottamer:

like this

{My_buy ();

My_modify (); }

:))))))))))))))))))))))))

Such a loose interpretation of the program code needs clarification:

    if (условие == true)
    {
        if (Tvoi_buy() == true)  // как вариант
        {Tvoi_Modify();}
    }
:)))
 
TarasBY:

Such a loose interpretation of the program code requires clarification:

:)))


why?

and can My_buy (a non-boolean variable) be checked for TRUE-FALSE ?

The modification goes for sure - the order is open - we need to set the stop-stocks...

Reason: