View Single Post
  #5 (permalink)  
Old 06-30-2006, 04:31 PM
cardio cardio is offline
Senior Member
 
Join Date: Sep 2005
Location: St Louis, MO, USA
Posts: 176
cardio is an unknown quantity at this point
that is not the hassle

I am starting to think that its interbankfx trying to prevent scalping when the market is tight. It works when the market is not tight - still it is confusing as once one's sl and tp are greater then MarketInfo(Symbol(),MODE_STOPLEVEL) it should open the trade.


Anyway Here is the code I use

Code:
StopLoss = NormalizeDouble((TradeAbovePct/100)*(DemaH-DemaL)*(1/Point),0);
 if (StopLoss<=MarketInfo(Symbol(),MODE_STOPLEVEL)) StopLoss=MarketInfo(Symbol(),MODE_STOPLEVEL)+3;
 
 TakeProfit = NormalizeDouble(2*((DemaH-DemaL)*(1/Point)),0);
 if (TakeProfit<=MarketInfo(Symbol(),MODE_STOPLEVEL)) TakeProfit=2*(MarketInfo(Symbol(),MODE_STOPLEVEL)+3);
 
//Then I call a buy and sell as needed
//e.i

OpenBuy1(10);
OpenSell1(10);

////////////////////////////////////////////////
bool OpenBuy1(int pips1)
{
       int ticket;
       string comment="";   

        //reset defaults
        use_MTBE = use_MTBEd;
        use_split = use_splitd;
       
       
       RefreshRates();
       price1 = Ask;
       stoploss1 = NormalizeDouble(price1-StopLoss*Point,Digits);
       tp1 = NormalizeDouble(price1+TakeProfit*Point,Digits);
       //expire1 = iTime(Symbol(),TimeFrame,0)+TimeFrame*HoursStopOpen*60;
       
      Print("Openbuy lots: ", Lots);           
       if(UseStopLoss)
           ticket=OrderSend(Symbol(),OP_BUY,Lots,price1,2,stoploss1,tp1,comment,MAGICMA,0,Orange);
       else
           ticket=OrderSend(Symbol(),OP_BUY,Lots,price1,2,0,tp1,comment,MAGICMA,0,Orange);
         
        if(ticket>0)
          {
          if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
            {
             Print("BUY order opened : ",OrderOpenPrice());
             //time1 = CurTime()+2*60*Period();
             return(true);
             }
          }
         else 
         {
         Print("Error opening BUY order : ",GetLastError()); 
         Print("OrderDetails: BuyPrice : ",price1," ,CurrentAsk : ", Ask," ,stoploss : ",stoploss1," ,takeprofit : ",tp1," ,slippage : ",2);
         return(false);
         }

            
}

bool OpenSell1(int pips1)
{

       int ticket;
       string comment="";
        
        //reset defaults
        use_MTBE = use_MTBEd;
        use_split = use_splitd;
                
        RefreshRates();
        price1 = Bid;
        stoploss1 = NormalizeDouble(price1+StopLoss*Point,Digits) ;
        tp1 = NormalizeDouble(price1-TakeProfit*Point,Digits);
//        expire1 = iTime(Symbol(),TimeFrame,0)+TimeFrame*HoursStopOpen*60;

       Print("Opensell lots: ", Lots); 
            if(UseStopLoss)
               ticket=OrderSend(Symbol(),OP_SELL,Lots,price1,2,stoploss1,tp1,comment,MAGICMA,0,Red);
            else
               ticket=OrderSend(Symbol(),OP_SELL,Lots,price1,2,0,tp1,comment,MAGICMA,0,Red);
            
            if(ticket>0)
              {
               if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) 
               {
                 Print("SELL order opened : ",OrderOpenPrice());
               // time1 = CurTime()+2*60*Period();
                 return(true);
               }
              }
            else 
            {
              Print("Error opening SELL order : ",GetLastError()); 
              Print("OrderDetails: SellPrice : ",price1," ,CurrentBid : ", Bid," ,stoploss : ",stoploss1," ,takeprofit : ",tp1," ,slippage : ",2);
              return(false);
            }


}
Reply With Quote