| stevehopwoodforex.com https://www.stevehopwoodforex.com/phpBB3/ Print view |
|
| Simple script to snap lines to high or low of candles https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=2086 |
Page 1 of 2 |
| Author: | happytrader [ Sat May 04, 2013 2:49 pm ] |
| Post subject: | Simple script to snap lines to high or low of candles |
Hi all, does anyone know of a script that allows you to drag and drop horizontal lines to the top or bottom of a candle you hover the mouse over. I have found one that I can manually place lines on the extremes of candles but I would like one that attaches its self to the precise levels if anyone knows of one. Any help appreciated. |
|
| Author: | gaheitman [ Thu May 09, 2013 8:17 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Empty4 allows you to capture the price and time of the location you "drop" a script onto a chart. The functions are: WindowPriceOnDropped() and WindowTimeOnDropped(). Using the first function would allow you to create a line right where you dropped the script (which is probably what the script you have is doing). In order to use information about the candle you drop the script on you have to convert it from the Date/Time you get from WindowTimeOnDropped() to the actual bar number. We do that with the famous iBarShift() function. So, the code to create a generic horizontal line on the chart at the high of whichever bar you are dropping the script onto is: Code: Select all George |
|
| Author: | happytrader [ Thu May 09, 2013 6:01 pm ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Hi George, thank you sooo much for doing this for me. It is brilliant. I am at the very very early stages of learning mql and am strictly a copy and paste, "borrower" of code, but I am slowly managing to grasp it and get scripts and EAs to do what I require, albeit with horrendous coding. Ultimately I want the lines to be colour coded to each timeframe, mn orange say, w1, yellow, daily blue etc, I will also try to get them to print the data in the description, date time price level etc so I can see details on the chart. I will also need to work out how to make them hierarchical, that is to show the higher tf lines on the lower tfs but not the lower on the higher if that makes sense. You have given me the starting blocks I will have a play now. Thanks again George, all the very best. Brilliant forum you have here Steve, cheers all. |
|
| Author: | 123Reverse [ Fri Jun 28, 2013 5:19 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
What changes do I make to enable more than one instance of the same script? As it is I can have only one high line and one low line. Thx. edit: ie if I do this "//ObjectDelete("MyHighLine");" it will not draw another line. |
|
| Author: | gaheitman [ Fri Jun 28, 2013 10:41 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Each line needs to have a unique name. You could add the Time[] of the candle you dropped the script on to each line you create. Or, if you are looking at different time frames you could simply add the Period() to the string. Does anything differentiate the lines? Of course once you start adding unique strings, it makes deleting them harder... George |
|
| Author: | SteveHopwood [ Sat Jun 29, 2013 10:09 pm ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
happytrader, what I want to do here is add some encouragement to you to keep going with learning the coding stuff. Seven years ago, I was exactly where you are now. Actually, the Proper Coders here would probably chorus, "Yes and he still is where you are now" but I am 'ard these days and can take it. Point is, I started from scratch and now run my own fabulously successful forum. Ok, so I devoted several years in which I coded at least free 5 EA's a week to win the following I now have, but the message I am offering is this: I did it, and so can you. Takes a bit of work, mind. Here you have a unique body of Proper Coders prepared to help you every bi as much as they have helped me. Never be frightened to ask for help here - it is always on offer. |
|
| Author: | happytrader [ Tue Jul 02, 2013 8:23 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Hi Steve, thanks very much for your reply and encouragement, much appreciated. As mentioned earlier I am getting there slowly as a, "borrower" of code and can generally get most things I require to work. The frustrating thing is that, as expected the more unusual requirements that are likely to prove the most useful are the hardest to find ( I guess that's why we decide to teach ourselves ). I have been studying many of your EAs and am amazed at what you can and have done. When I get myself organised I would love to have a chat and run some of my ideas about filtering out the losing trades from my pretty robust system, something for the future. As a fulltime home trader the one thing I do have is huge amounts of time whilst waiting for those "perfect" setups so I will keep at it. I have spent countless hours looking for a solution to the problem listed earlier, to no avail unfortunately, yet. Thanks to George I can get the lines to snap to the candle highs and lows, colour code them etc. but I just cannot work out how to get the data to draw onto the line on my chart automatically. Formatted something like this on todays AUD/USD - H4-Low 2013.06.11 12:00 0.93249 Thanks again and all the very best to you and the gang. Edited to add the code for a weekly support line //+------------------------------------------------------------------+ int start() { //get the low price of the dropped on WEEKLY bar double price = Low[iBarShift(Symbol(),0,WindowTimeOnDropped())]; //create the line ObjectCreate("wsup", OBJ_HLINE, 0,WindowTimeOnDropped(),price); ObjectSet("wsup",OBJPROP_COLOR,Turquoise); // setting object visibility on Weekly chart and all timefames below. ObjectSet("wsup", OBJPROP_TIMEFRAMES,OBJ_PERIOD_M1 |OBJ_PERIOD_M5 | OBJ_PERIOD_M15 | OBJ_PERIOD_H1 | OBJ_PERIOD_M30 | OBJ_PERIOD_H4 | OBJ_PERIOD_D1 | OBJ_PERIOD_W1 ); return(0); } //+------------------------------------------------------------------+ |
|
| Author: | SteveHopwood [ Tue Jul 02, 2013 9:39 pm ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Me too, although EA's are rarely able to replicate successful manual trading systems. Usually, the trader's 'rules' are actually a loose set of guidelines whose use is governed by the trader's experience and expertise. We shall see some time soon. I do not understand what your problem is. |
|
| Author: | 123Reverse [ Wed Jul 03, 2013 5:49 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
Thanks George. I'm now happy to just draw them on the one candle. What I've done is follow your instructions to create a high line, low line, open line and a close line and then once I got over the first lot of trial and error, made these four scripts into one. A few days later I've had another go and organised it better and added a mid line (middle of the body). In use I have say a M15 chart, change the tf to D1, add the script to the last (closed) candle, then change the tf back to M15. Good to watch PA around these lines. |
|
| Author: | hannele [ Sat Aug 24, 2013 12:50 am ] |
| Post subject: | Re: Simple script to snap lines to high or low of candles |
123Reverse, Im trading in 15min frame and wondering if you would like kindly to share this script, it would very useful for the type of trading I do (from one Aussie to another), please. cheers, hannele |
|
| All times are UTC | Page 1 of 2 |
|
Powered by phpBB® Forum Software © phpBB Limited |
|