It seems working fine and I can not find out the problem.
Maybe you should show your EA code rather than the code for the Indicator which you have already said is working OK.
EA just print out the result.
percent=0.01;
Print("poc1:",iCustom(NULL,0,"POC", percent,0,1));
Print("poc2:",iCustom(NULL,0,"POC", percent,0,2));
Print("poc3:",iCustom(NULL,0,"POC", percent,0,3));
Print("poc4:",iCustom(NULL,0,"POC", percent,0,4));
Print("poc5:",iCustom(NULL,0,"POC", percent,0,5));
Print("poc6:",iCustom(NULL,0,"POC", percent,0,6));
Print("poc7:",iCustom(NULL,0,"POC", percent,0,7));
Print("poc8:",iCustom(NULL,0,"POC", percent,0,8));
Strange your indicator is a kind of a Zigzag indicator you have only one buffer
but a zigzag has a high and a low value
your indicator is at bar 0 already pointing a new high
So maybe you have to make another buffer in the indicator for separating highs and lows
buffer0 looks pointing high
EA just print out the result.
Strange your indicator is a kind of a Zigzag indicator you have only one buffer
but a zigzag has a high and a low value
your indicator is at bar 0 already pointing a new high
So maybe you have to make another buffer in the indicator for separating highs and lows
buffer0 looks pointing high
You can download the indicator to try, 1 buffer is enough, include high and low.
Of course I modify Zigzag, which have 3 buffer.
But the EA is probably where the error is . . . show your code.
//+------------------------------------------------------------------+ //| SSR.mq4 | //| Copyright ?2012, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //#property copyright "Copyright 2012, smallcase" //#property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| 参数预设 | //+------------------------------------------------------------------+ #define MAGICMA 20050610 extern double Lots = 0.1; //开仓大小 extern double percent = 0.01; //回弹百分比 extern int period = 200; //基本趋势 extern int MODE_MA =1; extern double risk =0.015; //止损百分比 //double ZigzagBuffer[1000]; //bool downloadhistory=false; //+------------------------------------------------------------------+ //| Start function | //+------------------------------------------------------------------+ void start() { //---- check for history and trading if(Bars<100 || IsTradeAllowed()==false) return; if(CalculateCurrentOrders(Symbol())!=0) CheckForClose(); if(CalculateCurrentOrders(Symbol())==0) CheckForOpen(); //---- } //+------------------------------------------------------------------+ //| Check for open order conditions 开仓条件 | //+------------------------------------------------------------------+ void CheckForOpen() { double poc1,poc2,poc3,ma; int res, shift=1, pos1,pos2,pos3; //---- go trading only for first tiks of new bar 仅在新烛的第一柱交易。是为了避免重复交易,只能在开市价交易 if(Volume[0]>1) return; poc1=iCustom(NULL,0,"POC",percent,0,shift); // 取得平均指数和POC的值 Print("poc1:",iCustom(NULL,0,"POC", percent,0,1)); Print("poc2:",iCustom(NULL,0,"POC", percent,0,2)); Print("poc3:",iCustom(NULL,0,"POC", percent,0,3)); Print("poc4:",iCustom(NULL,0,"POC", percent,0,4)); Print("poc5:",iCustom(NULL,0,"POC", percent,0,5)); Print("poc6:",iCustom(NULL,0,"POC", percent,0,6)); Print("poc7:",iCustom(NULL,0,"POC", percent,0,7)); Print("poc8:",iCustom(NULL,0,"POC", percent,0,8)); ma=iMA(NULL,0, period,0,MODE_MA,PRICE_CLOSE,pos1); } //+------------------------------------------------------------------+ //| Check for close order conditions 清仓 | //+------------------------------------------------------------------+ void CheckForClose() { double ma1; double ma2; double ma3; //---- go trading only for first tiks of new bar if(Volume[0]>1) return; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue; //---- check order type 查看定单类型 if(OrderType()==OP_BUY) { // if(lasthigh/Low[1]>RSI) OrderClose(OrderTicket(),OrderLots(),Bid,3,White); break; } if(OrderType()==OP_SELL) { if(ma1>ma2) OrderClose(OrderTicket(),OrderLots(),Ask,3,White); break; } } //---- } //+------------------------------------------------------------------+ //| Calculate open positions 计算开仓数量 | //+------------------------------------------------------------------+ int CalculateCurrentOrders(string symbol) { int buys=0,sells=0; //---- for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA) { if(OrderType()==OP_BUY) buys++; if(OrderType()==OP_SELL) sells++; } } //---- return orders volume if(buys>0) return(buys); else return(-sells); }see, the code is really simple, not even start, just print the value and found the problem.
see, the code is really simple, not even start, just print the value and found the problem.
Your iCustom call calls an Indicator called POC not PercenteOfxChange
Yes, "POC" and "Percent Of Change" is the same.
//+------------------------------------------------------------------+ //| Comments4.mq4 | //| Copyright © 2012, Tjipke de Vries | //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, Tjipke de Vries" #property link "" #property indicator_chart_window extern double percent = 0.01; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- subPrintDetails(); //---- return(0); } //+------------------------------------------------------------------+ //----------------------- PRINT COMMENT FUNCTION void subPrintDetails() { string sComment = ""; string sp = "----------------------------------------\n"; string NL = "\n"; double poc1=iCustom(NULL,0,"POC", percent,0,1); double poc2=iCustom(NULL,0,"POC", percent,0,2); double poc3=iCustom(NULL,0,"POC", percent,0,3); double poc4=iCustom(NULL,0,"POC", percent,0,4); double poc5=iCustom(NULL,0,"POC", percent,0,5); double poc6=iCustom(NULL,0,"POC", percent,0,6); double poc7=iCustom(NULL,0,"POC", percent,0,7); double poc8=iCustom(NULL,0,"POC", percent,0,8); sComment = "Comments 4 Copyright © 2012, Tjipke" + NL; sComment = sComment + NL; sComment = sComment + "poc1 " + DoubleToStr(poc1,Digits) + NL; sComment = sComment + "poc2 " + DoubleToStr(poc2,Digits) + NL; sComment = sComment + "poc3 " + DoubleToStr(poc3,Digits) + NL; sComment = sComment + "poc4 " + DoubleToStr(poc4,Digits) + NL; sComment = sComment + "poc5 " + DoubleToStr(poc5,Digits) + NL; sComment = sComment + "poc6 " + DoubleToStr(poc6,Digits) + NL; sComment = sComment + "poc7 " + DoubleToStr(poc7,Digits) + NL; sComment = sComment + "poc8 " + DoubleToStr(poc8,Digits) + NL; sComment = sComment + NL; Comment(sComment); } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I created an indicator similar as Zigzag, but simplify as Percent Of Change of the price.
It seems working fine and I can not find out the problem.
But when I use this indicator in EA, the value show in EA is different from real value.
Appreciate someone can help or give some ideas why? or may email to me alan-zhou@126.com.
Thanks in advance.
See the below indicator for 8 days. Which is EUR/DAY Daily until 31/12/2011.
The real value as below same as above indicator:
Below is the value in EA, day1,3,4 is different from real one.