Insert an arrow in an offline chart

 

Hi,

I can insert the arrow fine in the M1 EUR/USD in which the EA runs. I run the ea to generate a .HST file containing the ticks and show that information in an offline chart. When I tell it to show the arrow object in the current window it shows fine. When I tell it to create the object in the offline window then I get an error 4051 (Invalid function parameter value).

I retrieve the window handle of the offline chart correctly to use is to refresh the offline chart after rewriting the tick file after each tick. When I use that same window handle in ObjectCreate apparently it is not valid. The actual handle value at the moment was 657762 (if that matters).

So I guess the question is whether I can use a window handle other than 0 in the ObjectCreate function, and if so is there a formatting issue or something that I might be missing? The conundrum is object create works if I use the live chart.

Any perspective would be greatly appreciated.

Thanks,

N

<CODE REMOVED>

 
niqmadu:

Hi,

I can insert the arrow fine in the M1 EUR/USD in which the EA runs. I run the ea to generate a .HST file containing the ticks and show that information in an offline chart. When I tell it to show the arrow object in the current window it shows fine. When I tell it to create the object in the offline window then I get an error 4051 (Invalid function parameter value).

I retrieve the window handle of the offline chart correctly to use is to refresh the offline chart after rewriting the tick file after each tick. When I use that same window handle in ObjectCreate apparently it is not valid. The actual handle value at the moment was 657762 (if that matters).

So I guess the question is whether I can use a window handle other than 0 in the ObjectCreate function, and if so is there a formatting issue or something that I might be missing? The conundrum is object create works if I use the live chart.

<CODE REMOVED>

Please read some other posts before posting . . .

Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

 

RaptorUK

What I understand from your reply are the following:

1. Do my homework

2. It should not be too hard if I do my homework.

3. I am not trying to insert the arrow in the offline chart in a completely stupid way (or you would have mentioned that as well)

4. Someone else has already posted about this or something like it (and you have no idea how I missed it)

I've spent a couple of hours wrapping my head around objectcreate--I'm not the most instinctive programmer, and of course I will continue reviewing other posts etc.

Regards,

N

 
niqmadu:

RaptorUK

What I understand from your reply are the following:

1. Do my homework

2. It should not be too hard if I do my homework.

3. I am not trying to insert the arrow in the offline chart in a completely stupid way (or you would have mentioned that as well)

4. Someone else has already posted about this or something like it (and you have no idea how I missed it)

I've spent a couple of hours wrapping my head around objectcreate--I'm not the most instinctive programmer, and of course I will continue reviewing other posts etc.

Regards,

N

Nope, what I'm saying is when you post code on this Forum use the SRC button . . . if you had read the Forum you would have seen the same request being made of other Users. Did you click the link I gave you ?
 

I see it now.

            string name = "Signal" + BAS_INDEX;
            BAS_INDEX++;

            int win_handle = WindowHandle(Symbol() + "x" , 2);            

            Alert("Win Handle   ", win_handle);
            if (!ObjectCreate(name, OBJ_ARROW, win_handle, TimeCurrent(), Ticks[1][LastItem] + 20 * Point))
               {
                  Alert("Error creating object:   ",GetLastError());
                  return(0);
               }
               
            ObjectSet(name, OBJPROP_STYLE, STYLE_SOLID);
            ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_ARROWDOWN);
            ObjectSet(name, OBJPROP_COLOR, White); 
            ObjectSet(name, OBJPROP_TIMEFRAMES, OBJ_ALL_PERIODS); 
            
            return(1);
 
niqmadu: The actual handle value at the moment was 657762 (if that matters).
  1. What was so hard about his request? Why didn't you EDIT your original post as requested instead of replying.
  2. int win_handle = WindowHandle(Symbol() + "x" , 2);            
    if (!ObjectCreate(name, OBJ_ARROW, win_handle, 
    Have you read the manual? The third argument is an integer 0=main window 1=first subwindow... I doubt you have 650,000 subwindows on one chart.
 
WHRoeder:
  1. What was so hard about his request? Why didn't you EDIT your original post as requested instead of replying.
  2. Have you read the manual? The third argument is an integer 0=main window 1=first subwindow... I doubt you have 650,000 subwindows on one chart

1. Clearly my bad. It was not my intent to not show proper etiquette.

2. Clearly not well enough.

So then my code will operate on a valid window in the current chart, specifically the chart that the EA is functioning in? That clarifies things quite a bit,

Thanks,

N

 
niqmadu: So I guess the question is whether I can use a window handle other than 0 in the ObjectCreate function, and if so is there a formatting issue or something that I might be missing? The conundrum is object create works if I use the live chart.
  1. If you want to put the object on the main window of the chart you must use zero
    #define WINDOW_MAIN 0
    if (!ObjectCreate(name, OBJ_ARROW, WINDOW_MAIN

  2. If you want to put the object on a sub-window you must find it.
    int win_idx=WindowFind("MACD(12,26,9)");
    if (!ObjectCreate(name, OBJ_ARROW, win_idx

  3. WindowHandle is only useful in specific DLL calls, never in mql4 functions like create.
Reason: