someone please help

Questions about MultiCharts and user contributed studies.
egg4019
Posts: 5
Joined: 15 Nov 2010

someone please help

Postby egg4019 » 16 Nov 2010

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.

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: someone please help

Postby furytrader » 17 Nov 2010

I think your code would be something like this:

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;
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.

egg4019
Posts: 5
Joined: 15 Nov 2010

Re: someone please help

Postby egg4019 » 17 Nov 2010

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

User avatar
furytrader
Posts: 354
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 155 times
Been thanked: 217 times

Re: someone please help

Postby furytrader » 17 Nov 2010

You can change the last line of code to read:

Code: Select all

If WatchPrice > 0 AND Time > TimeToWatch and ((Close - WatchPrice)/WatchPrice) >= RallyRatio Then Buy This Bar On Close;
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.

egg4019
Posts: 5
Joined: 15 Nov 2010

Re: someone please help

Postby egg4019 » 17 Nov 2010

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.


Return to “MultiCharts”