Skip to player
Skip to main content
Skip to footer
Search
Connect
Watch fullscreen
Like
Comments
Bookmark
Share
Add to Playlist
Report
Tutorial 205 Part 2 | Converting tutorial 173 to a function
Markplex
Follow
7/31/2024
This tutorial demonstrates how to convert tutorial 173 into a function, and how to call the function.
Category
📚
Learning
Transcript
Display full video transcript
00:00
Okay, so the second tutorial program I want to demonstrate how to convert into a function
00:05
is tutorial 173. As I said, if you're a GoldPass member, you can already look at this for Q&A 50,
00:13
but I'm just going to do it again for those who are not GoldPass members or who would like to
00:19
see a little bit more information. As you can see, the original tutorial aims to show when there's a
00:24
trend up and a trend down, as you can see in this graph. So let's go to the original program,
00:31
which is tutorial 173. As you'll see, we've got several inputs, and then we're calculating,
00:38
is it an uptrend or a downtrend? And we're also calculating the supertrend value. So let's have
00:45
a look at as a function. A lot of the inputs I've changed into numeric simple, so they will be
00:52
actually input values that will input into the function. So ATRLength, ATRmult, AVHILO, etc, etc.
01:02
And then the only one that's slightly different is we need to have a value which we're going to
01:07
return for the supertrend value. And I'll show you how we do that. Again, a lot of the syntax
01:17
is pretty much identical to the original program. But what we're doing is we're returning
01:25
into tutorial 173 function, the name of this function, the direction. And the direction is
01:31
something that we calculate in both programs. Let's have a look. Just go down. This is the
01:37
original indicator, and you can see that direction is something that we're calculating there.
01:43
So let's go back to the function. So we're returning the direction in the name of the
01:48
function. We're also returning a value for supertrend. And as I've said, that is going to be
01:54
put into O supertrend, which I have set up here as a numeric reference. So that is the function.
02:07
Again, pretty similar to the original program. And you can watch this and type it in if you like,
02:15
or there is a download available. But what we also need is something to call the function.
02:21
So we're simply going to put in the values we need into the function. And again, you can see
02:29
what those are if you just go to the top of the function, what they all mean. But we put those
02:35
values into the function. And then we have a value here, which you could make a variable,
02:40
I've just used value two, that is going to return whether it's an uptrend or a downtrend. So value
02:47
one is whether it's up or down. So if value one is negative, then we plot value two, which is
02:52
the supertrend value, but we give it a specific color. And again, if value one, in other words,
02:59
the trend going up is one, then we plot the same value, but we plot it a different color.
03:05
And what I've done is on the original chart, I've applied the original program.
03:10
And I've also applied the program calling the function. And I've just made the lines
03:16
very different thicknesses. So you can see that we are getting the same values. And of course,
03:22
the inputs are the same. Okay, so hopefully, that might be useful for you. And if you wish
03:30
to download it, you may do so. If you're a GoldPass member, look at Q&A 50, which is more
03:36
or less, or I think it is identical, just slightly different naming convention. Okay, thank you very
03:42
much.
Recommended
6:04
|
Up next
Program 90 | Finding extreme oscillator 'hooks'
Markplex
5/26/2025
7:57
Tutorial216
Markplex
5/1/2025
9:17
Tutorial217
Markplex
5/1/2025
8:33
Tutorial 215 | Alert when MACD crosses a line drawn on chart
Markplex
4/3/2025
9:21
Tutorial 214 | Draw a rectangle between the high and low of the week
Markplex
3/29/2025
9:43
Tutorial 212 | Draw a rectangle on a chart each day between the high and low of the PREVIOUS day
Markplex
2/12/2025
10:15
Tutorial 213 | Drawing horizontal lines from the wick of the latest pivots
Markplex
2/12/2025
5:37
Program 89 | MACD using a Price Series Provider
Markplex
1/18/2025
9:23
Tutorial 211 | Create a rectangle between 2 times and the highest/lowest price between those times
Markplex
12/30/2024
9:08
Tutorial 210 | Make a horizontal line 'snap' to pivots
Markplex
12/17/2024
6:48
Program 87 | Recurring volume profile (with end-of-bar real time update)
Markplex
12/6/2024
5:42
Program 88 | Markplex Relative Volume
Markplex
12/6/2024
5:42
Program 48 | Trade planner and fib tool UPDATE
Markplex
12/6/2024
8:53
Tutorial 209 | Control bar transparency using slider object
Markplex
10/29/2024
12:26
Tutorial 208 | Why use Methods?
Markplex
9/3/2024
8:00
Quick-tip 99 | Moving trendlines using the SHIFT/PgUp PgDn keys
Markplex
8/10/2024
12:58
Tutorial 203 | Calculate Volume Ratio in RadarScreen
Markplex
7/31/2024
4:41
Tutorial 204 | looking for conditions to occur within specified numbers of bars for each other
Markplex
7/31/2024
4:46
Tutorial 205 | How to convert tutorial 23 (line break) and tutorial 173 (supertrend) into functions
Markplex
7/31/2024
12:56
Tutorial 206 | Using the OpenFileDialog class to access a text file for use with the optimization class
Markplex
7/31/2024
10:05
Tutorial 201 | Annotated trend line drawing tool
Markplex
12/20/2023
4:39
Tutorial 202 | Calculate price to reach a user input RSI value
Markplex
12/20/2023
6:10
Tutorial 190-2 | Plotting when price crosses the upper or lower lines in a centered moving average
Markplex
11/28/2023
10:46
Tutorial 200 | Saving drawing object information in CSV files
Markplex
11/28/2023
6:02
Quick-tip 89 | Importing a text file into ELCollections
Markplex
10/31/2023