NexusFi: Find Your Edge


Home Menu

 





mt4 indicator to tradestation


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one bobwest with 1 posts (1 thanks)
    2. looks_two numberjuani with 1 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 yamin2000 with 1 posts (0 thanks)
    1. trending_up 1,751 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

mt4 indicator to tradestation

  #1 (permalink)
yamin2000
Saudi Arabia
 
Posts: 58 since Apr 2014
Thanks Given: 26
Thanks Received: 4

hi
could any one please make this mt4 indicator work in tradestation


//+------------------------------------------------------------------+
//| SweetSpots.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
//| SweetSpotsGOLD_TRO_MODIFIED_VERSION |
//| MODIFIED BY AVERY T. HORTON, JR. AKA [email protected] |
//| I am NOT the ORIGINAL author
// and I am not claiming authorship of this indicator.
// All I did was modify it. I hope you find my modifications useful.|
//| |
//+------------------------------------------------------------------+


#property copyright "Copyright Shimodax"
#property link "http://www.strategybuilderfx.com"

#property indicator_chart_window

/* Introduction:

This indicator shows lines at sweet spots (50 and 100
pips levels). It is recommended to turn off the grid.

Enjoy!

Markus
*/

extern bool TURN_OFF = false ;
extern bool AutoAdjust = true;
extern bool Show_Labels = true ;
extern int ShiftLabel = 2 ;

extern int NumLinesAboveBelow = 100;
extern int SweetSpotMainLevels = 100;

extern color LineColorMain= Yellow;
extern int LineStyleMain= STYLE_DOT;

extern bool ShowSubLevels= true;
extern int sublevels= 10;

extern color LineColorSub= Yellow;
extern int LineStyleSub= STYLE_DOT;


string symbol, tChartPeriod, tShortName, pricelabel ;
int digits, period, digits2, mult = 1 ;
double point ;

//+------------------------------------------------------------------+
int init()
{
period = Period() ;
symbol = Symbol() ;
digits = Digits ;
point = Point ;

if(digits == 5 || digits == 3) { mult = 10; digits = digits - 1 ; point = point * 10 ; }

if(AutoAdjust && period > PERIOD_H1 && period < PERIOD_MN1) { mult = mult * 10; }
if(AutoAdjust && period == PERIOD_MN1) { mult = mult * 100; }

SweetSpotMainLevels = SweetSpotMainLevels * mult;

sublevels = sublevels * mult;

deinit();

return(0);
}

//+------------------------------------------------------------------+
int deinit()
{
int obj_total= ObjectsTotal();

for (int i= obj_total; i>=0; i--) {
string name= ObjectName(i);

if (StringSubstr(name,0,11)=="[SweetSpot]")
ObjectDelete(name);
}
TRO();
return(0);
}

//+------------------------------------------------------------------+
int start()
{
if( TURN_OFF ) { return(0) ; }

static datetime timelastupdate= 0;
static datetime lasttimeframe= 0;


// no need to update these buggers too often
if (CurTime()-timelastupdate < 600 && Period()==lasttimeframe)
return (0);

deinit(); // delete all previous lines

int i, ssp1, style, ssp, thickness; //sublevels= 50;
double ds1;
color linecolor;

if (!ShowSubLevels)
sublevels*= 2;

ssp1= Bid / Point;
ssp1= ssp1 - ssp1%sublevels;

for (i= -NumLinesAboveBelow; i<NumLinesAboveBelow; i++)
{

ssp= ssp1+(i*sublevels);

if (ssp%SweetSpotMainLevels==0)
{
style= LineStyleMain;
linecolor= LineColorMain;
}
else
{
style= LineStyleSub;
linecolor= LineColorSub;
}

thickness= 1;

if (ssp%(SweetSpotMainLevels*10)==0)
{
thickness= 2;
}

if (ssp%(SweetSpotMainLevels*100)==0)
{
thickness= 3;
}

ds1= ssp*Point;
SetLevel(DoubleToStr(ds1,Digits), ds1, linecolor, style, thickness, Time[10]);
}

return(0);
}


//+------------------------------------------------------------------+
//| Helper |
//+------------------------------------------------------------------+
void SetLevel(string text, double level, color col1, int linestyle, int thickness, datetime startofday)
{

string linename= "[SweetSpot] " + text + " Line" + pricelabel;

// create or move the horizontal line
if (ObjectFind(linename) != 0) {
ObjectCreate(linename, OBJ_TREND, 0, Time[0], level, Time[1], level, 0, 0);

// ObjectCreate(linename, OBJ_HLINE, 0, 0, level);

ObjectSet(linename, OBJPROP_STYLE, linestyle);
ObjectSet(linename, OBJPROP_COLOR, col1);
ObjectSet(linename, OBJPROP_WIDTH, thickness);

ObjectSet(linename, OBJPROP_RAY, true);
ObjectSet(linename, OBJPROP_BACK, True);
}
else {
ObjectMove(linename, 0, Time[0], level);
}


if(Show_Labels)
{


string Obj0002 = linename+"linelbl" ;

ObjectDelete(Obj0002);

if(ObjectFind(Obj0002) != 0)
{
ObjectCreate(Obj0002,OBJ_ARROW,0,Time[0],level);
ObjectSet(Obj0002,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(Obj0002,OBJPROP_COLOR,col1);
}
else
{
ObjectMove(Obj0002,0,Time[0],level);
}


} // if

}


//+------------------------------------------------------------------+
void TRO()
{

string tObjName03 = "TROTAG" ;
ObjectCreate(tObjName03, OBJ_LABEL, 0, 0, 0);//HiLow LABEL
ObjectSetText(tObjName03, CharToStr(78) , 12 , "Wingdings", DimGray );
ObjectSet(tObjName03, OBJPROP_CORNER, 3);
ObjectSet(tObjName03, OBJPROP_XDISTANCE, 5 );
ObjectSet(tObjName03, OBJPROP_YDISTANCE, 5 );
}
//+------------------------------------------------------------------+

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 
numberjuani's Avatar
 numberjuani 
Agoura Hills, CA USA
 
Experience: Advanced
Platform: Tradestation&Multicharts
Broker: TradeStation
Trading: Futures & Equities
Posts: 128 since Apr 2019
Thanks Given: 9
Thanks Received: 102



yamin2000 View Post
hi
could any one please make this mt4 indicator work in tradestation


//+------------------------------------------------------------------+
//| SweetSpots.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
//| SweetSpotsGOLD_TRO_MODIFIED_VERSION |
//| MODIFIED BY AVERY T. HORTON, JR. AKA [email protected] |
//| I am NOT the ORIGINAL author
// and I am not claiming authorship of this indicator.
// All I did was modify it. I hope you find my modifications useful.|
//| |
//+------------------------------------------------------------------+


#property copyright "Copyright Shimodax"
#property link "http://www.strategybuilderfx.com"

#property indicator_chart_window

/* Introduction:

This indicator shows lines at sweet spots (50 and 100
pips levels). It is recommended to turn off the grid.

Enjoy!

Markus
*/

extern bool TURN_OFF = false ;
extern bool AutoAdjust = true;
extern bool Show_Labels = true ;
extern int ShiftLabel = 2 ;

extern int NumLinesAboveBelow = 100;
extern int SweetSpotMainLevels = 100;

extern color LineColorMain= Yellow;
extern int LineStyleMain= STYLE_DOT;

extern bool ShowSubLevels= true;
extern int sublevels= 10;

extern color LineColorSub= Yellow;
extern int LineStyleSub= STYLE_DOT;


string symbol, tChartPeriod, tShortName, pricelabel ;
int digits, period, digits2, mult = 1 ;
double point ;

//+------------------------------------------------------------------+
int init()
{
period = Period() ;
symbol = Symbol() ;
digits = Digits ;
point = Point ;

if(digits == 5 || digits == 3) { mult = 10; digits = digits - 1 ; point = point * 10 ; }

if(AutoAdjust && period > PERIOD_H1 && period < PERIOD_MN1) { mult = mult * 10; }
if(AutoAdjust && period == PERIOD_MN1) { mult = mult * 100; }

SweetSpotMainLevels = SweetSpotMainLevels * mult;

sublevels = sublevels * mult;

deinit();

return(0);
}

//+------------------------------------------------------------------+
int deinit()
{
int obj_total= ObjectsTotal();

for (int i= obj_total; i>=0; i--) {
string name= ObjectName(i);

if (StringSubstr(name,0,11)=="[SweetSpot]")
ObjectDelete(name);
}
TRO();
return(0);
}

//+------------------------------------------------------------------+
int start()
{
if( TURN_OFF ) { return(0) ; }

static datetime timelastupdate= 0;
static datetime lasttimeframe= 0;


// no need to update these buggers too often
if (CurTime()-timelastupdate < 600 && Period()==lasttimeframe)
return (0);

deinit(); // delete all previous lines

int i, ssp1, style, ssp, thickness; //sublevels= 50;
double ds1;
color linecolor;

if (!ShowSubLevels)
sublevels*= 2;

ssp1= Bid / Point;
ssp1= ssp1 - ssp1%sublevels;

for (i= -NumLinesAboveBelow; i<NumLinesAboveBelow; i++)
{

ssp= ssp1+(i*sublevels);

if (ssp%SweetSpotMainLevels==0)
{
style= LineStyleMain;
linecolor= LineColorMain;
}
else
{
style= LineStyleSub;
linecolor= LineColorSub;
}

thickness= 1;

if (ssp%(SweetSpotMainLevels*10)==0)
{
thickness= 2;
}

if (ssp%(SweetSpotMainLevels*100)==0)
{
thickness= 3;
}

ds1= ssp*Point;
SetLevel(DoubleToStr(ds1,Digits), ds1, linecolor, style, thickness, Time[10]);
}

return(0);
}


//+------------------------------------------------------------------+
//| Helper |
//+------------------------------------------------------------------+
void SetLevel(string text, double level, color col1, int linestyle, int thickness, datetime startofday)
{

string linename= "[SweetSpot] " + text + " Line" + pricelabel;

// create or move the horizontal line
if (ObjectFind(linename) != 0) {
ObjectCreate(linename, OBJ_TREND, 0, Time[0], level, Time[1], level, 0, 0);

// ObjectCreate(linename, OBJ_HLINE, 0, 0, level);

ObjectSet(linename, OBJPROP_STYLE, linestyle);
ObjectSet(linename, OBJPROP_COLOR, col1);
ObjectSet(linename, OBJPROP_WIDTH, thickness);

ObjectSet(linename, OBJPROP_RAY, true);
ObjectSet(linename, OBJPROP_BACK, True);
}
else {
ObjectMove(linename, 0, Time[0], level);
}


if(Show_Labels)
{


string Obj0002 = linename+"linelbl" ;

ObjectDelete(Obj0002);

if(ObjectFind(Obj0002) != 0)
{
ObjectCreate(Obj0002,OBJ_ARROW,0,Time[0],level);
ObjectSet(Obj0002,OBJPROP_ARROWCODE,SYMBOL_RIGHTPRICE);
ObjectSet(Obj0002,OBJPROP_COLOR,col1);
}
else
{
ObjectMove(Obj0002,0,Time[0],level);
}


} // if

}


//+------------------------------------------------------------------+
void TRO()
{

string tObjName03 = "TROTAG" ;
ObjectCreate(tObjName03, OBJ_LABEL, 0, 0, 0);//HiLow LABEL
ObjectSetText(tObjName03, CharToStr(78) , 12 , "Wingdings", DimGray );
ObjectSet(tObjName03, OBJPROP_CORNER, 3);
ObjectSet(tObjName03, OBJPROP_XDISTANCE, 5 );
ObjectSet(tObjName03, OBJPROP_YDISTANCE, 5 );
}
//+------------------------------------------------------------------+

Can you post in plain english what it does with a screenshot? I Dont know mt4 language

Reply With Quote
Thanked by:
  #4 (permalink)
 
bobwest's Avatar
 bobwest 
Western Florida
Site Moderator
 
Experience: Advanced
Platform: Sierra Chart
Trading: ES, YM
Frequency: Several times daily
Duration: Minutes
Posts: 8,168 since Jan 2013
Thanks Given: 57,452
Thanks Received: 26,278


yamin2000 View Post
hi
could any one please make this mt4 indicator work in tradestation


numberjuani View Post
Can you post in plain english what it does with a screenshot? I Dont know mt4 language

Also, a couple of pro tips:

1. No one is going to attempt to touch that code, because the formatting, with everything slammed up against the left margin, will drive a coder insane. To properly post code, first click on the "#" button at the top of the edit window (if you put the mouse on it, it will say "Wrap Code tags around selected text.) What you get is something like this, taken from your code:

 
Code
int deinit()
{
   int obj_total= ObjectsTotal();
   
   for (int i= obj_total; i>=0; i--) {
      string name= ObjectName(i);
    
      if (StringSubstr(name,0,11)=="[SweetSpot]") 
         ObjectDelete(name);
   }
   TRO();
   return(0);
}

A coder can read this, because the formatting makes the logical structure clear, and you can see what is nested within which block.

2. No one is going to touch the code without first knowing what it is supposed to do. Sure, someone who knows the language can usually work their way through the code (not easily) and figure out (or guess) why it is doing what it is doing, but a chart image and an explanation makes it much easier, as @numberjuani says.

3. You can even not bother to post the actual code in the body of your post. In fact, I suggest this. Instead, in your post describe what the code does and give a picture of how it should look if the conversion is done right. Then attach a file with the code to the post. Usually you can just attach the source code file that you got from the original program in the first place, and had to copy into the post. Just use that.

If I were going to convert this code, I would first have to copy it into a new source code file, and get it formatted so I could read it. It's better to start out that way.

If you do all these three things, it is more likely that someone will give you a hand.

I'm not criticizing you ( ), just trying to help you and others who need some code worked on.

Good luck with your project.

Bob.

When one door closes, another opens.
-- Cervantes, Don Quixote
Reply With Quote
Thanked by:




Last Updated on November 25, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts