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

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

resetting EA/Script 0 replies

Resetting EA 6 replies

Resetting MT4 EA Parameters through code 5 replies

resetting balance 2 replies

Resetting Market Watch to local Time 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 6
Attachments: Indicator Resetting
Exit Attachments

Indicator Resetting

  • Post #1
  • Quote
  • First Post: Sep 7, 2011 1:18am Sep 7, 2011 1:18am
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
hi

I have an indicator I downloaded that I would like to tweak, but it is beyond me. It is not my indicator, but is freely available on the web and is quite useful.

The indicator is a voice alert when support or resistance is broken. When the indicator is added to a chart, the S+R lines can be moved and can even be angled. Then a voice tells me when S or R is broken.

Originally it worked only for 19 pairs, but I fixed it to add an additional 7 pairs, so it now works with the 26 pairs I monitor. I changed the wave files as well from a male US voice to a female English voice. Just personal preference that one and was done at a website that allows text to voice and allows wave files to be saved.

The thing that gets me, though, is if I move the S+R lines to where I want and then change the timeframe at a later time, the lines reset to the default. I would like them to remain where I put them.

The other thing is the inability to change the colour of either line. They obviously have defaults as Red for support + Blue for resistance. If I change the colour to anything else, it immediately changes back. I'd like to be able to select the colour of my choice

I have included the .mq4 file.

thanks in advance

honkin
Attached File
File Type: mq4 Chin+Breakout+Alert+V.1.2s.mq4   27 KB | 260 downloads
  • Post #2
  • Quote
  • Sep 7, 2011 1:53am Sep 7, 2011 1:53am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
you are going to have to do the work.... but

Inserted Code
   //Before we Start, Let's delete all the objects:
   
   ObjectDelete("top");
   ObjectDelete("bottom");

   ObjectDelete("Top Instruction");
   ObjectDelete("Bottom Instruction");
   
   ObjectDelete("Vis1");
   ObjectDelete("Vis2");
   ObjectDelete("Vis3");
   ObjectDelete("Vis4");
probably move this from the init section into the deinit section, and wrap it around a test checking UninitializeReason() isn't REASON_CHARTCHANGE. if it is due to reason_chartchange then you obviously DON'T want to delete your objects.

and also in the init section it creates and then sets data for these objects. wrap them into a test to see if they don't already exist. if they already exist then DON'T make any settings on them (you'll see this is where the colours are set and why you keep losing what you change them to). if the objects don't exist then create the object and set the default paramaters as per the current code that's there already.
Forex Trading for the Savvy Beginner
 
 
  • Post #3
  • Quote
  • Sep 7, 2011 3:37am Sep 7, 2011 3:37am
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
cheers nubcake and thanks for your reply.

I am very basic in my coding skills, but what I can see is the deinit section already has the following code:

ObjectDelete("top");
ObjectDelete("bottom");

ObjectDelete("Top Instruction");
ObjectDelete("Bottom Instruction");

ObjectDelete("Top Instruction2");
ObjectDelete("Bottom Instruction2");

I am absolutely happy to do all the coding, as it is the only way I will learn. But in your first paragraph, are you able to tell me how to wrap something in a test to check the UninitializeReason()?

I have found the following code:

int init() { Alert("","Start",UninitializeReason()); } int deinit() { Alert("","Stop" ,UninitializeReason()); } but wonder where to place the start and where the stop.


So are you suggesting I cut and paste the code you showed and overwrite the text in the deinit section?

With your second paragraph, are you saying to wrap all of the original code in the init section in a test to see if the objects exist. Again, what code will enable such a test?

Sorry to be a bit thick on this, but I have traded using MT4 for quite a while, but not really used mql4 very much.

Can I also assume that default the colours are set in this code:

//length of the window # of bars short by 1/7
ObjectCreate("top",2,0,Time[windowbars]+windowbars*0.321*Period()*60,hi,Time[0],hi);
ObjectSet("top",OBJPROP_COLOR,Blue);

ObjectCreate("bottom",2,0,Time[windowbars]+windowbars*0.312*Period()*60,lo,Time[0],lo);
ObjectSet("bottom",OBJPROP_COLOR,Red);

Or will it just be wiser to change all occurrences of Red or Blue with the colours of my choice, as there are other areas that show ObjectSet?

cheers nubcake

honkin
 
 
  • Post #4
  • Quote
  • Sep 7, 2011 4:11am Sep 7, 2011 4:11am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
Quoting honkin
Disliked
cheers nubcake and thanks for your reply.

I am very basic in my coding skills, but what I can see is the deinit section already has the following code:

ObjectDelete("top");
ObjectDelete("bottom");

ObjectDelete("Top Instruction");
ObjectDelete("Bottom Instruction");

ObjectDelete("Top Instruction2");
ObjectDelete("Bottom Instruction2");

I am absolutely happy to do all the coding, as it is the only way I will learn. But in your first paragraph, are you able to tell me how to wrap something in a test to check the UninitializeReason()?...
Ignored
i only took a cursory look at the attached indicator code because it simply doesn't interest me enough for me to get right into it... so if the deletes are also in the deinit, which they should be anyway if it was coded properly, then you need to do something along the lines of the following in the deinit section...

if (UninitializeReason() != REASON_CHARTCHANGE) {
objectdelete...
objectdelete...
objectdelete...
etc...
}

if the indi calls deinit due to you changing the timeframe then the indi won't delete the objects (wiping all of what you had set up on the chart). then when it runs the init section once it restarts it should check to see if objects already exist, and if so then not do anything, else it should create them.

in init something like...

if (objectfind(.....NAME....) < 0) {
objectcreate....
objectset....
etc....
}
if (objectfind(.....NAME2....) < 0) {
objectcreate....
objectset....
etc....
}

etc...

objectfind returns the 'window' the object is located on the chart. zero means the main chart. 1 means the first indicator sub window, 2 the second sub-window, and so on. -1 means the object doesn't exist. note that this is only per chart, so it won't find an object of the same name on any other chart window or currency pair chart... only the current window or it's sub-windows. that's why you can attach these types of indi's onto different charts and have them not conflict with each other.

Quote
Disliked
Can I also assume that default the colours are set in this code:

//length of the window # of bars short by 1/7
ObjectCreate("top",2,0,Time[windowbars]+windowbars*0.321*Period()*60,hi,Time[0],hi);
ObjectSet("top",OBJPROP_COLOR,Blue);

ObjectCreate("bottom",2,0,Time[windowbars]+windowbars*0.312*Period()*60,lo,Time[0],lo);
ObjectSet("bottom",OBJPROP_COLOR,Red);
yep. you nailed it.

Quote
Disliked
Or will it just be wiser to change all occurrences of Red or Blue with the colours of my choice, as there are other areas that show ObjectSet?
up to you, or you could add the option to set the colour via external colour variables that you can then manually set in the indicator inputs tab when you first attach the indi.
Forex Trading for the Savvy Beginner
 
 
  • Post #5
  • Quote
  • Sep 7, 2011 4:49am Sep 7, 2011 4:49am
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
Quoting nubcake
Disliked

in init something like...

if (objectfind(.....NAME....) < 0) {
objectcreate....
objectset....
etc....
}
if (objectfind(.....NAME2....) < 0) {
objectcreate....
objectset....
etc....
}

up to you, or you could add the option to set the colour via external colour variables that you can then manually set in the indicator inputs tab when you first attach the indi.
Ignored
Thanks again nubcake. I added the parameter in deinit and it still deleted them when I switched timeframes, so I actually added // before all of the ObjectDelete lines in the init section. This seems to have stopped them being deleted and they still appear to work correctly, though I'll test them a bit more. It just saved me finding the ObjectCreate sections and adding if (objectfind etc.

I'd love to know how to add the option to set the colour via external colour variables. That way whoever else might use the indy can choose their own colour. Will that automatically override the colour parameters set under ObjectSet or will I just need to // those lines out?

thanks very much for your help

honkin
 
 
  • Post #6
  • Quote
  • Edited at 5:43am Sep 7, 2011 5:13am | Edited at 5:43am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
compare against your original indi... you'll see the changes i made.

edit : ok re-uploaded. note that the colours don't change if you edit the inputs tab after already having run the indi... it's probably easier to not include the 'extern' colour variables i added at the top and instead just specifically change the objects color manually, since it now retains itself anyway.... or just don't make the colours extern, and you just compile with the specific colours you prefer as the starting colours. the main reason i personally made them as externals is so you can see what i meant earlier, but it's redundant now.
Attached File
File Type: mq4 testingotherscodeindi.mq4   21 KB | 280 downloads
Forex Trading for the Savvy Beginner
 
 
  • Post #7
  • Quote
  • Sep 7, 2011 7:45am Sep 7, 2011 7:45am
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
fantastic nubcake

I see now what the code is to make a colour input and I also saw the changes you made with regards the // I added to stop deletion in the init section and the changes in the deinit section as well. That's all I could spot, but they give me an insight into the workings of some of the code and are much appreciated.

I am slowly learning, so thanks very much for all your help

honkin
 
 
  • Post #8
  • Quote
  • Sep 7, 2011 8:00am Sep 7, 2011 8:00am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
no probs. i'm confident i didn't break anything. it's a good chance for you to really sink your teeth into understanding how shit works and how to create simplistic solutions to problems.
Forex Trading for the Savvy Beginner
 
 
  • Post #9
  • Quote
  • Sep 8, 2011 9:00pm Sep 8, 2011 9:00pm
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
howdy nubcake

The indy is working a treat now so thanks very much.

I had a question u may be able to answer though.

I have 2 version of Mt4 from different brokers and the indicator works on one, but on the other, it fails to find the sound files, even though they are there. It displays the standard message of a S or R breech but says no audio support. That is the message when the audio files do not exist

Do you think I may have to actually point towards where the sound files are located in this instance, or could you hazard a guess as to why the sound files might not be found?

I can only assume that this version of MT4 is expecting sound files from indicators to be in a different location than just the standard MT4/Sounds folder

cheers

honkin
 
 
  • Post #10
  • Quote
  • Sep 8, 2011 9:19pm Sep 8, 2011 9:19pm
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
have a look at the names used for the currency pairs on the one that isn't working... i bet it's some bullshit weird name like USDJPYvvw22 instead of just being USDJPY.

if that's the case then the issue is simply the indicator not finding a match when setting the sym variable. to get around this you would change the if sym$ = "specific currency symbol" to instead do a string search of sym$ to find if the currency pair is within the string.... because asdfUSDJPYsdff still contains the original USDJPY text within the obscure symbol name, for example.

if this isn't the problem, then i'm not sure.
Forex Trading for the Savvy Beginner
 
 
  • Post #11
  • Quote
  • Sep 8, 2011 9:27pm Sep 8, 2011 9:27pm
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
hi nubcake

Yeah, spot on. I should have spotted it.

This version calls the pairs USDJPYfx instead of USDJPY.

You're right, I just change the if sym$ to match. I doubt I will have to I don't think I will need to start changing the audio filenames to USDYPYfx.wav, so this should be fine.

I can't believe I didn't spot that it names them differently. What a strange way to do it.

thanks again

honkin
 
 
  • Post #12
  • Quote
  • Sep 8, 2011 9:34pm Sep 8, 2011 9:34pm
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
Quoting honkin
Disliked
hi nubcake

Yeah, spot on. I should have spotted it.

This version calls the pairs USDJPYfx instead of USDJPY.

You're right, I just change the if sym$ to match. I doubt I will have to I don't think I will need to start changing the audio filenames to USDYPYfx.wav, so this should be fine.

I can't believe I didn't spot that it names them differently. What a strange way to do it.

thanks again

honkin
Ignored
no don't change the if sym$ to match the different name, because then it's still not compatible with any other obscure symbol name just like it is now with this second mt4.... use :

if (StringFind(Symbol(), "AUDCAD", 0) > -1) sym = 1

and so on for each of the different symbols.
Forex Trading for the Savvy Beginner
 
 
  • Post #13
  • Quote
  • Sep 8, 2011 9:43pm Sep 8, 2011 9:43pm
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
OK, that's probably best in case anyone else uses it in another version of MT4 with a different naming altogether

Once again I am in your debt

cheers

honkin
 
 
  • Post #14
  • Quote
  • Sep 21, 2011 2:00am Sep 21, 2011 2:00am
  •  honkin
  • | Joined Jan 2011 | Status: Member | 30 Posts
hello again nubcake

I wonder if I might pick your brain again please re 2 handy indicators I have found. If not, no problem at all. They are TrendAcanner and ForexCurrencyIndex

One of the problems is similar to what I experienced with this last one in that they only work for normal naming like EURUSD, whereas one of the MT4 version uses EURUSDfx.

This time, instead of the string

if (sym$== "AUDCAD" ) sym = 1 ;

the TrendScanner has

extern string Sym1 = "EURUSD";

I recall that the last time you fixed the problem by getting me to change that first line to read

if (StringFind(Symbol(), "EURUSD", 0) > -1) sym = 1 ;

I wasn't sure if it would the same this time due to the line being different to the last time. The ForexCurrencyIndex is different again

The second problem both indicators have is when placed in a chart, the right hand side of them is chopped off.

With the TrendScanner, there only appears to be 2 areas relating to horizontal. 1 line has

extern int horizontal_space = 40;

The other entries are

int start() {
cleanup();
gi_380 = 35;
gi_384 = horizontal_space;
for (int l_index_0 = 0; l_index_0 < gi_432; l_index_0++) {
if (gsa_428[l_index_0] != "") {
Calc(gsa_428[l_index_0], gi_380);
DrawText(gsa_428[l_index_0], gi_380, 1);
gi_380 += gi_384;
}

I know both indicators work well, but neither work with different naming and both get chopped off at the right instead of sizing according to the chart width

Any help (again) gladly accepted.

Regards

honkin
Attached Files
File Type: mq4 ForexCurrencyIndex.mq4   25 KB | 302 downloads
File Type: mq4 TrendScanner.mq4   11 KB | 307 downloads
 
 
  • Post #15
  • Quote
  • Edited at 4:49am Sep 21, 2011 4:24am | Edited at 4:49am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 3,698 Posts
Quoting honkin
Disliked
hello again nubcake

I wonder if I might pick your brain again please re 2 handy indicators I have found. If not, no problem at all. They are TrendAcanner and ForexCurrencyIndex

One of the problems is similar to what I experienced with this last one in that they only work for normal naming like EURUSD, whereas one of the MT4 version uses EURUSDfx.

This time, instead of the string

if (sym$== "AUDCAD" ) sym = 1 ;

the TrendScanner has

extern string Sym1 = "EURUSD";

I recall that the last time you fixed the problem by...
Ignored
i can't really help much at the moment... purely because i'm lazy and uninterested.

saying that, i did have a browse through the trend one. because you have decompiled the original ex4 file (or received it from someone else who did this) the original variable names are all replaced with generic arbitrary names.

it's become pretty clear from looking through this stuff that there is a very simple pattern to the generic variable names in this decompiled indicator. g = global. s = string. a = array. gsa = global string array. i = int. gi = global integer. l = local. li = local integer. ld = local double. a# = a variable passed to the current function. as = passed variable of string type. ai = passed variable of integer type.

i don't know why g_name and a_name exists and a_timeframe etc. it seems in some instances compiling mql into an ex4 file retains some of the names used, and in these instances the decompiled names include this pre-baked name. so g_name was probably originally a global variable literally called 'name'. a_text was probably literally called 'text'. a_symbol called 'symbol'. a_y called 'y', and so on. i don't know why they retain some names, and others get altered into purely generic names when compiled... or decompiled... whichever step drops the name from the file.

anyway, with that out of the way it will be a bit easier for you to read the variables within the body of the code and have an idea of where they originate and what type they are and their potential purpose. from that you can do 'replace all' for variables with meaningful names as you figure out what each variable is meant to be used for.

gsa_428[] (global string array type) is the array that stores the list of 'extern' symbol strings, and when passed into the Calc function it is referred in there by as_0 (passed into this function as a local variable of string type). then, within this Calc function it does a check to see if the broker is Interbank. if the broker is Interbank then the symbol names apparently have an 'm' on the end, similar to your previous issue with your own broker having odd symbol() names and so it attempts to deal with this odd naming convention.

the result either way is that the global string variable gs_412 is now meant to refer to the symbol() of the attached chart.

EDIT : wrong. not of the attached chart. it's just trying to figure out if it is meant to append the 'm' or not when it later calls things like iMA and iClose etc... my brain switched off.

i could make it attempt to automatically figure-out the odd symbol name prefix and suffix chars that a broker has added to their non-standard symbol name, but i can't be bothered. it's simpler to simply manually specify what your broker happens to put in front and behind the standard symbol names.

i've altered the code to accommodate exactly this. if the broker has their names like "barneyEURUSDfred", then when you load the indicator you put in SymbolPrefix "barney" and SymbolSuffix "fred". this should be enough.

i've gone through and renamed most of the generic variable names so that it's much more readable. i don't know if i have broken anything or not, but when i run it on my mt4 it locks it up. i assume this is because i don't have the history for the 28 different symbols as well as each of the different timeframes and so mt4 is desperately trying to download a butt-load of data that i don't have in my history at the moment... so i tested having it only set to 2 symbols and just m1 and it ran ok, but didn't display anything except grey boxes. so, yeah... don't know what the deal is but not really concerned.

i'm not sure what you mean by it cuts off on the right side. i guess you mean it doesn't show all of the symbols because your screen resolution is not wide enough to display all of the bars. i'm too tired to look into that part, so have a look at the code and see if you can't tinker with it and find it yourself. it could be one of the (now named) globalxdist or globalxdist2 variables, or the horizontal_space variable, or it could be one of the generic integers within the drawobject and drawtext sections. have a tinker and you'll work it out.

i haven't looked at the other indicator, but i imagine it'll probably be easiest to implement a prefix and suffix solution as per below for that one too, once you figure out what each part of the code does.

have a look...

Inserted Code
/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/
#property copyright "Copyright 2008, www.LearnForexLive.com"
#property link      "http://www.LearnForexLive.com"

#property indicator_separate_window

extern string SymbolPrefix = "";
extern string SymbolSuffix = "";

extern color colorDown = Red;
extern color colorFlat = DimGray;
extern color colortext = White;
extern color colorUp = Lime;
extern int horizontal_space = 40;
extern int vertical_space = 20;

extern bool MN = FALSE;
extern bool W1 = TRUE;
extern bool D1 = TRUE;
extern bool H4 = TRUE;
extern bool H1 = TRUE;
extern bool M30 = TRUE;
extern bool M15 = TRUE;
extern bool M5 = TRUE;
extern bool M1 = FALSE;

/*extern bool MN = FALSE;
extern bool W1 = false;
extern bool D1 = false;
extern bool H4 = false;
extern bool H1 = false;
extern bool M30 = false;
extern bool M15 = false;
extern bool M5 = false;
extern bool M1 = true;*/

//int gi_136 = 40;
int TrendTestBarPeriod2 = 20;
int TrendTestBarPeriod = 40;
int iMAShiftValue2 = 5;
int iMAShiftValue = 1;
extern string Sym1 = "EURUSD";
extern string Sym2 = "GBPUSD";
extern string Sym3 = "USDJPY";
extern string Sym4 = "USDCHF";
extern string Sym5 = "USDCAD";
extern string Sym6 = "AUDUSD";
extern string Sym7 = "NZDUSD";
extern string Sym8 = "EURJPY";
extern string Sym9 = "EURGBP";
extern string Sym10 = "GBPJPY";
extern string Sym11 = "GBPCHF";
extern string Sym12 = "CADJPY";
extern string Sym13 = "EURCHF";
extern string Sym14 = "CHFJPY";
extern string Sym15 = "GBPCAD";
extern string Sym16 = "EURCAD";
extern string Sym17 = "AUDJPY";
extern string Sym18 = "EURAUD";
extern string Sym19 = "GBPAUD";
extern string Sym20 = "NZDCAD";
extern string Sym21 = "NZDJPY";
extern string Sym22 = "NZDCHF";
extern string Sym23 = "EURNZD";
extern string Sym24 = "AUDNZD";
extern string Sym25 = "CADCHF";
extern string Sym26 = "AUDCHF";
extern string Sym27 = "AUDCAD";
extern string Sym28 = "GBPNZD";
int globalxdist;
int globalxdist2;
int globalydist;
int globalydist2;
string indishortname;
string correctedsymbol;
string globalname;
string externsymbolarray[30];
int symbolarraysize = 28;

int init() {
   indishortname = "Trend Scanner";
   IndicatorShortName(indishortname);
   externsymbolarray[0] = Sym1;
   externsymbolarray[1] = Sym2;
   externsymbolarray[2] = Sym3;
   externsymbolarray[3] = Sym4;
   externsymbolarray[4] = Sym5;
   externsymbolarray[5] = Sym6;
   externsymbolarray[6] = Sym7;
   externsymbolarray[7] = Sym8;
   externsymbolarray[8] = Sym9;
   externsymbolarray[9] = Sym10;
   externsymbolarray[10] = Sym11;
   externsymbolarray[11] = Sym12;
   externsymbolarray[12] = Sym13;
   externsymbolarray[13] = Sym14;
   externsymbolarray[14] = Sym15;
   externsymbolarray[15] = Sym16;
   externsymbolarray[16] = Sym17;
   externsymbolarray[17] = Sym18;
   externsymbolarray[18] = Sym19;
   externsymbolarray[19] = Sym20;
   externsymbolarray[20] = Sym21;
   externsymbolarray[21] = Sym22;
   externsymbolarray[22] = Sym23;
   externsymbolarray[23] = Sym24;
   externsymbolarray[24] = Sym25;
   externsymbolarray[25] = Sym26;
   externsymbolarray[26] = Sym27;
   externsymbolarray[27] = Sym28;
   externsymbolarray[28] = "";
   externsymbolarray[29] = "";
   return (0);
}

void deinit() {
   cleanup();
}

int start() {
   cleanup();
   globalxdist = 35;
   globalxdist2 = horizontal_space;
   for (int index = 0; index < symbolarraysize; index++) {
      if (externsymbolarray[index] != "") {
         Calc(externsymbolarray[index], globalxdist);
         DrawText(externsymbolarray[index], globalxdist, 1);
         globalxdist += globalxdist2;
      }
   }
   return (0);
}

void Calc(string symbolname, int xdist) {
  int pos;
    
   RefreshRates();
   globalydist = 20;
   globalydist2 = 19;

   correctedsymbol = SymbolPrefix + symbolname + SymbolSuffix;
   
   int li_12 = 0;
   if (M1 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_M1);
      if (li_12 > 0) DrawObject(symbolname + "m1", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "m1", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "m1", xdist, globalydist, colorFlat);
      DrawText2("M1", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (M5 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_M5);
      if (li_12 > 0) DrawObject(symbolname + "m5", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "m5", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "m5", xdist, globalydist, colorFlat);
      DrawText2("M5", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (M15 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_M15);
      if (li_12 > 0) DrawObject(symbolname + "m15", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "m15", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "m15", xdist, globalydist, colorFlat);
      DrawText2("M15", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (M30 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_M30);
      if (li_12 > 0) DrawObject(symbolname + "m30", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "m30", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "m30", xdist, globalydist, colorFlat);
      DrawText2("M30", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (H1 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_H1);
      if (li_12 > 0) DrawObject(symbolname + "h1", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "h1", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "h1", xdist, globalydist, colorFlat);
      DrawText2("H1", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (H4 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_H4);
      if (li_12 > 0) DrawObject(symbolname + "h4", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "h4", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "h4", xdist, globalydist, colorFlat);
      DrawText2("H4", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (D1 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_D1);
      if (li_12 > 0) DrawObject(symbolname + "d1", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "d1", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "d1", xdist, globalydist, colorFlat);
      DrawText2("D1", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (W1 == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_W1);
      if (li_12 > 0) DrawObject(symbolname + "w1", xdist, globalydist, colorUp);
      if (li_12 < 0) DrawObject(symbolname + "w1", xdist, globalydist, colorDown);
      if (li_12 == 0) DrawObject(symbolname + "w1", xdist, globalydist, colorFlat);
      DrawText2("W1", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
   if (MN == TRUE) {
      li_12 = CalcTrend(correctedsymbol, PERIOD_MN1);
      if (li_12 > 0) DrawObject(symbolname + "mn", xdist, globalydist, colorUp);Alert("Buy",PERIOD_MN1,Symbol());
      if (li_12 < 0) DrawObject(symbolname + "mn", xdist, globalydist, colorDown);Alert("Sell",PERIOD_MN1,Symbol());
      if (li_12 == 0) DrawObject(symbolname + "mn", xdist, globalydist, colorFlat);
      DrawText2("MN", globalydist2);
      globalydist += vertical_space;
      globalydist2 += vertical_space;
   }
}

void DrawObject(string namestring, int a_x_8, int a_y_12, color a_color_16) {
   namestring = "HoF" + namestring;
   if (ObjectFind(namestring) == -1) ObjectCreate(namestring, OBJ_LABEL, WindowFind(indishortname), 0, 0);
   ObjectSet(namestring, OBJPROP_CORNER, 2);
   ObjectSet(namestring, OBJPROP_XDISTANCE, a_x_8);
   ObjectSet(namestring, OBJPROP_YDISTANCE, a_y_12);
   ObjectSet(namestring, OBJPROP_COLOR, a_color_16);
   ObjectSetText(namestring, "_", 44, "Arial", a_color_16);
}

void DrawText(string a_text_0, int xdist, int a_y_12) {
   globalname = "HoF" + a_text_0 + "text";
   if (ObjectFind(globalname) == -1) ObjectCreate(globalname, OBJ_LABEL, WindowFind(indishortname), 0, 0);
   ObjectSet(globalname, OBJPROP_CORNER, 2);
   ObjectSet(globalname, OBJPROP_XDISTANCE, xdist - 1);
   ObjectSet(globalname, OBJPROP_YDISTANCE, a_y_12);
   ObjectSet(globalname, OBJPROP_COLOR, colortext);
   ObjectSetText(globalname, a_text_0, 6, "Arial", colortext);
}

void DrawText2(string a_text_0, int a_y_8) {
   globalname = "HoF" + a_text_0 + "text";
   if (ObjectFind(globalname) == -1) ObjectCreate(globalname, OBJ_LABEL, WindowFind(indishortname), 0, 0);
   ObjectSet(globalname, OBJPROP_CORNER, 2);
   ObjectSet(globalname, OBJPROP_XDISTANCE, 5);
   ObjectSet(globalname, OBJPROP_YDISTANCE, a_y_8);
   ObjectSet(globalname, OBJPROP_COLOR, colortext);
   ObjectSetText(globalname, a_text_0, 7, "Arial", colortext);
}

void cleanup() {
   string l_name_4;
   for (int li_0 = ObjectsTotal() - 1; li_0 >= 0; li_0--) {
      l_name_4 = ObjectName(li_0);
      if (StringFind(l_name_4, "HoF") == 0) ObjectDelete(l_name_4);
   }
}

int CalcTrend(string a_symbol_0, int a_timeframe_8) {
   double ld_40;
   double l_ima_48;
   int li_ret_12 = 0;
   int localintindex = 0;
   int li_20 = 0;
   int li_24 = 0;
   int li_28 = 0;
   int li_32 = 0;
   int l_datetime_36 = iTime(a_symbol_0, a_timeframe_8, 0);
   if (l_datetime_36 == 0) {
      Print("No history for " + a_symbol_0 + " Period=" + a_timeframe_8);
      return (li_ret_12);
   }
   for (localintindex = li_20; localintindex <= localintindex + li_20; localintindex++) {
      ld_40 = iMA(a_symbol_0, a_timeframe_8, 30, 0, MODE_SMA, PRICE_CLOSE, localintindex);
      l_ima_48 = iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, localintindex);
      if (ld_40 > l_ima_48 && li_24 == 0) li_24 = 1;
      if (ld_40 < l_ima_48 && li_24 == 1) {
         li_24 = 0;
         break;
      }
      if (ld_40 < l_ima_48 && li_24 == 0) li_24 = -1;
      if (ld_40 > l_ima_48 && li_24 == -1) {
         li_24 = 0;
         break;
      }
   }
   for (localintindex = li_20; localintindex <= TrendTestBarPeriod2 + li_20; localintindex++) {
      ld_40 = iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, localintindex);
      l_ima_48 = iMA(a_symbol_0, a_timeframe_8, 100, 0, MODE_SMA, PRICE_CLOSE, localintindex);
      if (ld_40 > l_ima_48 && li_28 == 0) li_28 = 1;
      if (ld_40 < l_ima_48 && li_28 == 1) {
         li_28 = 0;
         break;
      }
      if (ld_40 < l_ima_48 && li_28 == 0) li_28 = -1;
      if (ld_40 > l_ima_48 && li_28 == -1) {
         li_28 = 0;
         break;
      }
   }
   for (localintindex = li_20; localintindex <= TrendTestBarPeriod + li_20; localintindex++) {
      ld_40 = iClose(a_symbol_0, a_timeframe_8, localintindex);
      l_ima_48 = iMA(a_symbol_0, a_timeframe_8, 100, 0, MODE_SMA, PRICE_CLOSE, localintindex);
      if (ld_40 > l_ima_48 && li_32 == 0) li_32 = 1;
      if (ld_40 < l_ima_48 && li_32 == 1) {
         li_32 = 0;
         break;
      }
      if (ld_40 < l_ima_48 && li_32 == 0) li_32 = -1;
      if (ld_40 > l_ima_48 && li_32 == -1) {
         li_32 = 0;
         break;
      }
   }
   if (li_24 == 1 && li_28 == 1 && li_32 == 1) {
      if (iClose(a_symbol_0, a_timeframe_8, li_20) > iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, li_20) && iMA(a_symbol_0, a_timeframe_8, 30, 0, MODE_SMA, PRICE_CLOSE, li_20) > iMA(a_symbol_0, a_timeframe_8, 30, 0, MODE_SMA, PRICE_CLOSE, iMAShiftValue2) &&
         iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, li_20) > iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, iMAShiftValue)) li_ret_12 = 1;
   }
   if (li_24 == -1 && li_28 == -1 && li_32 == -1) {
      if (iClose(a_symbol_0, a_timeframe_8, li_20) < iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, li_20) && iMA(a_symbol_0, a_timeframe_8, 30, 0, MODE_SMA, PRICE_CLOSE, li_20) < iMA(a_symbol_0, a_timeframe_8, 30, 0, MODE_SMA, PRICE_CLOSE, iMAShiftValue2) &&
         iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, li_20) < iMA(a_symbol_0, a_timeframe_8, 50, 0, MODE_SMA, PRICE_CLOSE, iMAShiftValue)) li_ret_12 = -1;
   }
   return (li_ret_12);
}
Forex Trading for the Savvy Beginner
 
 
  • Post #16
  • Quote
  • Last Post: Oct 26, 2011 11:31pm Oct 26, 2011 11:31pm
  •  bigfoot1945
  • | Joined Apr 2011 | Status: Member | 42 Posts
Quoting nubcake
Disliked
no probs. i'm confident i didn't break anything. it's a good chance for you to really sink your teeth into understanding how shit works and how to create simplistic solutions to problems.
Ignored
I have a shitty problem. I have an indicator that is awesome, but it repaints and the only way to correct it is to have it reset itself every thirty seconds, then everything is ok. OR.. If you know how to stop it from repainting that would be better, either way it will work for me. The indicator is attached.
Attached Files
File Type: mq4 #SUPER~1.MQ4   1 KB | 277 downloads
File Type: ex4 #SUPER~1.ex4   2 KB | 211 downloads
 
 
  • Platform Tech
  • /
  • Indicator Resetting
  • 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 / ©2022