PLEASE,i need help for this simple strategy.

 

how do this script:

example:

GBP/USD

no indicator

lot:1

if BID above 1.4501 be LONG 1 lot,

then if BID below 1.4501 close LONG and go SHORT 1lot (or vice versa).

the script must always keep 1 open position(1lot) LONG or SHORT if BID is >1.4501 or <1.4501.

thanks a lot.

 

Try this simple one. May be it will work for you. I haven't tried it though.

//+------------------------------------------------------------------+
//|                                                   TestScript.mq4 |
//|                                   Copyright © 2010, Makala Corp. |
//|                                            http://www.makala.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Makala Corp."
#property link      "http://www.makala.net"

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
 //------------------------------------------------------------------+
 //Input constants
 double Lots = 1.0;           //Lot size
 double BidLevel = 1.4501;    //Triger Bid Level
 //---------------
      {
        
         //BUY triger 
           if(Bid > BidLevel)  
            { 
               OrderSelect(SELECT_BY_POS, MODE_TRADES);
               OrderClose(OrderTicket(),OrderLots(),Bid,5,Magenta); // close short position
               OrderSend(Symbol(),OP_BUY,Lots,Ask,5,0,0,"expert comment",255,0,CLR_NONE);
               Alert(GetLastError());                          
               return;
            }
         //---- 
         //SELL Triger
           if(Bid < BidLevel)  
            { 
               OrderSelect(SELECT_BY_POS, MODE_TRADES);
               OrderClose(OrderTicket(),OrderLots(),Ask,5,Magenta); // close long position
               OrderSend(Symbol(),OP_SELL,Lots,Bid,5,0,0,"expert comment",255,0,CLR_NONE);   
               Alert(GetLastError());                          
               return;
            }
         //----
                  
      }   
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
if (OrderSelect(0, SELECT_BY_POS, MODE_TRADES)) {
    OrderClose(OrderTicket(),...
    RefreshRates();
}
 

thanks,but i have problem the script open much more than 1 lot,

each time bid touch bid level he send 1 new order,

May be it will work if we add MAX lot function.

thanks for any help.

Reason: