Convert "Price speed and acceleration" indicator?
Author: WEALTHPRO25
Creation Date: 5/8/2015 7:59 PM
profile picture

WEALTHPRO25

#1
PLEASE ASSIST ME IN CONVERTING THE CODE BELOW SO IT CAN BE USED IN WEALTH LAB PRO

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightGray
#property indicator_color2 DarkOrchid
#property indicator_width1 2
#property indicator_width2 2


//---- indicator buffers

extern int period = 240;
extern bool show_speed = TRUE;

int limit;

double speed[];
double acceleration[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(2);

//---- drawing settings

if (show_speed == TRUE){

SetIndexStyle(0,DRAW_HISTOGRAM);

}else{

SetIndexStyle(0,DRAW_NONE);
}
SetIndexBuffer(0,speed);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,acceleration);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i;
//----

if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;

for(i=0; i<limit; i++) {
speed[i] = iClose(Symbol(),0,i)-iClose(Symbol(),0,i+period);
}

for(i=0; i<limit; i++) {
acceleration[i] = speed[i]-speed[i+period];
}

//----
return(0);
}
//+------------------------------------------------------------------+
profile picture

Eugene

#2
Did we already ask twice in support portal to not use ALL CAPS? This creates an impression of shouting that nobody likes.

Appreciate your understanding that our resource is moderated for everyone's benefit and crossposting is prohibited. I had to delete five more exactly duplicate threads titled with ALL CAPS under each forum category. Next time deleted will be all the posts.

Now to your indicator - someone else's copyrighted MQL4 work. There is no need to remove author's copyright notice from the original version because every skipped information might help us understand that unnamed something coming from the different platform:

//+——————————————————————+
//| price speed and acceleration.mq4 |
//| Copyright © 2011, Andrea Salvatore |
//| http://www.pimpmyea.com |
//+——————————————————————+
#property copyright “Copyright © 2011, Andrea Salvatore”
#property link “http://www.pimpmyea.com”

Hopefully this is close to what you're looking for:

CODE:
Please log in to see this code.
profile picture

WEALTHPRO25

#3
thank you eugene
profile picture

Eugene

#4
In an duplicate thread, WEALTHPRO25 wrote:

dear eugene,

i want to thank you for your help, the code works
is it possible to add one more derivative, meaning the change in acceleration representated as a line, which is called jerk in math terminology, can you please add this to the code you wrote previously, i want to thank you again for your help. sorry for writing in cap lock previously.
profile picture

Eugene

#5
Added the rate of change of acceleration. You can define its period separately and interactively through the Strategy Parameters box on the bottom left:

CODE:
Please log in to see this code.


Let me know if something does not meet your expectations.
profile picture

WEALTHPRO25

#6
thank you very much eugene,


just one more request, is it possible to plot a line which is the rate of change of jerk, called the snap in math terminology, can you please add this to the last code you wrote. greatly appreciate your assistance.
profile picture

Eugene

#7
Here you go:

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).