Welcome to the Traders Laboratory.

Coding Forum Collaborate, receive help, or discuss indicators and other coding-related topics

Like Tree1Likes
Reply
Old 05-25-2010, 11:02 AM   #17

Join Date: Jul 2009
Location: Jakarta
Posts: 7
Ignore this user

Thanks: 0
Thanked 1 Time in 1 Post

Re: Convert MT4 Indicator into Tradestation Eld?

any1 could help me to convert this please

its only my simple indicator to plot local time on chart

Quote:
extern int corner=0;
extern int X=0;
extern int Y=0;
extern int Font_Size=10;
extern color Font_Color=Red;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- creates and sets Object Label
if(ObjectFind("LocalTime" )<0) ObjectCreate("LocalTime", OBJ_LABEL, 0, 0, 0, 0);
ObjectSet("LocalTime", OBJPROP_CORNER, corner);
ObjectSet("LocalTime", OBJPROP_XDISTANCE, X+10);
ObjectSet("LocalTime", OBJPROP_YDISTANCE, Y+Font_Size);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- deletes Object Label
if(ObjectFind("LocalTime" )>-1) ObjectDelete("LocalTime") ;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//---- set and reset Object Label text to show current local time
ObjectSetText("LocalTime" , TimeToStr(TimeLocal(),TIM E_SECONDS), Font_Size, "Arial", Font_Color);
//----
return(0);
}
//+------------------------------------------------------------------+

Last edited by furtrader; 05-25-2010 at 11:23 AM.
furtrader is offline  
Reply With Quote
Old 09-21-2011, 06:51 AM   #18

Join Date: Mar 2009
Posts: 27
Ignore this user

Thanks: 8
Thanked 5 Times in 5 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

i just curious that anyone could convert following MT4 indicators to easy language. as far as i know these advanced indicators are never been converted to TS.

One Side Gaussian Filter One side gaussian ...
Fractal Graph Dimension Indicator Fractal Graph Dimension Indicator (FGDI) - MQL4 Code Base
Variation Index Variation Index - MQL4 Code Base
r4bb1t is offline  
Reply With Quote
Old 09-26-2011, 03:43 PM   #19

Join Date: Mar 2009
Posts: 27
Ignore this user

Thanks: 8
Thanked 5 Times in 5 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Code:
//+----------------------------------------------- ---------------------------------------+
/ / | Hodrick - Prescott Filter.mq5 |
/ / | Copyright 2010 gpwr |
/ / | vlad1004@yahoo.com |
//+----------------------------------------------- ---------------------------------------+
# property copyright "gpwr"
# property version "1.00"
# property description "Hodrick - Prescott Filter"
# property indicator_chart_window
# property indicator_buffers 1
# property indicator_plots 1
# property indicator_label1 "filter"
# property indicator_type1 DRAW_LINE
# property indicator_color1 Red
# property indicator_style1 STYLE_SOLID
# property indicator_width1 1

//===================================== INPUTS ========== =================================
input int Per = 50; / / HP filter period
input int N = 500 / / # of prices to smooth

/ / Global variables
int PrevBars;
double Lambda;

/ / Indicator buffers
double hpf [];

/ / Custom indicator initialization function -------------------------------------------- - +
void OnInit ()
{
/ / Initialize global variables
   PrevBars = Bars (_Symbol, _Period) -1;
   Lambda = 0.0625/MathPow (MathSin (M_PI / Per), 4);

/ / Map indicator buffers
   ArraySetAsSeries (hpf, true);
   SetIndexBuffer (0 hpf, INDICATOR_DATA);
   IndicatorSetInteger (INDICATOR_DIGITS, _Digits);
   IndicatorSetString (INDICATOR_SHORTNAME "HPF ("+ string (Per )+")");
}

//====================================== MAIN ========= ===================================
int OnCalculate (const int bars,
                const int prev_calculated,
                const datetime & Time [],
                const double & Open [],
                const double & High [],
                const double & Low [],
                const double & Close [],
                const long & tick_volume [],
                const long & volume [],
                const int & spread [])
{
/ / Check for insufficient data and new bar
   if (bars <N)
   {
      Print ( "Error : not enough bars in history!");
      return (0);
   }
   if (PrevBars == bars) return (bars);
   PrevBars = bars;

/ / Initialize indicator buffer to EMPTY_VALUE
   ArrayInitialize (hpf, EMPTY_VALUE);
   
/ / Reverse indexing direction for Open
   ArraySetAsSeries (Open, true);

/ / Main cycle ---------------------------------------------- -----------------------------+
   for (int i = 0; i <N; i + +) hpf [i] = Open [i];
   HPF (N, Lambda, hpf);
   return (bars);
}
//==================================== FUNCTIONS =========== ==============================
/ / Hodrick - Prescott Filter -------------------------------------------- -------------------+
void HPF (int n, double lambda, double & x [])
{
   double a [], b [], c [], h1, h2, h3, h4, h5, hh1, hh2, hh3, hh5, hb, hc, z;
   ArrayResize (a, n);
   ArrayResize (b, n);
   ArrayResize (c, n);
        
   a [0] = 1.0 + lambda;
   b [0] =- 2.0 * lambda;
   c [0] = lambda;
   for (int i = 1; i <n - 2; i + +)
   {
      a [i] = 6.0 * lambda +1.0;
      b [i] =- 4.0 * lambda;
      c [i] = lambda;
   }
   a [1] = 5.0 * lambda +1;
   a [n - 1] = 1.0 + lambda;
   a [n - 2] = 5.0 * lambda +1.0;
   b [n - 2] =- 2.0 * lambda;
   b [n - 1] = 0.0;
   c [n - 2] = 0.0;
   c [n - 1] = 0.0;
   
   / / Forward
   for (int i = 0; i <n; i + +)
   {
      z = a [i] - h4 * h1 - hh5 * hh2;
      hb = b [i];
      hh1 = h1;
      h1 = (hb - h4 * h2) / z;
      b [i] = h1;
      hc = c [i];
      hh2 = h2;
      h2 = hc / z;
      c [i] = h2;
      a [i] = (x [i] - hh3 * hh5 - h3 * h4) / z;
      hh3 = h3;
      h3 = a [i];
      h4 = hb - h5 * hh1;
      hh5 = h5;
      h5 = hc;
   }
   
   / / Backward 
   h2 = 0;
   h1 = a [n - 1];
   x [n - 1] = h1;
   for (int i = n - 2; i> = 0; i -)
   {
      x [i] = a [i] - b [i] * h1 - c [i] * h2;
      h2 = h1;
      h1 = x [i];
   }
}
It's Hodrick-Prescott Filter coded in MT4. it's widely used in econometrics or bussiness forecasting. hope someone convert it to tradestation.
i've tried by myself but i've stucked in the Forward iteration part. he used one variable named x in the forward interation and it's third parameter of the function itself. but i don't know how to handle it on tradestation.

Last edited by r4bb1t; 09-26-2011 at 04:07 PM.
r4bb1t is offline  
Reply With Quote
Old 09-26-2011, 07:53 PM   #20

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,663 Times in 1,010 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Quote:
Originally Posted by r4bb1t »
...
It's Hodrick-Prescott Filter coded in MT4. it's widely used in econometrics or bussiness forecasting. hope someone convert it to tradestation.
i've tried by myself but i've stucked in the Forward iteration part. he used one variable named x in the forward interation and it's third parameter of the function itself. but i don't know how to handle it on tradestation.
if you have tried, but are unwilling to share your "efforts",
what chances are someone would like to collaborate in this ?
__________________
Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.
Tams is offline  
Reply With Quote
Old 09-26-2011, 08:44 PM   #21

Tradewinds's Avatar

Join Date: Nov 2008
Posts: 910
Ignore this user

Thanks: 379
Thanked 257 Times in 178 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Quote:
Originally Posted by furtrader »
any1 could help me to convert this please

its only my simple indicator to plot local time on chart
Here is code that puts the clock on the chart. See the ELD file. I got it from the tradestation, EasyLanguage Forum:

eKam Clock and Timer

Here is some really simple code that I create:

Code:
Once
Begin
	Value1=Text_new(D,T,H,numtostr(T,2));
End;

Text_SetString(Value1, NumToStr(T,2));
Text_SetLocation(Value1, D, T, getappinfo(aihighestDispValue));
Attached Files
File Type: eld 20100526131127BarCountdownTimer.ELD (19.7 KB, 164 views)
Tradewinds is offline  
Reply With Quote
Old 09-26-2011, 09:00 PM   #22

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,663 Times in 1,010 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Quote:
Originally Posted by Tradewinds »
Here is code that puts the clock on the chart. See the ELD file. I got it from the tradestation, EasyLanguage Forum:

eKam Clock and Timer

Here is some really simple code that I create:

Code:
Once
Begin
	Value1=Text_new(D,T,H,numtostr(T,2));
End;

Text_SetString(Value1, NumToStr(T,2));
Text_SetLocation(Value1, D, T, getappinfo(aihighestDispValue));

this code only gives you the ending time of the bar.

you should use currenttime:

Text_SetString(Value1, NumToStr(CURRENTTIME,0));


MultiCharts user can use CURRENTTIME_s, which gives the seconds portion of the time.


ps. there is a function/keyword to format the time into hh:mm:ss
__________________
Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
Tradewinds (09-26-2011)
Old 09-26-2011, 09:33 PM   #23

Tradewinds's Avatar

Join Date: Nov 2008
Posts: 910
Ignore this user

Thanks: 379
Thanked 257 Times in 178 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Quote:
Originally Posted by Tams »
this code only gives you the ending time of the bar.

you should use currenttime:

Text_SetString(Value1, NumToStr(CURRENTTIME,0));


MultiCharts user can use CURRENTTIME_s, which gives the seconds portion of the time.


ps. there is a function/keyword to format the time into hh:mm:ss
Okay. Thanks. I learned something new. See, it's worth sharing code even if it's not perfect.
Tams likes this.
Tradewinds is offline  
Reply With Quote
Old 09-26-2011, 10:05 PM   #24

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,663 Times in 1,010 Posts

Re: Convert MT4 Indicator into Tradestation Eld?

Quote:
Originally Posted by Tradewinds »
Okay. Thanks. I learned something new. See, it's worth sharing code even if it's not perfect.
yes... the more we share, the better WE become.
__________________
Arguing with a troll is a lot like wrestling in the mud with a pig, after a couple of hours you realize the pig likes it.
Tams is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
Any Tradestation Market Profile Indicator? agabr Coding Forum 6 08-12-2011 05:23 PM
Bid-Ask Pressure Indicator for Tradestation Soultrader Trading Indicators 81 08-18-2009 03:29 PM
Alchemy TradeStation Indicator Package captjoe Coding Forum 1 11-29-2008 08:05 PM
Colby Indicator For Tradestation slableak Brokers and Data Feeds 12 11-29-2008 10:23 AM
BRICKS Indicator for Tradestation Soultrader Trading Indicators 8 02-23-2008 09:10 PM

All times are GMT -4. The time now is 09:33 PM.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.