If I am asking to much please tell me.
I am trying to learn this and feel that I am getting now where.
I would really appreciate the help.
Thanks in advance.
You'll not get much response unless you post more of your code - are we expected to guess the code-block of CheckShortOpen() for example ? - and tell us exactly what errors are being thrown. In order to do that, it would help if you made use of the Print() function in your code to assess the logic flow, to check the contents of key variables and to log errors using GetLastError().
CB
Okay the file is below.
//+------------------------------------------------------------------+ //| candles.mq4 | //| www.globalmarketingdesign.com | //+------------------------------------------------------------------+ #property copyright "" #property link "www.globalmarketingdesign.com" /* $Log: /TEXASNOMAD/candles.mq4 $ * * 1 1/03/09 22:43 Pion * first version with reliable orders * */ #include <stderror.mqh> //Completion to stderror.mqh #define ERR_TRADE_EXPIRATION_DENIED 147 //Expirations are denied by broker. #define OBJECT_NAME_PATTERN "c4n8l3s" //+------------------------------------------------------------------+ //| Inputs | //+------------------------------------------------------------------+ extern string Header__1 = " --------------- Initial Parameters ------------------ "; extern double LotSize = 0.5; extern double TailHeight = 10; extern int MinCandleHeight = 5; extern int NoCoverRule = 0; extern int MomentumRule1 = 0; extern int MomentumRule2 = 0; extern int TakeProfit = 20; extern int StopLoss = 10; extern int TrailingStop = 10; extern int ActiveHours = 5; //+------------------------------------------------------------------+ //| Globals | //+------------------------------------------------------------------+ int MagicNumber; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { MagicNumber = WindowHandle(Symbol(), Period()); DeleteAllObjects(); DrawLabels("www.globalmarketingdesign.com", 1); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { DeleteAllObjects(); return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double Lo = Low[0]; double Hi = High[0]; double Op = Open[0]; double Cl = Close[0]; bool longTradeOpen = false; bool shortTradeOpen = false; bool longTradeClose = false; bool shortTradeClose = false; // Long Open if(CheckLongOpen(Lo, Hi, Op, Cl) >= TailHeight) { longTradeOpen = true; } // Long Close if(CheckLongClose(Lo, Hi, Op, Cl) >= TailHeight) { longTradeClose = true; } // Short Open if(CheckShortOpen(Lo, Hi, Op, Cl) >= TailHeight) { shortTradeOpen = true; } // Short Close if(CheckShortClose(Lo, Hi, Op, Cl) >= TailHeight) { shortTradeClose = true; } return(0); } //+------------------------------------------------------------------+ //| Check Long Open | //+------------------------------------------------------------------+ double CheckLongOpen(double Lo, double Hi, double Op, double Cl) { // Long Trade, Open Candle: // Open - Low // ---------- = n% // High - Low return (((Op-Lo) / (Hi-Lo)) * 100); } //+------------------------------------------------------------------+ //| Check Long Close | //+------------------------------------------------------------------+ double CheckLongClose(double Lo, double Hi, double Op, double Cl) { // Long Trade, Closed Candle: // Close - Low // ----------- = n% // High - Low return (((Cl-Lo) / (Hi-Lo)) * 100); } //+------------------------------------------------------------------+ //| Check Short Open | //+------------------------------------------------------------------+ double CheckShortOpen(double Lo, double Hi, double Op, double Cl) { // Short Trade, Open Candle: // High - Close // ------------ = n% // High - Low return (((Hi-Cl) / (Hi-Lo)) * 100); } //+------------------------------------------------------------------+ //| Check Short Close | //+------------------------------------------------------------------+ double CheckShortClose(double Lo, double Hi, double Op, double Cl) { // Short Trade, Closed Candle: // High - Open // ----------- = n% // High - Low return (((Hi-Op) / (Hi-Lo)) * 100); } //+------------------------------------------------------------------+ //| Delete Objects | //+------------------------------------------------------------------+ void DeleteAllObjects() { int objectCount = ObjectsTotal(); for (int index = objectCount - 1; index >= 0; index--) { string objectName = ObjectName(index); if (StringSubstr(objectName, 0, StringLen(OBJECT_NAME_PATTERN)) == OBJECT_NAME_PATTERN) ObjectDelete(objectName); } } //+------------------------------------------------------------------+ //| Draw Copywrite | //+------------------------------------------------------------------+ double DrawLabels(string text, int lineIndex) { string objName = OBJECT_NAME_PATTERN + lineIndex + "_Copyright"; int xPos = 8; int yPos = lineIndex * 15; int cornerID = 1; ObjectDelete(objName); ObjectCreate(objName, OBJ_LABEL, 0, 0, 0); ObjectSet(objName, OBJPROP_CORNER, cornerID); ObjectSet(objName, OBJPROP_XDISTANCE, xPos); ObjectSet(objName, OBJPROP_YDISTANCE, yPos); ObjectSet(objName, OBJPROP_BACK, true); ObjectSetText(objName, text, 14, "Times", Orange); WindowRedraw(); }
All the code is now apart of the message. I am trying to make a candle ea.
I would like some help to calculate pips and view previous bars and such, but have no real clue what to do.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
My Inputs are as follows:
Lot Size: Determines initial trade size.
Example: 0.5 – EA initiates two positions at 0.5 lots each
Tail Height %: Minimum percentage of total Candle height represented by the Tail (see equations for each of 4 candles above).
Example: 70 – Tail must be at least 70% of total candle height from high to low.
Min Candle Height: Minimum height of candle in pips.
Example: 10 – Candle must be 10 pips or more to qualify as trade trigger
No Cover Rule: number of prior bars which tail’s High or Low must exceed.
Example: 10 – Tail High/Low must be greater than any price during the preceding 10 bars
Momentum Rule 1 - Pips: number of pips that price must move in number of price bars specified in Momentum Rule 2 before a Qualified Hammer.
Momentum Rule 2 – Bars: number of bars in which pips move must take place.
Take Profit: Number of pips past entry price at which profitable trade will be closed. ***If this is set to 0, both positions exit with Trailing Stop input.
Example: 20 – Long trade entered at 1.4105, T/P set at 1.4125 upon entry
Stop Loss: Number of pips past the tail’s end (candle’s low on long trade, candle high on short trade) at which losing trade will be closed.
Example: 5 – Short trade entered at 0.6850 with candle tail high at 0.6860; S/L is set at 0.6865
Trailing Stop: Number of pips that S/L will trail 2nd half of trade after each new high/low is made.
***If this is set to 0, both positions exit at Take Profit input.
Active Hours:
Beginning time – sets the GMT hour that EA becomes active.
Ending time – sets the GMT hour that EA becomes inactive (goes inactive at scheduled time if no trades are open; if trade is open, goes inactive as soon as trade is closed out by EA rules).
My Qualifying Candle(s) or Hammer(s):
Tail is n% of total Hammer height – Input #2
Hammer is n pips in height (H to L) – Input #3
No Cover Rule: There is “no cover” for preceding n bars – Input #9
Long trades: Tail low must be the lowest price for the preceding n bars. If a lower price was marked at any time during the prior n bars, the Long Hammer is disqualified and no trade is initiated.
Short trades: Tail high must be the highest price for the preceding n bars. If a higher price was marked at any time during the prior n bars, the Short Hammer is disqualified and no trade is initiated.
Momentum Rule: There must be an x pips move over n bars prior to Hammer (x pips move down for Long Hammer, x pips move up for Short Hammer) – Input #10
The the code below is what I have so far, it will take care of the first qualifying hammer.I could use a little push, hint, or idea on how to do and or make the other checks for a qualifying hammer.