One trade per order.... - page 2

 

Your still trying to solve this? sorry (i don't know how i got so distracted). i've done a little bit of fiddling by adding variables "Occur" and "newtrenddistance".

i use a variable, usually called something "Occur", to check and make sure a process isn't done twice. the second one, newtrenddistance, is because i haven't taken the time to determine how much time your scalper has to make a desicsion if the trend has changed or not. i've assumed you've wanted to use closes to determine a new trend also.

basically, i added the few expressions,

OrderSelect(LastTicket,SELECT_BY_TICKET,MODE_HISTORY);

Occur = True;

if((OrderType() == OP_SELL && iClose(NULL,0,1) > iClose(NULL,0,newtrenddistance)) || (OrderType() == OP_BUY && iClose(NULL,0,1) < iClose(NULL,0,newtrenddistance)))

{

Occur = False;

}

if(Occur == False)

{

OrderSend.....................;

}

i'm not sure if this is going to execute perfectly what i had in mind, or live up to your complete desires from this addition, but it sparks an idea.

sorry, but i didn't have time to test it.

Files:
 
bool lastPosSellPos()
{
    HistorySelect(0,TimeCurrent()); 
//--- 
   uint     total=HistoryDealsTotal(); 
   ulong    ticket=0; 
   long     type; 
//--- for all deals 
   for(uint i=0;i<total;i++) 
     { 
      //--- try to get deals ticket 
      if((ticket=HistoryDealGetTicket(i))>0) 
        { 
         //--- get deals properties  
         type  =HistoryDealGetInteger(ticket,DEAL_TYPE);  
         //--- only for current symbol 
         if(type==POSITION_TYPE_SELL)) 
           {
            return (true);
           }
        }
     }
return (false);
 }
///--
bool lastPosBuyPos()
{
    HistorySelect(0,TimeCurrent()); 
//--- 
   uint     total=HistoryDealsTotal(); 
   ulong    ticket=0; 
   long     type; 
//--- for all deals 
   for(uint i=0;i<total;i++) 
     { 
      //--- try to get deals ticket 
      if((ticket=HistoryDealGetTicket(i))>0) 
        { 
         //--- get deals properties  
         type  =HistoryDealGetInteger(ticket,DEAL_TYPE);  
         //--- only for current symbol 
         if(type==POSITION_TYPE_BU)) 
           {
            return (true);
           }
        }
     }
return (false);
 }
//---
add this code to your trading instruction Example
if ( LastPosSellPos()==true && PositionsTotal()<1)
  {
   trade.Buy
  }
//Viceversa for sell trade