Meta-editor 5 error fix,declaration without type

 

Hi guys,

Could you help in fixing this error.

The error is in ( input(title="Naked Forex - Kangaroo Tail & Big Shadow Indicator", overlay = true) i keep getting declaration without type.


//+------------------------------------------------------------------+

//|                                                           KT.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Kangaroo tail indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit; 

 input(title="Naked Forex - Kangaroo Tail & Big Shadow Indicator", overlay = true)

roomToTheLeftPeriod=  input(title="RoomToLeft Candles", type=integer, defval=14, minval=2, maxval=30)
bodyRelativeSize= input(title="Body range", type=integer, defval=3, minval=2, maxval=30)
dojiSize = input(0.1, minval=0.01, title="Doji size")
isDoji=(abs(open - close) <= (high - low) * dojiSize)

//  kangaroo tails
rangePrev1=high[1] - low[1]
rangePrev2=high[2] - low[2]
range=high - low
body=abs(close - open)
topthird = high - range/3.0
lowthird = low + range/3.0
withinPrevCandleRange = close >= low[1] and close <= high[1] and open >= low[1] and open <= high[1]

roomToTheHi  = rising(high, roomToTheLeftPeriod) 
roomToTheLo  = falling(low, roomToTheLeftPeriod)

// kangaroo tails
kangarootail1 =range > rangePrev1 and range > rangePrev2 and withinPrevCandleRange and  body*bodyRelativeSize <= range and close >= topthird and open >= topthird and roomToTheLo and not isDoji
kangarootail2 =range > rangePrev1 and range > rangePrev2 and withinPrevCandleRange and body*bodyRelativeSize <= range and close < lowthird and open <= lowthird and roomToTheHi and not isDoji
plotshape(kangarootail1, title= "Kangaroo tail",location=location.belowbar, color=green, style=shape.arrowup, text="Kangaroo tail")
plotshape(kangarootail2, title= "Kangaroo tail", color=red, style=shape.arrowdown, text="Kangaroo tail")


// big shadow
bodyPrev1=abs(close[1] - open[1])
bodyPrev2=abs(close[2] - open[2])
bodyPrev3=abs(close[3] - open[3])
bigShadow1 = body > bodyPrev1 and body > bodyPrev2 and body > bodyPrev3 and roomToTheHi and close < low[1] and close < low[2] and low < low[1] and high > high[1]
bigShadow2 = body > bodyPrev1 and body > bodyPrev2 and body > bodyPrev3 and roomToTheLo and close> high[1] and close > high[2] and low < low[1] and high > high[1]
plotshape(bigShadow1, title= "Big shadow", color=red, style=shape.arrowdown, text="Big shadow")
plotshape(bigShadow2, title= "Big shadow",location=location.belowbar, color=green, style=shape.arrowup, text="Big shadow")




barcolor(kangarootail1 or kangarootail2 ? yellow : na)


 
Eemmanuel:

Hi guys,

Could you help in fixing this error.

The error is in ( input(title="Naked Forex - Kangaroo Tail & Big Shadow Indicator", overlay = true) i keep getting declaration without type.



you are not using input correctly, and you should declare them in the global space

try looking at the documentation   https://www.mql5.com/en/docs

and this is how you code an input

 input string title = "Naked Forex - Kangaroo Tail & Big Shadow Indicator"; 

regards

MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
MQL5 Reference - How to use algorithmic/automated trading language for MetaTrader 5
  • www.mql5.com
MetaQuotes Language 5 (MQL5) is a high-level language designed for developing technical indicators, trading robots and utility applications, which automate financial trading. MQL5 has been developed by MetaQuotes Software Corp. for their trading platform. The language syntax is very close to C++ enabling programmers to develop applications in...
 
Eemmanuel: Could you help in fixing this error.
  1. You need to learn the language. What you wrote is the equivalent to baby babble. Utter garbage.

  2. int OnInit; 
    
    This declares a variable of type int whose name is OnInit. The real OnInit is a function. Look at the example on how you call a function.
              Event Handling / OnInit - Reference on algorithmic/automated trading language for MetaTrader 5

  3.  input(title="Naked Forex - Kangaroo Tail & Big Shadow Indicator", overlay = true)
    
    Input is a storage class keyword to a variable declaration, not a function. Paul already posted the correct syntax including the ending semicolon.
              Language Basics / Variables / Input Variables - Reference on algorithmic/automated trading language for MetaTrader 5

  4. rangePrev1=high[1] - low[1]
    rangePrev2=high[2] - low[2]
    range=high - low
    body=abs(close - open)
    Read must read the manual. No termininating semicolons. Undefine arrays (high and low). No declarations of rangePrev1, rangePrev2, range, body, open or close. Baby babble. Utter garbage. Do not post code that won't even compile; stop wasting everyone's time.
    1. MT4: Learn to code it.
      MT5: Begin learning to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
    2. or pay (Freelance) someone to code it.
                Hiring to write script - General - MQL5 programming forum
 
Paul Anscombe:

you are not using input correctly, and you should declare them in the global space

try looking at the documentation   https://www.mql5.com/en/docs

and this is how you code an input

regards

Thank you.
 
def generate_signals(row): if row["ema_short"] > row["ema_long"] and row["rsi"] < 70: return 1 elif row["ema_short"] < row["ema_long"] and row["rsi"] > 30: return -1 else: return 0 it is not working in mt5 editor how can i fix it
 
hashim kagolo #: def generate_signals(row): if row["ema_short"] > row["ema_long"] and row["rsi"] < 70: return 1 elif row["ema_short"] < row["ema_long"] and row["rsi"] > 30: return -1 else: return 0 it is not working in mt5 editor how can i fix it

There is no key word "def", "elif", or access arrays with a non-integer. You need to learn the language. What you wrote is the equivalent to baby babble. Utter garbage.

You didn't define a function, so you can't "return".

Reason: