| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| reading and useing a price from the screen https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=854 |
Page 1 of 2 |
| Author: | jjasper7 [ Sat Sep 29, 2012 6:09 pm ] |
| Post subject: | reading and useing a price from the screen |
how can i move the crosshairs/arrow to a point and then read its price at a past time. it would be useful for an indicator to calculate values from, perhaps to visually set a stop loss or a limit entry, or use to move my stoploss. Does anyone know of a program that gets a coordinate and a trigger that sets up an input like that, which i could modify for such an indi? |
|
| Author: | gaheitman [ Sat Sep 29, 2012 6:26 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
I'm not entirely sure what you are looking for. There are ample examples in the code here of reading the price value from a horizontal line. You could have your indicator look for this line and use its price. I've done the following at one time or another, so I could give you a bit of code to help you on your way if any of these would help:
George |
|
| Author: | jjasper7 [ Sat Sep 29, 2012 11:50 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
thanks again, george. if those 3 suggestions are all in one indi, it sounds very much like you already have what i am trying to make... fetch a starting point (or adjust the start) and draw a fibo and zigzags from there as well. i thought i had the way to read in a vertical line for the start, but could not get it to work. please send or post the routines when you can find them and the time. |
|
| Author: | gaheitman [ Sun Sep 30, 2012 4:48 am ] |
| Post subject: | Re: reading and useing a price from the screen |
Since a vertical line has no price component, only a time component, you have to get a price in two steps. The following code should get the close price for the bar that the vertical line Time_Marker is on: Code: Select all You'll have to keep track of the returned price, so you can tell if the line gets moved. I'm still looking for the indi I wrote that actually used the moving line, but I thought this would get you started.... George |
|
| Author: | garyfritz [ Sun Sep 30, 2012 5:02 am ] |
| Post subject: | Re: reading and useing a price from the screen |
There are also ways to read the location of a mouse click. Maybe you could click to specify the price or time you want? I know this is do-able but I haven't done it myself. |
|
| Author: | gaheitman [ Sun Sep 30, 2012 5:16 am ] |
| Post subject: | Re: reading and useing a price from the screen |
You can get the location that you drop a script on a chart via calls to WindowPriceOnDropped() and WindowTimeOnDropped(). I'm a bigger fan of using the Time to get the price instead of calling WindowPriceOnDropped() since you generally want the Open/Close of the bar, not an exact price. Well, I generally do. For example, I use this code if I want to get the open of a bar: double target1 = Open[iBarShift(Symbol(),0,WindowTimeOnDropped())]; I just suck at dropping it exactly where I want. Unfortunately, these functions don't work on indicators or EAs, so you'd be stuck using a script to drop a line that is read by your indicator/ea. George |
|
| Author: | jjasper7 [ Sun Sep 30, 2012 7:00 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
there is so much i still do not understand about mql, i appreciate your guidance. your snippit showed that my call to ibarshift was wrong. i have a project due this week, and will have to get back to the code next week. if you discover your example code and wouldn't mind sharing it, please do - not only is working code very helpful, but your stuff is so much more elegant than my crude code that i would like to use it if available. i really miss having some sort of a 'breakpoint' routine to help debugging. i guess i almost always had one in the past, and working back from error messages is so much more difficult (just crying, i guess). |
|
| Author: | jjasper7 [ Wed Oct 03, 2012 5:42 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
i am placing a line on the chart, often (not always),it does not draw, even though i can then find it in the objects list, and it does not consistently fail (even without recompiling it will occasionally work). are there some strange things to watch for that keep it from painting? i have noticed the same failure to paint consistently on trying to paste a wingding. the values have been checked. |
|
| Author: | gaheitman [ Wed Oct 03, 2012 5:47 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
I've never had a problem with lines being drawn. When you examine it in the object list everything is complete? Post the code that draws the line and I can look at it. George |
|
| Author: | jjasper7 [ Fri Oct 05, 2012 6:29 pm ] |
| Post subject: | Re: reading and useing a price from the screen |
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); |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|