Who can help me?

 

My EA work on H1 chart.If first cam a buy signal he must open a buy order,after 10 or 20 minutes can arrive a sell signal in the same bar ,so the buy order must remain open and he must open now a sell order. In other words, for every bar i can have maximum 2 pozitions: a buy and a sell order opened,if one of them will be closed by TP and a new signal cam he must open again the same position . When bar is finis is possibile for one of them to remain open, but for the new bar wich cam if a new signal appears he must open again the same type of position.In time is posible for many bars to have remaining the same type of positions open but not more then one for every bar and the same type of order.I try to use Time[0] ,but if the position is close do the TP is not open another one in the same bar in case of new signal cam, and the ticket=0 is not ok because i can have 2 positions at time opened and past bars with opened positions remaining.It must be something between this two ideas but i cant figured how!

It is some how complicated but to be easy undestandibile, i need a function who can work like : if buy_order(on this bar)==0 or sell_order(on this bar)==0 open a new position buy or sell, but  must use this criteria only for current bar and not for the next one or for the past bars!

Thank's in advance!

 
gingaiulian:

My EA work on H1 chart.If first cam a buy signal he must open a buy order,after 10 or 20 minutes can arrive a sell signal in the same bar ,so the buy order must remain open and he must open now a sell order. In other words, for every bar i can have maximum 2 pozitions: a buy and a sell order opened,if one of them will be closed by TP and a new signal cam he must open again the same position . When bar is finis is possibile for one of them to remain open, but for the new bar wich cam if a new signal appears he must open again the same type of position.In time is posible for many bars to have remaining the same type of positions open but not more then one for every bar and the same type of order.I try to use Time[0] ,but if the position is close do the TP is not open another one in the same bar in case of new signal cam, and the ticket=0 is not ok because i can have 2 positions at time opened and past bars with opened positions remaining.It must be something between this two ideas but i cant figured how!

It is some how complicated but to be easy undestandibile, i need a function who can work like : if buy_order(on this bar)==0 or sell_order(on this bar)==0 open a new position buy or sell, but  must use this criteria only for current bar and not for the next one or for the past bars!

Thank's in advance!

Hello, what if I have idea with reset condition for buy and Sell

maybe like this, hope it can help you and forgive if I'm wrong because I still amateur :)

//------------------------------------------------------------------------------------  
// Here is additional Next for Buy Condition
//------------------------------------------------------------------------------------  
if  (  buy Condition && CountForBuy<1 )  
      {  
        ticket = OrderSend(Symbol(),OP_BUY,..........
        
        if (ticket == 0) {Sleep(2000);RefreshRates();}
         resetbuycondition=0;
         resetsellcondition=1;
      }  
          
//------------------------------------------------------------------------------------  
// Here is additional Next for Sell Condition
//------------------------------------------------------------------------------------  
        if ( Sell COndition  && CountForSell<1)
      {        
    ticket =    OrderSend(Symbol(),OP_SELL,.....
      

        if (ticket == 0) {Sleep(2000);RefreshRates();}
         resetbuycondition=1;
         resetsellcondition=0;
      }

 
It can work on half only! We supose one buy order is open,your code will reset the buy condition ,and seems to be ok until now but on the next bar (if actual buy order remains open) the CountForBuy it will be =1 so it will not open another buy order if new buy condition is come! Right?
 

I made it! This is the code.

      int CountForSell=0;
      for(int i=0;i<OrdersTotal(); i++ ){
      if(OrderSelect(i, SELECT_BY_POS)==true){
      if (OrderType()==OP_SELL)
      if(OrderOpenTime()>=Time[0])CountForSell++; ;
      int TotalSymbolSell = CountForSell; 
      }
      }
      if ((condition)&& (TotalSymbolSell<1))  {
      sell();

      }

Enyway , thank you Achmad Wijaya for your time!

I work on many codes and ideas in the last 8 years on the forex,How many dreams and plans and times spents for that,and for what ,i am not yet  become profitable,Sometimes i wonder if is not gest dreams and empty hopes in this direction!Now i have this code who seems to work verry nicelly but is not the first time, how much it will work until become uselless like meny others!I like to hear nice story at least about success about the others .

 
gingaiulian:

I made it! This is the code.

      int CountForSell=0;
      for(int i=0;i<OrdersTotal(); i++ ){
      if(OrderSelect(i, SELECT_BY_POS)==true){
      if (OrderType()==OP_SELL)
      if(OrderOpenTime()>=Time[0])CountForSell++; ;
      int TotalSymbolSell = CountForSell; 
      }
      }
      if ((condition)&& (TotalSymbolSell<1))  {
      sell();

      }

Enyway , thank you Achmad Wijaya for your time!

I work on many codes and ideas in the last 8 years on the forex,How many dreams and plans and times spents for that,and for what ,i am not yet  become profitable,Sometimes i wonder if is not gest dreams and empty hopes in this direction!Now i have this code who seems to work verry nicelly but is not the first time, how much it will work until become uselless like meny others!I like to hear nice story at least about success about the others .

You're wellcome :)
Reason: