Create Object in back testing

 

I am playing around with MQL4 and have created a basic script, here is a snippet.

The issue is just the ObjectCreate.

int tiket=OrderSend(Symbol(), OP_BUY, Lotsi,Ask, 0, 0,0, 0);

OrderModify(tiket,Ask,Ask - 100*Point,Ask + 250 * Point,0);

OrderSelect(tiket,SELECT_BY_TICKET);

ObjectCreate("Arrow", OBJ_ARROW, 0,OrderOpenTime(), OrderClosePrice( ) );

I can use the same line in a script and it will draw an arrow, if I use it in an EA and do some back testing it does not draw anything.

My goal is to have my EA leave markers where it places the orders, so when I do back testing there is a visual indication of where the trade took place.

Can someone give me some help, thanks.

 

The back-tester creates arrows when it places an order by default, is this not enough for you? Your code above is not enough for someone else to debug. Submit the entire code. Check if the order is being selected correctly. Use Print or Alert in back-tester to verify the value of ticket or returned values from order select. Give different names to "Arrow" or you'll have only one object on chat. Example "Arrow"+timeCurrent.

 
PAG24:


Can someone give me some help, thanks.

Don't you need to do an ObjectSet and give it the OBJPROP_ARROWCODE so it knows what kind of arrow you want ?
 

The problem is when I back test it does not place any arrows.

I have 85 trades place but no arrows?

I've attached the code but it is not my code, it was some code I found on the internet and I've been playing with it to learn how it works.

Files:
 

I get the default arrows when I back-test. What type of arrows are you looking for? Are you testing in Visual Mode? Picture below shows what I get.

 
PAG24:

The problem is when I back test it does not place any arrows.

What kind of arrow do you want ? https://docs.mql4.com/constants/arrows or maybe one of these ? https://docs.mql4.com/constants/wingdings

 

PAG24:

OrderSelect(tiket,SELECT_BY_TICKET);

ObjectCreate("Arrow", OBJ_ARROW, 0,OrderOpenTime(), OrderClosePrice( ) );

I can use the same line in a script and it will draw an arrow, if I use it in an EA and do some back testing it does not draw anything.

My goal is to have my EA leave markers where it places the orders, so when I do back testing there is a visual indication of where the trade took place.


  1. You code places the arrow the same place the tester does (+/- SPREAD,) perhaps that is why you don't see it.
  2. Once you create the object further create calls will fail and the arrow won't move.
  3. You don't define the type of arrow as Raptor points out.
 

Ok so if I add in a value which increments, and I changed it to a V line, so now the line comes up but it still only places it once at the very start.

How do I increment in correctly?

ObjectCreate("Arrow2"+gh, OBJ_VLINE, 0,OrderOpenTime(), OrderClosePrice());

Now what do you mean by Raptor points out?

 
Ah sorry guys my fault, I defined the gh=0 variable inside the function not as global, so everytime a tick came in it would int gh to 0. All solved now. Thanks everyone.
Reason: