#property link "" double ind1[6]; extern double TakeProfit = 35; extern double Lots = 10; extern int Lookback = 10; extern int movingperiod = 21; extern int movingshift = 0; extern int volumes = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- GetSubIndicatorValue(); //---- return(0); } //+------------------------------------------------------------------+ //Fetch all subindicator value into the system void GetSubIndicatorValue() { string indicator1 = "Gann Hi-lo Activator SSL"; ind1[0]= iCustom(NULL,0,indicator1,Lookback,0,0); ind1[1]= iCustom(NULL,0,indicator1,Lookback,0,1); ind1[2]= iCustom(NULL,0,indicator1,Lookback,0,2); //double ma=iMA(NULL,0,movingperiod,movingshift,MODE_SMA,PRICE_WEIGHTED,0); Comment("Gann: ",ind1[0]," ",ind1[1]," ",ind1[2],"\n","Bars: ",Open[0]," ",Close[1]," ",Close[2],Volume[0]); int total,cnt; total=OrdersTotal(); if (Volume[0]==1) // On first tick of current bar only { if(total<1) { //Trade between 5:15 and 18:00 GMT if((Hour()>=0&&Hour()<5)||(Hour()>=18&&Hour()<24)) return(0); //if((Ask>ind1[1]) && (ind1[2]>=Open[2]) && (ind1[1]<=Close[1]) && Ask>ma) if((Ask>ind1[1]) && (ind1[2]>=Open[2]) && (ind1[1]<=Close[1]) && Volume[1]>volumes) //Alert("BUY ",ind1[1],Open[1],Close[1]); int buyorder; //buyorder=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-TakeProfit*Point,Ask+TakeProfit*Point,"Buy Order",16384,0,Green); buyorder=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"Buy Order",16384,0,Green); if(buyorder<0) { Print("OrderSend failed with error #",GetLastError()); return(0); } //if((Bid=Close[1]) && Bid=Close[1]) && Volume[1]>volumes) //Alert("SELL ",ind1[1],Open[1],Close[1]); int sellorder; //sellorder=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+TakeProfit*Point,Bid-TakeProfit*Point,"Sell Order",16385,0,Red); sellorder=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"Sell Order",16385,0,Red); if(sellorder<0) { Print("OrderSend failed with error #",GetLastError()); return(0); } } for(cnt=0;cnt=Close[1]) && Volume[1]>volumes) { OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close position return(0); // exit } } } if(OrderType()==OP_SELL) // go to short position { // should it be closed? if((Ask>ind1[1]) && (ind1[2]>=Open[2]) && (ind1[1]<=Close[1]) && Volume[1]>volumes) { OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close position return(0); // exit } } } } return(0); }