How to write code for detecting every 25 points

Questions about MultiCharts and user contributed studies.
NW27
Posts: 177
Joined: 25 Dec 2010
Has thanked: 40 times
Been thanked: 83 times

How to write code for detecting every 25 points

Postby NW27 » 22 Jun 2011

Hi All,

I want to plot a horizontal line on the chart within the approximate price range.
ie
Note the levels are exactly every 25 points as indicated below.

4825 no plot
.
.
4800 ----------------------------------------------
.
.
4875 -----------------------------------------------
.
actual price @4855
.
4850 ------------------------------------------------
.
.
4825 ------------------------------------------------
.
.
4800 No plot


Thanks,
Neil.
How do I detect the close proximity of the 25 levels to the close price.
I tried using the MOD function ie (close mod 25) +close. Sort of works but I'm missing something.

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: How to write code for detecting every 25 points

Postby TJ » 23 Jun 2011

why do you want no plot on 4825 ?

it would be easiest if you simply plot the lines every 25 points, regardless.

NW27
Posts: 177
Joined: 25 Dec 2010
Has thanked: 40 times
Been thanked: 83 times

Re: How to write code for detecting every 25 points

Postby NW27 » 23 Jun 2011

TJ,

I was trying to do this for a few reasons.
1. I thought by only having a few lines on the chart. It would cut down on the resources required. (It all helps, I think).

2. If I was to put lines in every 25 points on a price that is approximately 4800, it would try to scale the whole screen from 0..4800. The price action would be really small.
a) Manually rescaling all of the time would be a a pain in the a...
b) Kind of defeats point 1.

3. I don't think there is 192 (4800/25) plot lines available.


How would you overcome points 2 & 3?

Neil.

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: How to write code for detecting every 25 points

Postby TJ » 23 Jun 2011

NW27 wrote:TJ,
..
2. If I was to put lines in every 25 points on a price that is approximately 4800, it would try to scale the whole screen from 0..4800. The price action would be really small.
a) Manually rescaling all of the time would be a a pain in the a...
b) Kind of defeats point 1.
...
Neil.


you don't have to include the indicator in the price scaling.

right click on chart, select Format Instrument
under Scaling tab, in the General section,
uncheck the box for "Expand Scale to Indicators".
These users thanked the author TJ for the post:
NW27

User avatar
TJ
Posts: 6523
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 957 times
Been thanked: 1883 times

Re: How to write code for detecting every 25 points

Postby TJ » 23 Jun 2011

instead of using an indicator to plot the lines,
you can set the label spacing on the chart:

right click on chart, select Format Instrument
under Scaling tab,
check the box for "Set Labels Manually".
set the step size to 25.

right click on chart, select Format Window...
under Background tab,
Check the box for "Show Grid".
Select your grid type and color.


Return to “MultiCharts”