How to count number of opend positions? - page 2

 
Yes i will study this. Thanks, appreciate your helps :)
 

Ok it was nice. I did place codes in my EA.

I up this topic cause for this part:

datetime TC=TimeCurrent;

for(int a=0; a<ArraySize(DebutList); a++)
      {
         if(TC >= StrToTime(DebutList[a]) && TC <= StrToTime(DebutList[a]) + 4)
         {
            if(iClose(Symbol(), TimeFrame, 1) < iClose(Symbol(), TimeFrame, 2))// Bougie 1 < Bougie 2
            {
               ticket = OrderSend(Symbol(), OP_BUY, LotS, NormalizeDouble(ask, digits), 300, 0, 0, "", MagicS, CLR_NONE);
                  if(ticket > 0)
                  {
                     OrderModify(ticket, OrderOpenPrice(), NormalizeDouble(SLBuy,digits), NormalizeDouble(tpSB, digits), 0, CLR_NONE);
                  }
            }  
         }
      }


i don't need count all OrderType.

DebutList[a] is a list of different time in string format.

I just want that if ticket > 0 , boucle is done now and will begin again when the next string time is coming.

I tried boulce for and while but logically no good results. Cause i use time interval, i lose some open trade cause no ticks were there during the interval. And sometimes cause there is 3 ticks during this interval it open 3 orders.

If i could have a small counter which say: if order opened (ticket >0) stop the boucle to the next new time (DebutList[a]). It not a problem if one order is open and the last order which was opened by the last signal is opened too.

i was searching in the forum but no codes seems to be a solution for my problem.

Thanks for all your help !

 
Kane59:
ticket = OrderSend(Symbol(), OP_BUY, LotS, NormalizeDouble(ask, digits), 300, 0, 0, "", MagicS, CLR_NONE);
if(ticket > 0){
  OrderModify(ticket, OrderOpenPrice(), NormalizeDouble(SLBuy,digits), NormalizeDouble(tpSB, digits), 0, CLR_NONE);
 
  1. Never use normalize. Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
  2. Always check your return codes. What are Function return values ? How do I use them ? - MQL4 forum



 
Kane59:

Ok it was nice. I did place codes in my EA.

I up this topic cause for this part:


boucle ?  can you explain this in English please ?


Could you also explain what you are trying to achieve ?  what are the times held in the DebutList array ? 

 
RaptorUK:


boucle ?  can you explain this in English please ?


Could you also explain what you are trying to achieve ?  what are the times held in the DebutList array ? 


Sorry, in french we said boucle, it's cycle operator for and while.

time are 11:30 and 15:00 in the array.

I just want to stop ordersend when a first order is opened when time is 11:30. So when time is 15:00, the EA have to OrderSend again. The first order opened in 11:30 could be opened too. So it's possible that the two orders are opened a same time. I just want one order per hour without close the last to allow open the second order.

 

yes but i tried other ways and no results. ask and bid are it:

ask = MarketInfo( symbol(), Mode_ASK);

bid = MarketInfo(Symbol(), Mode_BID);

 
Kane59:

Sorry, in french we said boucle, it's cycle operator for and while.

time are 11:30 and 15:00 in the array.

I just want to stop ordersend when a first order is opened when time is 11:30. So when time is 15:00, the EA have to OrderSend again. The first order opened in 11:30 could be opened too. So it's possible that the two orders are opened a same time. I just want one order per hour without close the last to allow open the second order.

So all you need to do is first check the currently open orders . . .  if you have an order that has an OrderOpenTime() of between 11:30 and 14:59 and the time is currently between 11:30 and 14:59 you don't open a new one . . . then do the same for 15:00 to ??:??
 

No no:

if time is 11:30   Open a position only one.

if time is 15:00   Don't look if the first position (opened in 11:30) is open yet, open a position only one. Don't care if the is opened yet !

i just want limit at 1 trade per string hour when it arrives like that:


datetime TC=TimeCurrent;

for(int a=0; a<ArraySize(DebutList); a++)
      {
         if(TC >= StrToTime(DebutList[a]) && TC <= StrToTime(DebutList[a]) + 4)
         {
            if(iClose(Symbol(), TimeFrame, 1) < iClose(Symbol(), TimeFrame, 2))// Bougie 1 < Bougie 2
            {
               ticket = OrderSend(Symbol(), OP_BUY, LotS, NormalizeDouble(ask, digits), 300, 0, 0, "", MagicS, CLR_NONE);
                  if(ticket > 0)
                  {
                     OrderModify(ticket, OrderOpenPrice(), NormalizeDouble(SLBuy,digits), NormalizeDouble(tpSB, digits), 0, CLR_NONE);
                     Stop open somes trades and wait for the next string hour.
                  }
            }  
         }
      }


I don't know how to do, that's why i ask for help. I see the logic but not how to write.

i tried that:

datetime TC=TimeCurrent;

for(int a=0; a<ArraySize(DebutList); a++)
      {  int Order = 1;
         if(TC >= StrToTime(DebutList[a]) && TC <= StrToTime(DebutList[a]) + 4)
         {
            if(iClose(Symbol(), TimeFrame, 1) < iClose(Symbol(), TimeFrame, 2))// Bougie 1 < Bougie 2
            {
               while (Order <= 1)
               {
               ticket = OrderSend(Symbol(), OP_BUY, LotS, NormalizeDouble(ask, digits), 300, 0, 0, "", MagicS, CLR_NONE);
                  if(ticket > 0)
                  {
                     OrderModify(ticket, OrderOpenPrice(), NormalizeDouble(SLBuy,digits), NormalizeDouble(tpSB, digits), 0, CLR_NONE);
                     Order++;
                  }
               }
            }  
         }
      }
No effect to stop multi opening trade
 
Kane59:

No no:

Yes, Yes.  

Read what I wrote not what you thought I wrote . . .  check the Open orders,  if there is already one opened for the current time do not open a second  . . . for the current time . . . .  do the same at the 2nd time,  15:00 . . .

 
RaptorUK:

Yes, Yes.  

Read what I wrote not what you thought I wrote . . .  check the Open orders,  if there is already one opened for the current time do not open a second  . . . for the current time . . . .  do the same at the 2nd time,  15:00 . . .


Ah yes i understood write like that.


I will try code it,


thanks a lot.

Reason: