Candle Wick Length code for EA

 

HI,

I have been trying to put together my first self made EA I ahve been able to solve the 1st issue with stochastic now its the candle wick length. I want to instruct the EA to only take trades when the upper wick is greater than or equal to 20pips for a sell and the lower wick is greater than or equal to 20pips. Below is a code I created but I am not sure if it is correct because it does not work well:

bool buy_condition_3 = ((Open[1] - Low[1]) >= 200*Point ) || ((Close[1] - Low[1]) >= 200*Point) ;

For buy


 bool sell_condition_3 = ((High[1] - Close[1]) >= 200*Point ) || ((High[1] - Open[1]) >= 200*Point) ;

For sell.


Is there standard way of writing this?

 

1) There is no standard :-)

2) for the upper wick I would use (High[1] - MathMax(Open[1],Close[1]) >= 200*Point)
and for the lower wick (MathMin(Open[1],Close[1]) - Low[1] >= 200*Point)

 
Or write self documenting code
double bodyTop = MathMax(Open[1],Close[1]);
double bodyBot = MathMin(Open[1],Close[1]);
double upWick  = High[1] - bodyTop;
double loWick  = bodyBot -  Low[1];

bool sell_condition_3 = upWick >= 200*Point;
 
 
Chinedu Onuoha:

HI,

I have been trying to put together my first self made EA I ahve been able to solve the 1st issue with stochastic now its the candle wick length. I want to instruct the EA to only take trades when the upper wick is greater than or equal to 20pips for a sell and the lower wick is greater than or equal to 20pips. Below is a code I created but I am not sure if it is correct because it does not work well:

For buy


For sell.


Is there standard way of writing this?


Thanks I see this as almost the same as the later suggestion and I have tried the 2 but the order is not executing. I have attached the EA please what could be wrong?


Thanks for your help

Files:
Pinbar_EA.mq4  5 kb
 
Chinedu Onuoha: what could be wrong?
There are no mind readers here and our crystal balls are cracked.
  1. Start using the new Event Handling Functions.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  2. if( buy_condition_1  &&  buy_condition_2  &&  buy_condition_3 ){
    Use the debugger or print out your variables, including _LastError and find out why.

  3.           LongTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);
    
    Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 
whroeder1:
There are no mind readers here and our crystal balls are cracked.
  1. Start using the new Event Handling Functions.
              Event Handling Functions - Functions - Language Basics - MQL4 Reference

  2. Use the debugger or print out your variables, including _LastError and find out why.

  3. Check your return codes for errors and report them.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

I am sure you tried to help but you ended up getting me more confused.

I know that there are no mind readers here that was why I added the attachment  because I have exhausted all within my current knowledge capacity or is it now a crime for someone to ask questions if they are not informed ? I am new to this and all the stuff you mentioned are new to me.


Sorry this did not help and it is sad.


Thanks for trying

 
You asked, you posted the code. I didn't see anything obvious (other than posted.) Stop your poor little me ("is it now a crime") and you start debugging your code.
 
whroeder1:
You asked, you posted the code. I didn't see anything obvious (other than posted.) Stop your poor little me ("is it now a crime") and you start debugging your code.

I don't know how to do that (debugg)

 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
Reason: