someone please help
someone please help
I am looking for a simple code however not having any knowledge what so ever makes it a little difficult on the first run. I am looking for code to give me a buy once a stock goes up .75% from a 10:00am closing price. Any help would greatly be appreciated.
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: someone please help
I think your code would be something like this:
I wrote this with the assumption that it's run on an intraday basis, which is why we use the code "If Time > TimeToWatch ..." - in other words, the code won't give a buy signal until after 10:00 am, since you need the price at 10:00 am to generate the signal.
Feel free to ask any questions or if you want to know more about how to tweak this code.
Hope this helps.
Code: Select all
Inputs: TimeToWatch(1000), RallyRatio(0.0075);
Vars: WatchPrice(0);
If Time = TimeToWatch Then WatchPrice = Close; // This records the price at 10:00 am
If Time > TimeToWatch and ((Close - WatchPrice)/WatchPrice) >= RallyRatio Then Buy This Bar On Close;
Feel free to ask any questions or if you want to know more about how to tweak this code.
Hope this helps.
Re: someone please help
Fury thanks for the help, I did run the code however I kept getting an error message:
error in study "_test"
(Exception)
Floating-point division by zero
error in study "_test"
(Exception)
Floating-point division by zero
- furytrader
- Posts: 354
- Joined: 30 Jul 2010
- Location: Chicago, IL
- Has thanked: 155 times
- Been thanked: 217 times
Re: someone please help
You can change the last line of code to read:
I'm not sure how the WatchPrice could be something other than zero after we've stored a value, unless you don't have a 10:00 am bar on your chart.
You will need to have a bar with a timestamp that reads "10:00 am" for this to work.
Code: Select all
If WatchPrice > 0 AND Time > TimeToWatch and ((Close - WatchPrice)/WatchPrice) >= RallyRatio Then Buy This Bar On Close;
You will need to have a bar with a timestamp that reads "10:00 am" for this to work.
Re: someone please help
How do I get the bars to show 10:00am, right now they are starting out at 9:31am and showing up every 7 minutes.