Found this indicator in FF and would like to try it in the strategy tester, but i cannot get buy/sell signal from the indicator to the EA when it shows an arrow on the chart. I know i have to use the iCustom, but i'm in doubt on how to use it correctly.
The indicator looks like this:
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.
The indicator looks like this:
Inserted Code
#define INDICATOR_VERSION 20101105 // VERSION 6 #define INDICATOR_NAME "123PatternsV6JK" #define RELEASE_LEVEL "Public" #define MT4_BUILD 226 #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 DodgerBlue // UpperLine #property indicator_color2 OrangeRed // LowerLine #property indicator_color3 LimeGreen // Target1 #property indicator_color4 LimeGreen // Target2 #property indicator_color5 DodgerBlue // BuyArrow #property indicator_color6 OrangeRed // SellArrow #property indicator_color7 DodgerBlue // BullDot #property indicator_color8 OrangeRed // BearDot #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_width5 3 // BuyArrow #property indicator_width6 3 // SellArrow #property indicator_width7 3 // BullDot #property indicator_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"; // indicator buffers double UpperLine[]; double LowerLine[]; double Target1[]; double Target2[]; double BuyArrow[]; double SellArrow[]; double BullDot[]; double BearDot[]; double firsthigh, firstlow, lasthigh, lastlow, prevhigh, prevlow, signalprice, brokenline; datetime firsthightime, firstlowtime, lasthightime, lastlowtime, prevhightime, prevlowtime, signaltime; datetime redrawtime; // remember when the indicator was redrawn int signal; #define NOSIG 0 #define BUYSIG 1 #define SELLSIG 2 string indicatorFileName; bool returnBars; bool calculateValue; int timeFrame; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { int i; for(i=0; i<=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); IndicatorShortName(INDICATOR_NAME); IndicatorDigits(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
//+------------------------------------------------------------------+ //| My First EA.mq4 | //| MQL4 tutorial on quivofx.com | //| | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property version "3.00" //--- input parameters input double LotSize=0.1; input int Slippage=3; input int MagicNumber=5555; extern double MinTail = 5; input int TakeProfit=50; input int StopLoss=12; extern double TrailingStop=0; //--- global variables double MyPoint; int MySlippage; double DistanceX, DistanceY; double TH; double TL; double YH; double YL; double DBYH; double DBYL; double DailyHigh = 0; double DailyLow = 0; datetime now = 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; double LastMA; int CountCandles = 0; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { double 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(ticket<0) { Print("OrderSend failed with error #",GetLastError()); } else { Print("OrderSend placed successfully"); } // Modify 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 modified successfully."); } } // Open Sell Order void OpenSell() { //Open Sell Order int ticket = OrderSend(_Symbol,OP_SELL,LotSize,Bid,MySlippage,0,0,"SELL",MagicNumber); if(ticket<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 modified successfully."); } } // Get My Points double MyPoint() { double CalcPoint = 0; if(_Digits == 2 || _Digits == 3) CalcPoint = 0.01; else if(_Digits == 4 || _Digits == 5) CalcPoint = 0.0001; return(CalcPoint); } // Get My Slippage int MySlippage() { int CalcSlippage = 0; if(_Digits == 2 || _Digits == 4) CalcSlippage = Slippage; else if(_Digits == 3 || _Digits == 5) CalcSlippage = Slippage * 10; return(CalcSlippage); } // Check if there is a new bar bool IsNewBar() { static datetime RegBarTime=0; datetime ThisBarTime = Time[0]; if (ThisBarTime == RegBarTime) { return(false); } else { RegBarTime = ThisBarTime; return(true); } } // Returns the number of total open orders for this Symbol and MagicNumber int TotalOpenOrders() { int total_orders = 0; for(int order = 0; order < OrdersTotal(); order++) { if(OrderSelect(order,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber() == MagicNumber && OrderSymbol() == _Symbol) { total_orders++; } } return(total_orders); }
Blindly following others will make you blind!