Found this indior atnigeriaforextradingand might love to attempt it from the egy tester, but I cannot find buy/sell signal in the indior into the EA once it reveals an arrow on the chart. I know I have to use the iCustom, but I'm in doubt about how best to use it correctly.
The indior looks like this:
Inserted Code #define INDICATOR_VERSION 20101105 // VERSION 6 #define INDICATOR_NAME 123PatternsV6JK #define RELEASE_LEVEL Public #define MT4_BUILD 226 #property indior_chart_window #property indior_buffers 8 #property indior_color1 DodgerBlue // UpperLine #property indior_color2 OrangeRed // LowerLine #property indior_color3 LimeGreen // Target1 #property indior_color4 LimeGreen // Target2 #property indior_color5 DodgerBlue // BuyArrow #property indior_color6 OrangeRed // SellArrow #property indior_color7 DodgerBlue // BullDot #property indior_color8 OrangeRed // BearDot #property indior_width1 1 #property indior_width2 1 #property indior_width3 1 #property indior_width4 1 #property indior_width5 3 // BuyArrow #property indior_width6 3 // SellArrow #property indior_width7 3 // BullDot #property indior_width8 3 // BearDot extern string Notes = 15pip RangeBars Basic Setup; extern string TimeFrame = Current time frame; extern int ZigZagDepth = 4; extern double RetraceDepthMin = 0.4; extern double RetraceDepthMax = 1.0; extern bool ShowAllLines = True; extern bool ShowAllBreaks = True; extern bool ShowTargets = False; extern double Target1Multiply = 1.5; extern double Target2Multiply = 3.0; extern bool HideTransitions = True; extern bool alertsOn = true; extern bool alertsOnCurrent = false; extern bool alertsMessage = true; extern bool alertsSound = false; extern bool alertsNotify = true; extern bool alertsEmail = true; extern string UniqueID = GlobalVariable1; // indior buffers double UpperLine#91;#93;; double LowerLine#91;#93;; double Target1#91;#93;; double Target2#91;#93;; double BuyArrow#91;#93;; double SellArrow#91;#93;; double BullDot#91;#93;; double BearDot#91;#93;; double firsthigh, firstlow, lasthigh, lastlow, prevhigh, prevlow, signalprice, brokenline; datetime firsthightime, firstlowtime, lasthightime, lastlowtime, prevhightime, prevlowtime, signaltime; datetime redrawtime; // remember when the indior was redrawn int signal; #define NOSIG 0 #define BUYSIG 1 #define SELLSIG 2 string indiorFileName; bool returnBars; bool calculateValue; int timeFrame; // ------------------------------------------------------------------ //| Custom indior initialization function | // ------------------------------------------------------------------ int init() { int I; for(I=0; ilt;=7; I ) SetIndexEmptyValue(I,EMPTY_VALUE); if(ShowAllLines == True) SetIndexStyle(0,DRAW_LINE); else SetIndexStyle(0,DRAW_NONE); if(ShowAllLines == True) SetIndexStyle(1,DRAW_LINE); else SetIndexStyle(1,DRAW_NONE); if(ShowTargets == True) SetIndexStyle(2,DRAW_LINE); else SetIndexStyle(2,DRAW_NONE); if(ShowTargets == True) SetIndexStyle(3,DRAW_LINE); else SetIndexStyle(3,DRAW_NONE); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,SYMBOL_ARROWUP); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,SYMBOL_ARROWDOWN); SetIndexStyle(6,DRAW_ARROW); SetIndexArrow(6,159); // BullDot (WingDings character) SetIndexStyle(7,DRAW_ARROW); SetIndexArrow(7,159); // BearDot (WingDings character) SetIndexBuffer(0,UpperLine); SetIndexBuffer(1,LowerLine); SetIndexBuffer(2,Target1); SetIndexBuffer(3,Target2); SetIndexBuffer(4,BuyArrow); SetIndexBuffer(5,SellArrow); SetIndexBuffer(6,BullDot); SetIndexBuffer(7,BearDot); IndiorShortName(INDICATOR_NAME); IndiorDigits(Digits); if(ShowAllLines == True) SetIndexLabel(0,UpperLine); else SetIndexLabel(0,); if(ShowAllLines == True) SetIndexLabel(1,LowerLine); else SetIndexLabel(1,); if(ShowTargets == True) SetIndexLabel(2,Target1); else SetIndexLabel(2,); if(ShowTargets == True) SetIndexLabel(3,Target2); else SetIndexLabel(3,); SetIndexLabel(4,BuyArrow); SetIndexLabel(5,SellArrow); SetIndexLabel(6,); SetIndexLabel(7,);
And here is the EA: this is the line I'm fighting with - double L_1=iCustom(NULL,0,123PatternsV6JK,4,0); -- 4 and 5 is the buffer for the buy and sell arrow.
Inserted Code //p ------------------------------------------------------------------ //| My First EA.mq4 | //| MQL4 tutorial on quivofx.com | //| | //p ------------------------------------------------------------------ #property copyright #property Hyperlink #property version 3.00 //-- input parameters input double LotSize=0.1; input int Slippage=3; input int MagicNumber=5555; extern dual MinTail = 5; input int TakeProfit=50; input int StopLoss=12; extern dual TrailingStop=0; //-- global factors double MyPoint; int MySlippage; dual DistanceX, DistanceY; dual TH; dual TL; dual YH; dual YL; dual DBYH; dual DBYL; dual DailyHigh = 0; dual DailyLow = 0; datetime currently = TimeCurrent(); datetime LastActiontime = 0; int x=0; int I=0; int j=0; bool FirstTimeOnChart = false; input int iHour1 = 7; input int iHour2 = 20; input int MidnightHour = 0; input int MidnightMinute = 0; dual LastMA; int CountCandles = 0; //p ------------------------------------------------------------------ //| Expert initialization serve | //p ------------------------------------------------------------------ int OnInit() //p ------------------------------------------------------------------ //| Expert deinitialization function | // ------------------------------------------------------------------ void OnDeinit(const int reason) //p ------------------------------------------------------------------ //| Expert tick function | // ------------------------------------------------------------------ void OnTick() dual L_1=iCustom(NULL,0,123PatternsV6JK,4,0); Comment(L1 = L_1); // Open Buy Order void OpenBuy() // Open Buy Order int ticket = OrderSend(_Symbol,OP_BUY,LotSize,Ask,MySlippage,0, 0,BUY,MagicNumber,0,clrRed); if(ticketlt;0) Print(OrderSend failed with error #,GetLastError()); else Print(OrderSend placed successfully); // Alter Buy Order bool res = OrderModify(ticket,OrderOpenPrice(),Ask-StopLoss*MyPoint,Ask TakeProfit*MyPoint,0,clrBlue); if(! Res) Print(Error in OrderModify. Error code=,GetLastError()); else Print(Order altered successfully.) ; // Open Sell Order void OpenSell() //Open Sell Order int ticket = OrderSend(_Symbol,OP_SELL,LotSize,Bid,MySlippage,0 ,0,SELL,MagicNumber); if(ticketlt;0) Print(OrderSend failed with error #,GetLastError()); else Print(OrderSend placed successfully); // Modify Sell Order bool res = OrderModify(ticket,OrderOpenPrice(),Bid StopLoss*MyPoint,Bid-TakeProfit*MyPoint,0); if(! Res) Print(Error in OrderModify. Error code=,GetLastError()); else Print(Order altered successfully.) ; // Buy My Points double MyPoint() _Digits == 5) CalcPoint = 0.0001; return(CalcPoint); // Buy My Slippage int MySlippage() // Check if There's a new bar bool IsNewBar() static datetime RegBarTime=0; datetime ThisBarTime = TimeNumber 91;0#93;; if (ThisBarTime == RegBarTime) return(false); else RegBarTime = ThisBarTime; return(true); // Returns the Amount of complete open orders for this Symbol and MagicNumber int TotalOpenOrders() int total_orders = 0; for(int order = 0; order lt; OrdersTotal(); order ) if(OrderSelect(order,SELECT_BY_POS,MODE_TRADES)==f alse) break; if(OrderMagicNumber() == MagicNumber OrderSymbol() == _Symbol) total_orders ; yield (total_orders);