reading and useing a price from the screen

User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: reading and useing a price from the screen

Post by gaheitman »

jjasper7 wrote:can anyone observe what i am doing wrong in these code snippets? the wingdings and lines sometimes show but more often do not. their values do show up in the objects list, but are frequently not painted. and no code differences between when they paint and when they fail.

-------------------------------------------

void MarkV( string name, double price, int bar, int wingdng, color colr)
{
// wingdings: 228/230 buy/sell arrows,
// colors; buy/sell Aqua/Maroon
name=name+bar;
ObjectCreate(name ,OBJ_ARROW,0,Time[bar],price);
ObjectSet(name,OBJPROP_ARROWCODE,wingdng);
ObjectSet(name,OBJPROP_COLOR,colr);
}

// ex. MarkV("mtm5", Low[1], 0, 190, Black);

------------------------------

void DrawLine(string name, datetime time1, double val1, datetime time2, double val2, color col, int width, int style, bool ray)
{
//Plots a line with the given parameters
ObjectDelete(name);
ObjectCreate(name, OBJ_TREND, 0, time1, val1, time2, val2);
ObjectSet(name, OBJPROP_COLOR, col);
ObjectSet(name, OBJPROP_WIDTH, width);
ObjectSet(name, OBJPROP_STYLE, style);
ObjectSet(name, OBJPROP_RAY, ray);
}//End void DrawLine()

// ex. DrawLine("ttnl "+Bars, Time[3], High[3], Time[2],High[3]+2*spread, Brown, 2, STYLE_SOLID, false);
// ex2. DrawLine(" Aline ", Time[startA],Avalue, Time[0],Avalue, Brown, 3, STYLE_SOLID, false);
For the arrows, since you are not deleting the arrow in advance, the ObjectCreate() will fail if it already exists. If it does fail, it won't change the time/price. You should get error messages in the log, however.

Another possibility is that the objects are not appearing because you have something else on the screen like iParamWorktime drawing a rectangle that is higher in the z-order because of it's name so it is on top of the objects you are drawing. I posted somewhere on here about the order of visible objects based on their name. I'll see if I can find it and update this post if you think that might be the case.

George
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: reading and useing a price from the screen

Post by jjasper7 »

i have tried adding ObjectDelete ahead of the calls, but do not notice improvement in the display of the objects. and i am not drawing rectangles, and the objects are small (wingdings or lines), so cannot explain why they do not paint. i have noticed some of the missing display objects are in the Objects List. also having trouble deleting the objects, as if the program is too busy to keep up when i am trying to deinit. can you please explain what might be happening?
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: reading and useing a price from the screen

Post by jjasper7 »

another big problem i have started having. if i load an indicator i wrote, even on only one chart, it slows the processor drastically. i have throttled the program down to exit without doing anything unless it is a new bar, but even that does not help - my computer is fully busy, and takes 5-10 seconds to respond to me (like rt mouse click on the chart to pull down the options, and other simple things) - even with the indicators start{} commented out so no logic is available to run. any ideas how to find what is loading down the processor?
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: reading and useing a price from the screen

Post by gaheitman »

jjasper7 wrote:i have tried adding ObjectDelete ahead of the calls, but do not notice improvement in the display of the objects. and i am not drawing rectangles, and the objects are small (wingdings or lines), so cannot explain why they do not paint. i have noticed some of the missing display objects are in the Objects List. also having trouble deleting the objects, as if the program is too busy to keep up when i am trying to deinit. can you please explain what might be happening?
If the objects are in the object list, then you created them, but the parameters are incorrect. Have you looked at the time/price information from that list to see that they are correct? The values there should give you a clue as to what is going on.

George
jjasper7
Trader
Posts: 87
Joined: Mon Mar 19, 2012 11:44 pm
Location: Mesa,AZ (near Phoenix)

Re: reading and useing a price from the screen

Post by jjasper7 »

george, that display problem is still giving me grief. it would be very helpful if i could find a breakpoint debugger to help. do you know of such a program to help find errors?
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: reading and useing a price from the screen

Post by gaheitman »

jjasper7 wrote:george, that display problem is still giving me grief. it would be very helpful if i could find a breakpoint debugger to help. do you know of such a program to help find errors?
That would be nice to have, but I am not aware of any. I spend a lot of time adding Print() and Alert() statements to code....

If might be worth looking at these couple of posts: http://www.stevehopwoodforex.com/phpBB3 ... t=10#p4559 They refer to using a standalone debugger so you can capture debug output to another screen. You still have to add a bunch of logging statements to the code, however.

George
Post Reply

Return to “Know your MT4 platform”