Download MetaTrader 5

Please complete the expert help me

To add comments, please log in or register
ghobar
25
ghobar 2015.11.21 20:24 
Please complete the expert help me
I want to signal when the indicator signal Hammer = sell and  Shooting Star = buy 
But not execute buy and sell orders.

Please advise on what part I am in trouble

 

 

//+------------------------------------------------------------------+

//|                                                                  |

//|      Copyright © 2014, Click Hooshmand Guilan LLC                |

//|               http://www.Yahoo.com                            |

//|                                                                  |

//+------------------------------------------------------------------+

#property copyright "Copyright © 2014, Click "

#property link      "http://www.Yahoo.com"


extern int Magic1=1;

extern int Magic2=2;

extern bool Show_Alert = true;

extern int  Pointer_Offset = 9;

extern int  High_Offset = 10;

extern bool Display_ShootStar = true;

extern bool Show_ShootStar_Alert = true;

extern int  Offset_ShootStar = 12;

extern color Color_ShootStar = Aqua;

extern int Text_ShootStar = 8;

extern bool Display_Hammer = true;

extern bool Show_Hammer_Alert = true;

extern int  Offset_Hammer = 6;

extern color Color_Hammer = Aqua;

extern int Text_Hammer = 8;

extern double Candle_WickBody_Percent=0.90;

extern int CandleLength=12;

extern int slippage=6;

extern int stoploss=210;

extern int takeprofit=280;

extern bool usetrail=false;

extern int TrailingStop=100;

extern double Risk=40.0;


//---- buffers

double upArrow[];

double downArrow[];


//+------------------------------------------------------------------+

//| expert initialization function                                   |

//+------------------------------------------------------------------+

int init() {


//---- indicators

   

   SetIndexStyle(0,DRAW_ARROW, EMPTY);

   SetIndexArrow(0,72);

   SetIndexBuffer(0, downArrow);

      

   SetIndexStyle(1,DRAW_ARROW, EMPTY);

   SetIndexArrow(1,71);

   SetIndexBuffer(1, upArrow);

      

   return(0);

  }

//+------------------------------------------------------------------+

//| expert deinitialization function                                 |

//+------------------------------------------------------------------+

int deinit() {

   ObjectsDeleteAll(0, OBJ_TEXT);

   return(0);

}

//+------------------------------------------------------------------+

//| expert start function                                            |

//+------------------------------------------------------------------+

int start()

  {

  if(Orders()==0)

  {

   if(Shooting()=="buy")

   {

   Pendbuy();

    }

  

  if(Shooting()=="sell")

  {

  Pendsell();

  }

  }

  if(usetrail==true)

  Trail();

   return(0);

  }

//+------------------------------------------------------------------+

int Orders()

{

int num=0;


 for(int i=OrdersTotal()-1;i>=0;i--)

 {

 OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

 

 if(OrderMagicNumber()==Magic1 || OrderMagicNumber()==Magic2)

  

  num++;

  

  }

return(num);

}

//+------------------------------------------------------------------+

string Shooting()

{

double b1=iCustom(Symbol(),0,"hamar.shotingstar",true,9,10,true,true,12,Aqua,8,true,true,6,Aqua,8,0.90,12,0,1);


double b2=iCustom(Symbol(),0,"hamar.shotingstar",true,9,10,true,true,12,Aqua,8,true,true,6,Aqua,8,0.90,12,1,1);


double b3=iCustom(Symbol(),0,"hamar.shotingstar",true,9,10,true,true,12,Aqua,8,true,true,6,Aqua,8,0.90,12,0,2);


double b4=iCustom(Symbol(),0,"hamar.shotingstar",true,9,10,true,true,12,Aqua,8,true,true,6,Aqua,8,0.90,12,1,2);


Comment(b1,"\n",b2,"\n",b3,"\n",b4);


if(Volume[0]<=1)

{

 if(b1!=1 && b2==1 && b3==1 && b4!=1)

 return("buy");

 

 {

 

 if(b1==1 && b2!=1 && b3!=1 && b4==1)

 return("sell");

 }

}

   return(0);

  }

//---------------------------------------------------------------------

void Pendbuy()

{

OrderSend(Symbol(),OP_BUY,Get_Lots(Risk),Ask,slippage,Ask-stoploss*MathPow(10,-Digits)

,Ask+takeprofit*MathPow(10,-Digits),"www.FxNewTech.com",Magic1,0,Blue);


}

//---------------------------------------------------------------------

void Pendsell()

{

OrderSend(Symbol(),OP_SELL,Get_Lots(Risk),Bid,slippage,Bid+stoploss*MathPow(10,-Digits)

,Bid-takeprofit*MathPow(10,-Digits),"www.FxNewTech.com",Magic2,0,Red);

}

//---------------------------------------------------------------------

//+------------------------------------------------------------------+

double Get_Lots(double lRisk)

{

double

   Lots = AccountEquity() * lRisk/100/1000;

   if (MarketInfo(Symbol(),MODE_MINLOT) > Lots)Lots = MarketInfo(Symbol(),MODE_MINLOT);

   if (MarketInfo(Symbol(),MODE_MAXLOT) < Lots)Lots = MarketInfo(Symbol(),MODE_MAXLOT);

   return(Lots);

}

//+------------------------------------------------------------------+

void Trail()

{

for(int i=OrdersTotal()-1;i>=0;i--)

{

 OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

 

 if(OrderMagicNumber()==Magic1)

 {

  if((Bid-OrderOpenPrice())>MathPow(10,-Digits)*TrailingStop)

  {

   if(OrderStopLoss()<(Bid-MathPow(10,-Digits)*TrailingStop))

   {

   OrderModify(OrderTicket(),OrderOpenPrice(),Bid-MathPow(10,-Digits)*TrailingStop,OrderTakeProfit(),0,Green);

    }

   }  

  }

  

 if(OrderMagicNumber()==Magic2)

 {

  if((OrderOpenPrice()-Ask)>(MathPow(10,-Digits)*TrailingStop))

  {

   if((OrderStopLoss()>(Ask+MathPow(10,-Digits)*TrailingStop)))

   {

   OrderModify(OrderTicket(),OrderOpenPrice(),Ask+MathPow(10,-Digits)*TrailingStop,OrderTakeProfit(),0,Yellow);

    }

   } 

  }

 }

}


 

 

 

 


Sherif Hasan
7292
Sherif Hasan 2015.11.22 05:48  

Its easy way...

https://www.mql5.com/en/job

Freelance service at MQL5.com
Freelance service at MQL5.com
  • www.mql5.com
Orders for the development of automated trading programs
ghobar
25
ghobar 2015.11.23 10:05  
Hello to all
I did not find the problem solved Is it possible for me to solve this problem here.
Indicator put relevant and expert in this field.
Thanks
To add comments, please log in or register