how can i get the highest after orderopenprice was opened. - page 6

 

I fixed the first issue ( i made error Thanks diostar)

// i shoud put if(OrdersTotal()>0){
if ( ((lastOpenedOpenPriceBuy()-0.0030)>MarketInfo("EURUSD",MODE_BID)) )
{ SELL("EURUSD",S_EURUSD_LS_1,S_EURUSD_TP_1,S_EURUSD_SL_1,S_EURUSD_TS_1,"if ( ( (lastOpenedOpenPriceBuy()-0.0030>MarketInfo(EURUSD,MODE_BID) ) )" ) ;}
}

for the second one:

if ( ((lastOpenedOpenPriceBuy()-lastOpenedOpenPriceSell() )>=0.0060) &&( lastClosedClosePrice()<beforelastClosedClosePrice()) )
{ CLOSESHORT("EURUSD") ;}

I do not know what i should do:
for your information the CLOSESHORT function is:

int CLOSESHORT(string symbol_c) {
CloseAllPositions(symbol_c,OP_SELL,MagicNumberShort);
CloseAllPositions(symbol_c,OP_SELL,MagicNumberShort);
return(0);
}

Thanks

 

I am now confused.

Are you replying about the first function lastOpenedOpenPriceBuy()

I may only be able to deal with that for now. So, what fixes you were up to exactly. What's the code like now?

 
diostar:

I am now confused.

You are not the only one . . stop wasting your time.
 
RaptorUK:
You are not the only one . . stop wasting your time.

you know, this thread is probably one the longest. And after 6 pages, confused. No, I stiill say that's not a "waste".

(It just means its time for new direction, new life, new beginning. For everyone.)

 
I have spent time on this thread also, I have added code and made suggestions . . . when you drag the horse to water, flavour it with hay and add some apples and yet the horse still doesn't want to drink it's time to realise that the horse doesn't want to drink . . . it want's an intravenous drip for it's water intake . . . at that point as far as I am concerned the horse is on it's own.
 
RaptorUK:
I have spent time on this thread also, I have added code and made suggestions . . . when you drag the horse to water, flavour it with hay and add some apples and yet the horse still doesn't want to drink it's time to realise that the horse doesn't want to drink . . . it want's an intravenous drip for it's water intake . . . at that point as far as I am concerned the horse is on it's own.

I see. The final reward may not be "destined" as to have the horse nourished, then the rewards to those who did try, has got to be something else.

Thank the horse for that.

 

Thanks diostar for your helping.

now i got 85% correct the bugs. let us see:

1- we created 4 functions ( please see them at the end of this page)

*lastOpenedOpenPriceBuy()

* lastOpenedOpenPriceSell()

*lastClosedClosePrice()
*beforelastClosedClosePrice()

2- We faced the first issue when we used:

if (  ((lastOpenedOpenPriceBuy()-0.0030)>MarketInfo("EURUSD",MODE_BID))  ) 
   {  SELL("EURUSD",S_EURUSD_LS_1,S_EURUSD_TP_1,S_EURUSD_SL_1,S_EURUSD_TS_1,"if (  ( (lastOpenedOpenPriceBuy()-0.0030)>MarketInfo(EURUSD,MODE_BID) )  )") ;}
  if (  ((lastOpenedOpenPriceSell()+0.0030)<MarketInfo("EURUSD",MODE_BID))  ) 
   {  BUY("EURUSD",B_EURUSD_LS_1,B_EURUSD_TP_1,B_EURUSD_SL_1,B_EURUSD_TS_1,"if (  ( (lastOpenedOpenPriceSell()+0.0030)<MarketInfo(EURUSD,MODE_BID) )  )") ;}

We correct it by adding :

if(OrdersTotal()>0){
  if (  ((lastOpenedOpenPriceBuy()-0.0030)>MarketInfo("EURUSD",MODE_BID))  ) 
   {  SELL("EURUSD",S_EURUSD_LS_1,S_EURUSD_TP_1,S_EURUSD_SL_1,S_EURUSD_TS_1,"if (  ( (lastOpenedOpenPriceBuy()-0.0030)>MarketInfo(EURUSD,MODE_BID) )  )") ;}
  if (  ((lastOpenedOpenPriceSell()+0.0030)<MarketInfo("EURUSD",MODE_BID))  ) 
   {  BUY("EURUSD",B_EURUSD_LS_1,B_EURUSD_TP_1,B_EURUSD_SL_1,B_EURUSD_TS_1,"if (  ( (lastOpenedOpenPriceSell()+0.0030)<MarketInfo(EURUSD,MODE_BID) )  )") ;}
  }

3- The second issue is:

if ( ((lastOpenedOpenPriceBuy()-lastOpenedOpenPriceSell())>=0.0060)&&(((lastOpenedOpenPriceBuy()+lastOpenedOpenPriceSell())/2)<MarketInfo("EURUSD",MODE_BID))
         &&(lastClosedClosePrice()< beforelastClosedClosePrice()) )  
   {  CLOSESHORT("EURUSD") ;}

if i remove &&(lastClosedClosePrice()< beforelastClosedClosePrice()) . then everything will going ok

no problem with :

*((lastOpenedOpenPriceBuy()-lastOpenedOpenPriceSell())>=0.0060)

*(((lastOpenedOpenPriceBuy()+lastOpenedOpenPriceSell())/2)<MarketInfo("EURUSD",MODE_BID))

only problem coming with &&(lastClosedClosePrice()< beforelastClosedClosePrice())

take an Example:

if order number 5 opened and was for sell then order number 6 opened and closed that order was for buy then order number 7 opened and was for buy.

The case will be (lastClosedClosePrice()< beforelastClosedClosePrice())

( Order Number 6 < Order Number 4 ) // since order number 5 still did not close.

What should i do ? I do not know. i tried to used if(OrdersHistoryTotal()>0){then insert all the conditions but no way }

double lastOpenedOpenPriceBuy()
  {
   double ret = 0;
   datetime time=0;
   for(int i=0; i<OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && OrderOpenTime()>time) {
         time = OrderOpenTime();
         ret = OrderOpenPrice();
      }
   }
   
   return(ret);
  }


double lastOpenedOpenPriceSell()
  {
   double ret = 0;
   datetime time=0;
   for(int i=0; i<OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_SELL && OrderOpenTime()>time) {
         time = OrderOpenTime();
         ret = OrderOpenPrice();
      }
   }
   
   return(ret);
  }



double lastClosedClosePrice()
  {
   double ret = 0;
   datetime time = 0;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
      if(OrderType()<2 && OrderCloseTime()>time) {
         time = OrderCloseTime();
         ret = OrderClosePrice();
      }
   }
   
   return(ret);
  }


double beforelastClosedClosePrice()
  {
   double ret = 0;
   double ret2 = 0;
   datetime time = 0;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--) {
      OrderSelect(i, SELECT_BY_POS, MODE_HISTORY);
      if(OrderType()<2 && OrderCloseTime()>time) {
         time = OrderCloseTime();
         ret = ret2;
         ret2 = OrderClosePrice();
      }
   }
   if(ret==0) {
      ret = ret2;
   }
   
   return(ret);
  }
 
double lastOpenedOpenPriceBuy()
  {
   double ret = 0;
   datetime time=0;
   for(int i=0; i<OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && OrderOpenTime()>time) {
         time = OrderOpenTime();
         ret = OrderOpenPrice();
      }
   }
   
   return(ret);
  }

This was NOT was I suggested, and "we" didn't create this. This 100% yours.