• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:55pm
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:55pm
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Printable Version

Similar Threads

Help with mq4 SendMail syntax 2 replies

Syntax Help Needed 7 replies

which syntax that check open order? 7 replies

jurik syntax question 1 reply

VT Dumb Syntax Questions 4 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Syntax Help
Exit Attachments

Syntax Help

  • Post #1
  • Quote
  • First Post: Mar 1, 2009 10:31pm Mar 1, 2009 10:31pm
  •  coach3131
  • | Joined Feb 2009 | Status: Member | 122 Posts
If I want to check the standard deviation of a price for the past 20 bars, what is the difference between MA shift and shift?



double iStdDev( string symbol, int timeframe, int ma_period, int ma_shift, int ma_method, int applied_price, int shift)Calculates the Standard Deviation indicator and returns its value. Parameters:
symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol. timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe. ma_period - MA period. ma_shift - MA shift. ma_method - MA method. It can be any of Moving Average method enumeration value. applied_price - Applied price. It can be any of Applied price enumeration values. shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).
  • Post #2
  • Quote
  • Mar 2, 2009 1:17am Mar 2, 2009 1:17am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
"MA shift" is the shift input of the Moving Average within the Standard Deviation indicator. whereas "shift" denotes the candle index you want to retrieve for the value of the Standard Deviation indicator itself.

simply put, "MA shift" is required for calculation of the result. "shift" is required for the retrieval of the result.

not all indicators' function have "MA shift" but all of them requires a "shift".

I hope this is clear.
Programming for a better future.
  • Post #3
  • Quote
  • Mar 2, 2009 2:49am Mar 2, 2009 2:49am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
Quoting coach3131
Disliked
Quoting coach3131
Disliked
So MA shift is the moving average shift and shift is the shift of the standard deviation.... so if I want the past 20 periods, I would put 20 for both? and if so, then what is periods?
Ignored
Basically, I am trying to create an indicator that will draw the Moving Average Line and then calculate the Standard Deviation and draw a line at Moving Average + Standard Deviation.... the Moving Average indicator draws a line on the chart, but I am wondering if something is wrong with the syntax to try and add the standard deviation to it
Ignored
although I'm not sure I understand you correctly. I'm just a programming guy, not experts in the use of indicators.

what I can say is. do you use MA shift in your moving average line? if not, then you don't have to use MA shift in your standard deviation.

a better way of understanding what MA shift is... would be to apply a moving average period 21 on chart with MA shift set to 0. that's the most basic. then add another moving average line with the same inputs but this time use MA shift set to 1. you'll see the lines are almost identical except the latter is shifted 1 candle to the right. That's all there is to it. I personally have never used MA shift before throughout my programming experience and I doubt you'll be using it much too.

regards,
Zen
Programming for a better future.
  • Post #4
  • Quote
  • Mar 2, 2009 2:51am Mar 2, 2009 2:51am
  •  coach3131
  • | Joined Feb 2009 | Status: Member | 122 Posts
I am trying to create an indicator that draws a line above the moving average + 1 standard deviation for x periods (in this example 20).

Basically trying to combine the Moving Average Indicator with Standard Deviation indicator, but instead of the Standard Deviation Indicator writing on a separate chart, configuring it to write on the chart.
  • Post #5
  • Quote
  • Mar 2, 2009 3:11am Mar 2, 2009 3:11am
  •  coach3131
  • | Joined Feb 2009 | Status: Member | 122 Posts
Ok, I am not using shift... was figuring out what it was...

The line I want is the price + standard deviation over the periods
  • Post #6
  • Quote
  • Mar 2, 2009 3:16am Mar 2, 2009 3:16am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
ok I don't know how to explain it well.

see if this is what you want.
Attached File
File Type: mq4 MA+StdDev.mq4   2 KB | 204 downloads
Programming for a better future.
  • Post #7
  • Quote
  • Mar 2, 2009 3:20am Mar 2, 2009 3:20am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
MA_Method settings:
0 = Simple moving average,
1 = Exponential moving average,
2 = Smoothed moving average,
3 = Linear weighted moving average.

MA_Applied_Price settings:
0 = Close price.
1 = Open price.
2 = High price.
3 = Low price.
4 = Median price, (high+low)/2.
5 = Typical price, (high+low+close)/3.
6 = Weighted close price, (high+low+close+close)/4.

you can find these in your MQL reference
Programming for a better future.
  • Post #8
  • Quote
  • Mar 2, 2009 4:49am Mar 2, 2009 4:49am
  •  coach3131
  • | Joined Feb 2009 | Status: Member | 122 Posts
Awesome, thanks! I am able to see what I am after now.
  • Post #9
  • Quote
  • Mar 2, 2009 3:49pm Mar 2, 2009 3:49pm
  •  coach3131
  • | Joined Feb 2009 | Status: Member | 122 Posts
Thank you very much... your indicator was useful for getting me where I want to go.... I split it into two indicators measuring 5 levels of standard deviation on each side of the line.... here is a question that I think can be solved with a nested loop if I am not mistaken

Right now MA is tracking x bars (20 for this example).... I should be able to run a loop that figures the standard deviation for the past 20 bars that are above the MA.... thus, it doesn't count every bar but only the bars above the MA until it gets to x bars above the MA

Also, what is standard practice in the programming world if there is the main author and then other contributing authors for properly documenting that?
  • Post #10
  • Quote
  • Mar 2, 2009 7:06pm Mar 2, 2009 7:06pm
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
are you worried about excessive processing? don't be, the following two lines within the codes

Inserted Code
Counted_bars=IndicatorCounted(); // Number of counted bars   
i=Bars-Counted_bars-1;           // Index of the first uncounted

ensures that the total number of candles is only calculated at the first instance when the indicator is loaded. subsequently it will only recount the newest bar.

I urge you to go read up on IndicatorCounted() function to be clear of this concept.

regards,
Zen
Programming for a better future.
  • Post #11
  • Quote
  • Last Post: Mar 2, 2009 7:15pm Mar 2, 2009 7:15pm
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
Quoting coach3131
Disliked
Also, what is standard practice in the programming world if there is the main author and then other contributing authors for properly documenting that?
Ignored
There is no international method of sorts. What I do is to have something like this at the top of the code.

Inserted Code
//+------------------------------------------------------------------+
//|                                           InsideBarIndicator.mq4 |
//|   Copyright © 2008, Zen_Leow based on work done by Robert Bayles |
//|                                                                  |
//+------------------------------------------------------------------+

and perhaps elaborate on the modification done. Don't worry. Most people don't bother with this anyway.

regards,
Zen
Programming for a better future.
  • Platform Tech
  • /
  • Syntax Help
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2021