Download MetaTrader 5

Can't draw arrow in backtesting ?

To add comments, please log in or register
Do you want to deposit to your account? Do this in any convenient way!
Mideel
74
Mideel 2015.01.25 14:43 

I just made simple EA but it draws nothing although I use visual mode.

Then I made simple test on init function like this to drew some arrows but nothing showed up.


void init()

{

         ObjectCreate( ChartID(), "Test", OBJ_ARROW_DOWN, 0, Time[1], High[1] ) ;
         ObjectSet("Test", OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("Test", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
         ObjectSet("Test", OBJPROP_COLOR, Blue);

}


I'm on the visual mode too...

honest_knave
Moderator
2215
honest_knave 2015.01.25 15:12  

You shouldn't try to access things like High[1] in OnInit() "because during initialization values of information environment parameters may be not ready (information about charts, market prices and so on)"

Check your objects list to see if it has been drawn... just not where you think it should have been. 

Mideel
74
Mideel 2015.01.28 16:01  
honest_knave:

You shouldn't try to access things like High[1] in OnInit() "because during initialization values of information environment parameters may be not ready (information about charts, market prices and so on)"

Check your objects list to see if it has been drawn... just not where you think it should have been. 

I've tried it in start function in visual mode but I still got nothing....
honest_knave
Moderator
2215
honest_knave 2015.01.28 16:23  

Your code snippet works fine on Build 765 (Visual Mode or Live Chart).

Have you checked the Objects List?

 

Mideel
74
Mideel 2015.01.30 14:25  
honest_knave:

Your code snippet works fine on Build 765 (Visual Mode or Live Chart).

Have you checked the Objects List?

 

Just checked it and there was nothing in the object list, its greyed out.


What should I do now ?

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.01.30 15:42  

I believe you don't attach it properly. Make sure on top right shows your ea name. Sometime you missed it.

I am pretty sure it is common mistake.

Mideel
74
Mideel 2015.01.30 16:28  
deysmacro:

I believe you don't attach it properly. Make sure on top right shows your ea name. Sometime you missed it.

I am pretty sure it is common mistake.

Yes, I didn't attach it because I want to test it on back testing in visual mode since this is just a test but the real EA uses graphical objects and I want to see it in back testing visual mode.


But you said it worked in back testing visual mode too right ?

honest_knave
Moderator
2215
honest_knave 2015.01.30 16:54  

There is nothing wrong in principle with the code snippet that you posted.

So the problem must be in how or when that code is implemented.

You'll need to post more code for us to help.

whroeder1
14519
whroeder1 2015.01.30 17:12  
mideel: I just made simple EA but it draws nothing although I use visual mode.
void init(){
         ObjectCreate( ChartID(), "Test", OBJ_ARROW_DOWN, 0, Time[1], High[1] ) ;
         ObjectSet("Test", OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("Test", OBJPROP_ARROWCODE, SYMBOL_ARROWUP);
         ObjectSet("Test", OBJPROP_COLOR, Blue);
}

  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. There is no chart to draw on in init. Time[] and High[] may not exist. Put the code in start. An EA must have a start.
  3. Check the logs - was the EA actually attached?
  4. Check your return codes (ObjectCreate) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Mideel
74
Mideel 2015.01.31 09:32  

Are you guys really sure it works in back testing ?


Its true that it works if I really attach the EA to the chart, but still in back testing visual mode, it showed nothing... I have made sure there is no error like no tick data, I use daily time frame and 2 day length of back testing.


And to make sure, there is no misunderstanding... visual mode back testing means I don't attach the EA to the chart right ?

Keith Watford
Moderator
9623
Keith Watford 2015.01.31 11:10  
mideel:

Are you guys really sure it works in back testing ?


Its true that it works if I really attach the EA to the chart, but still in back testing visual mode, it showed nothing... I have made sure there is no error like no tick data, I use daily time frame and 2 day length of back testing.


And to make sure, there is no misunderstanding... visual mode back testing means I don't attach the EA to the chart right ?

Does the code delete the objects on de-initialization?

If so, 2 days testing on the daily time-frame would  delete the object quicker than you are able to see it.

12
To add comments, please log in or register