Download MetaTrader 5

Modification Does Not Work I think

To add comments, please log in or register
What is MetaQuotes ID? Find that out from the article!
pascalboy
238
pascalboy 2013.12.06 13:34 
int start()
{

//PIYASADA EMIR YOK ISE İKİ ADET EMİR AÇ
//MEVCUT BIDIN 
//20 PIPS ASAGISINDA SATIM EMRİ AÇ
//20 PIPS YUKARISINDA ALIM EMRI AÇ
//1000 PIPS TP 
//500 PIPS STOPLOSS
RefreshRates();


double XAL=MarketInfo(Symbol(),MODE_ASK);
double XSAT=MarketInfo(Symbol(),MODE_BID);


double AL=NormalizeDouble(XAL,5);
double SAT=NormalizeDouble(XSAT,5);

//EMIR SAYISI 2 NIN ALTINDA OLDUĞU SÜRECE YAP
while(OrdersTotal()<2)
   {
   int Emiral=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+30*Point,3,Ask-500*Point,Ask+1000*Point,0);

      if(OrderSelect(OrderTicket(),SELECT_BY_POS)==true)
         {
           int X=OrderTicket();


            }
   int Emirsat=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-30*Point,3,Bid+500*Point,Bid-1000*Point,0);

      if(OrderSelect(OrderTicket(),SELECT_BY_POS)==true)
         {
            int Y=OrderTicket();


         }





///EMİRLERİ SINIRLARA GÖRE MODİFİYE ET

double OrderNumber=OrderTicket();
double Type=OrderType();
double Sl=OrderStopLoss();
double OrderOpen=OrderOpenPrice();
double Tp=OrderTakeProfit();
if(Type==OP_BUY)
{
double Level1=OrderOpen+20;
double LevelStopLoss=Level1-10;

int OrderSelecct=OrderSelect(OrderNumber,SELECT_BY_POS);
if(Type==OP_BUY && Ask>=Level1)
{

int Modifiye=OrderModify(OrderNumber,0,LevelStopLoss,0,0,0);
}
}
if(Type==OP_SELL)
{
Level1=OrderOpen-20;
LevelStopLoss=Level1+10;

int OrderSeleecct=OrderSelect(OrderNumber,SELECT_BY_POS);
if(Type==OP_SELL && Bid<=Level1)
{
int Modifiyee=OrderModify(OrderNumber,0,LevelStopLoss,0,0,0);
}
}

}
//










return;
}

thank you for your all help.

i couldn't find why the above program does not modify orders.

maybe orderselection format is wrong but i couldn't find it?

Tjipke de Vries
6316
Tjipke de Vries 2013.12.06 15:38  
pascalboy:

thank you for your all help.

i couldn't find why the above program does not modify orders.

maybe orderselection format is wrong but i couldn't find it?


is this programming ??

there are so many things inside your program that it looks like you have no idea what you're doing

int start()
{

//PIYASADA EMIR YOK ISE İKİ ADET EMİR AÇ
//MEVCUT BIDIN 
//20 PIPS ASAGISINDA SATIM EMRİ AÇ
//20 PIPS YUKARISINDA ALIM EMRI AÇ
//1000 PIPS TP 
//500 PIPS STOPLOSS
RefreshRates();

what happens as start() is called ??

What is the use of RefreshRates() at this point ??

double XAL=MarketInfo(Symbol(),MODE_ASK);
double XSAT=MarketInfo(Symbol(),MODE_BID);

the symbol is same as chart what is Ask what is Bid ?? do you have to call marketinfo ??

double AL=NormalizeDouble(XAL,5);
double SAT=NormalizeDouble(XSAT,5);

why is it needed to normalize the price and why with 5 digits

A JPY pair has that also 5 digits ??

while(OrdersTotal()<2) 

why do you wanna open new trades for this condition

there is no correct checking what trades your EA has open

if you try to open new orders then you don't check correctly ..... if it happens

and if not why it fails

also i don't understand

      if(OrderSelect(OrderTicket(),SELECT_BY_POS)==true)
         {
           int X=OrderTicket();


            }

what you do with X and later Y

as you can see it makes no sense this orderselect .....

...... Also what follows

int OrderSelecct=OrderSelect(OrderNumber,SELECT_BY_POS);
if(Type==OP_BUY && Ask>=Level1)
{

why select by pos if you use orderticket do you think it will be 0,1,2 or 3 ?? ......

whroeder1
14530
whroeder1 2013.12.06 15:54  
   int Emiral=OrderSend(Symbol(),OP_BUYSTOP,0.1,Ask+30*Point,3,Ask-500*Point,Ask+1000*Point,0);
    if(OrderSelect(OrderTicket(),SELECT_BY_POS)==true)
You can NOT use OrderTicket() until you do a successful OrderSelect.
pascalboy
238
pascalboy 2013.12.06 18:09  
You look right at some details. But i couldn't work orderselect with selecting ticket number pool.and i changed it to by_ pos. I will Try it again thanks.
whroeder1
14530
whroeder1 2013.12.06 18:56  
Try what again? You CAN NOT use OrderTicket() in either pool. You have to do a sucessful orderSelect before using any of the other trading functions
onur
5
onur 2013.12.06 20:03  
pascalboy:
You look right at some details. But i couldn't work orderselect with selecting ticket number pool.and i changed it to by_ pos. I will Try it again thanks.

slm, dostum, you already assigned the ticket number to emiral or emirsat use them instead of OrderTicket() then use
OrderSelect(emiral,Select_By_Ticket)
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.12.06 20:52  
shanks:

slm, dostum, you already assigned the ticket number to emiral or emirsat use them instead of OrderTicket() then use
Stop and restart the EA and your solution fails . . .
pascalboy
238
pascalboy 2013.12.06 21:02  
Wonderfull Turkish. :)
onur
5
onur 2013.12.06 21:16  
pascalboy:
Wonderfull Turkish. :)

:) yeah just to be noticed only, rest is in the forum way
To add comments, please log in or register