Horizontal Line Problem

 

Hi all,


I have a little problem. Maybe you can help me with it.


A friend of mine coded an EA for me and it works pretty good. It is based on a fix price, which I can enter when I add the ea to the chart.


Unfortunately it does not draw a line in the chart at the fix price ratio. So I am sitting here and try to add it to the code, but I only get failure messages.


Here is what I wanted to code:


extern double Fixpreis= 1.3550;

ObjectCreate("Fixpreis",OBJ_HLINE,0,0,Fixpreis);


but this does not work. I get the message "Fixpreis expression on global scope not allowed" when compiling.


I want to enter the Fixpreis once and it should draw the h-line in the chart.


Thank you, if you could help me.


Matt

 

Which function have you added the ObjectCreate() call into?

I'd imagine you're wanting to put it in the init() fucntion.

 

Hi cloudbreaker,


thank you for your fast reply. Actually these two lines are set before the init() area. I am an absolut beginner. I haven´t got a clue, what I am doing. Maybe you can give me a hint.


Thanx again


Matt

 
worldtrade:

Hi cloudbreaker,


thank you for your fast reply. Actually these two lines are set before the init() area. I am an absolut beginner. I haven´t got a clue, what I am doing. Maybe you can give me a hint.


Thanx again


Matt

Take the second line and move it into the init() function.

The init() function is run when you initialize your EA.

The start() function is run when an incoming tick arrives.

The deint() function is run for a max of 2.5 secs when you stop the EA.


I think your problem is that you are issuing an instruction outside of a function.

 

Hi cloudbreaker,


ok, there are zero compiling warnings, but no line was drawn. Any idea, what is missing? When I coded it this way and placed it outside init() he drew the line:


ObjectCreate("Fixpreis",OBJ_HLINE,0,0,1.3550);


but not this way:


ObjectCreate("Fixpreis",OBJ_HLINE,0,0,Fixpreis); (when placed inside the init() area.)


Matt