Download MetaTrader 5

I do not understand why I get this error

To add comments, please log in or register
disqplay
22
disqplay  

I have created a custom indicator that compiles with zero error or warnings. Yet when I try to use it in an expert advisor using the iCustoms function it tell me the OnCalculate function is not found in the custom indicator. Has anyone else run into this problem and if so how did you correct it. I have attached the screenshot of both the compiled indicator and the failed expert. Any and all support to correct this error would be greatly appreciated.

Robert 

David Raine
140
David Raine  
disqplay:

I have created a custom indicator that compiles with zero error or warnings. Yet when I try to use it in an expert advisor using the iCustoms function it tell me the OnCalculate function is not found in the custom indicator. Has anyone else run into this problem and if so how did you correct it. I have attached the screenshot of both the compiled indicator and the failed expert. Any and all support to correct this error would be greatly appreciated.

Robert 

if you not show your code, how we gonna know what you doing?
disqplay
22
disqplay  

Sorry about that David just was not thinking here is the attached codes, highlow seo ver1 is the indi and the other is the expert using the iCustom call.

Robert 

Carl Schreiber
7678
Carl Schreiber  

You probably have called an outdated version of your indicator?

Your iCustom(..) requests: "lowhighseo ver0" and "lowhighseo ver2" - but you post "highlow_ seo_ver_1"( with OnCalculate() )?

disqplay
22
disqplay  
calli:

You probably have called an outdated version of your indicator?

Your iCustom(..) requests: "lowhighseo ver0" and "lowhighseo ver2" - but you post "highlow_ seo_ver_1"( with OnCalculate() )?

The indicator was written by me last week so it is not outdated.

As far as the posting I have tried calling several version of the same indicator that all compile correctly but none work when custom called by the expert

Robert 

Paul Anscombe
4432
Paul Anscombe  
disqplay:

Sorry about that David just was not thinking here is the attached codes, highlow seo ver1 is the indi and the other is the expert using the iCustom call.

Robert 

you are using it wrong

iCustom returns an integer of the handle for the indicator and not the value of the indicator buffer


have a look at the documentation

Carl Schreiber
7678
Carl Schreiber  
Paul Anscombe:

you are using it wrong

iCustom returns an integer of the handle for the indicator and not the value of the indicator buffer


have a look at the documentation

Only in mt5 but not in mt4!

iCustom - MQL4 Documentation
iCustom - MQL4 Documentation
  • docs.mql4.com
iCustom - MQL4 Documentation - MQL4 Documentation
Paul Anscombe
4432
Paul Anscombe  
calli:

Only in mt5 but not in mt4!

This is the mql5 site...  should post the query on the correct site

Ziheng Zhuang
6222
Ziheng Zhuang  

   

 //#property indicator_chart_window

//+------------------------------------------------------------------+
//|                                      lowhighseoexperradvisor.mq4 |
//|                           Copyright 2016, Robert H Toutaint      |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://rtoutaint@gmail.com"
#property version   "1.00"
#property description "This ea is for testing bar-since events"
#property strict
//#property indicator_chart_window

#include <stderror.mqh>
#include <stdlib.mqh>


//--- input parameters
extern double StopLoss=10;
extern double TakeProfit=40;
input double   LotSize=0.12;

extern int Slippage=30;
extern int MagicNumber=963;


double pips;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
// Determine what a pip is.
   pips =Point; //.00001 or .0001. .001 .01.
   if(Digits==3||Digits==5)
   pips*=10;   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   Checkforsignal();
   
  }
//+------------------------------------------------------------------+
//|                 Trigger                                                 |
//+------------------------------------------------------------------+
 void Checkforsignal()

  {
   static datetime candletime = 0;
   if(candletime != Time[0]) 
   {
  //+------------------------------------------------------------------+
  //|           buy trigger                                                       |
  //+------------------------------------------------------------------+
    double arrowup = iCustom(NULL,0,"lowhighseo ver_1",2,0);
         if(arrowup != EMPTY_VALUE)  
         EnterTrade(OP_BUY);
     
   
     
//+------------------------------------------------------------------+
//|                     sell trigger                                             |
//+------------------------------------------------------------------+
    double arrowdown = iCustom(NULL,0,"lowhighseo ver_1",3,0);
         if(arrowdown != EMPTY_VALUE)  
       EnterTrade(OP_SELL);
       
       candletime = Time[0];
      }
  }    
//+------------------------------------------------------------------+
//|              Trade type                                                    |
//+------------------------------------------------------------------+
void EnterTrade(int type){

   int err=0;
   double price=Bid, sl=0, tp=0;
   if(type == OP_BUY)
      price =Ask;
   //----
   int ticket =  OrderSend(Symbol(),type,LotSize,price,Slippage,0,0,"MAEA Trade",MagicNumber,0,Magenta); 
   if(ticket>0){
      if(OrderSelect(ticket,SELECT_BY_TICKET)){
         sl = OrderOpenPrice()+(StopLoss*pips);
         tp = OrderOpenPrice()-(TakeProfit*pips);
         if(OrderType()==OP_BUY){
            sl = OrderOpenPrice()-(StopLoss*pips);
            tp = OrderOpenPrice()+(TakeProfit*pips);
         }
         if(!OrderModify(ticket,price,sl,tp,0,Magenta)) {
            err = GetLastError();
            Print("Encountered an error during modification!"+(string)err+" "+ErrorDescription(err)  );
         }
      }
      else{//in case it fails to select the order for some reason 
         Print("Failed to Select Order ",ticket);
         err = GetLastError();
         Print("Encountered an error while seleting order "+(string)ticket+" error number "+(string)err+" "+ErrorDescription(err)  );
      }
   }
   else{//in case it fails to place the order and send us back a ticket number.
      err = GetLastError();
      Print("Encountered an error during order placement!"+(string)err+" "+ErrorDescription(err)  );
      if(err==ERR_TRADE_NOT_ALLOWED)MessageBox("You can not place a trade because \"Allow Live Trading\" is not checked in your options. Please check the \"Allow Live Trading\" Box!","Check Your Settings!");
   }
}


自动交易和策略测试
自动交易和策略测试
  • www.mql5.com
MQL5:MetaTrader 5客户端内置的交易策略语言。语言允许编写您自己的自动交易系统,技术指标,脚本和函数程序库
To add comments, please log in or register