how to move move objects like in Fib

[Deleted]  

Hi guys,

I got tired of having Fibs on MT4 with levels that are not able to be modified individually...

so I coded my own Fib which can have separate characteristics for each level... like different colors and thickness

here is a pic of the completed indy :


the question i have now is : How do i move the objects when I click on the diagonal red line and move it to a new candle?

I have coded this indy to remove the lines and plot new ones when I delete and replace the diagonal red line...BUT i would

prefer if to move the levels like when you select the standard fib and move it to a new candle...the fib levels just follow

any ideas how to do that?

I imagine that we could do this by using a record of the last 2 values of the fib line(red diagonal line) like this : (i cant figure out how to code it but I can explain what i think must be done)

so we keep a record like :

CurrFibLevel = (the indy places the value for the fib level where it is now)

LastFiblevel = (the indy places the value for the fib level on the last tick of price action)


if(CurrFiblevel!=lastFiblevel)

{

ObjectMove (object details here)

}


This is what I imagine to be right but cant figure out how to get the indy to record the last and current fib level values

would I use a ''for loop'' for this? im just at a loss how to code this small piece :(

any help on this would be much appreciated

thanx :)

[Deleted]  

You can't create an object that would offer the exact similar functionality. However you can create multiple lines, and on each new tick, you check the lead line (being that trend line that spans between 0 and 100% fibo point) for its point1 and point2 x and y properties and then adjust all other lines accordingly to that. Which is a bloody awesome idea.

Thanks.

On another note: is there a way to "activate" an object using mql4 code itself? By "activate" I mean the double click thingy that enables you to modify object properties. Having multiple lines on screen makes it sometimes impossible to double click the correct line. Kinda annoying as I usually want to move only very specific few of those lines.

William Roeder
25849
William Roeder  
mqlearner:
I got tired of having Fibs on MT4 with levels that are not able to be modified individually...

Control-B (right click -> object list) select the fib and edit. Set or add levels you want. Done. Next fib will use those as the default.

[Deleted]  
forexCoder:

You can't create an object that would offer the exact similar functionality. However you can create multiple lines, and on each new tick, you check the lead line (being that trend line that spans between 0 and 100% fibo point) for its point1 and point2 x and y properties and then adjust all other lines accordingly to that. Which is a bloody awesome idea.

Thanks.

On another note: is there a way to "activate" an object using mql4 code itself? By "activate" I mean the double click thingy that enables you to modify object properties. Having multiple lines on screen makes it sometimes impossible to double click the correct line. Kinda annoying as I usually want to move only very specific few of those lines.



thank you, i have come to the same conclusion about checking the line that spans the 0 -100% and that is exactly what I am trying to do...

I just with my limited knowledge of mql4 cant seem to get the right code to do it... do you maybe have a suggestion how I can do that?


thanx for the answer and Im glad you like the idea :)

[Deleted]  
WHRoeder:

Control-B (right click -> object list) select the fib and edit. Set or add levels you want. Done. Next fib will use those as the default.

Yes but you cannot customize levels independently.
[Deleted]  
forexCoder:
Yes but you cannot customize levels independently.


do you maybe know how to code the checks for that 0-100 line? how would I get it to check that?


because as I imagine it, I would need to be able to save the last value of the lead line and then compare that to the current value of the lead line and then if they differ

then the indy must maybe use ObjectMove to redraw the levels in the new position...

but how do i get it to do the check and compare the values of the last and current lead line levels?

[Deleted]  

Yes, in the code, where you draw the lines, first check if that object already exists on chart

if(ObjectFind(blabla)){

/* in here check whether the coordinates of main line have changed using

ObjectGet(name, OBJPROP_ blabla - check for TIME1, TIME2, PRICE1, PRICE2;

then redraw all other lines using these new coordinates.*/

}

[Deleted]  
forexCoder:

Yes, in the code, where you draw the lines, first check if that object already exists on chart

if(ObjectFind(blabla)){

/* in here check whether the coordinates of main line have changed using

ObjectGet(name, OBJPROP_ blabla - check for TIME1, TIME2, PRICE1, PRICE2;

then redraw all other lines using these new coordinates.*/

}


that looks great, thank you i will try it now, your help is very much appreciated

:)

[Deleted]  
forexCoder:

Yes, in the code, where you draw the lines, first check if that object already exists on chart

if(ObjectFind(blabla)){

/* in here check whether the coordinates of main line have changed using

ObjectGet(name, OBJPROP_ blabla - check for TIME1, TIME2, PRICE1, PRICE2;

then redraw all other lines using these new coordinates.*/

}

to be honest i stared applying this logic to the Indy and hit a brick wall... the problem i have is that i can not figure out how to record the last "ticks" value for the lead line...

If i cant figure that out then I cant compare it and see if it is different to what the lead line value is now... so how do i store the lead line value in an array for example?


im useless with arrays as i am yet to understand how to use them in code but i do know they are containers for data so can be used to record the values of the lead line...


but how do i code it to keep a record of those values? :(


sorry for my limited knowledge on this subject

[Deleted]  
You can create a global var (outside start function, not global mt4 variable) where you set such value and then compare it to all further values.
[Deleted]  
forexCoder:
You can create a global var (outside start function, not global mt4 variable) where you set such value and then compare it to all further values.


SUCCESS!!!!!! :) :) :) .... thank you so Much forexCoder! your input got me thinking and i managed to find a way to implement your 1st suggestion

i did this :

 if(ObjectFind("topline")==win_idx)
       { 
       if(tophigh!=ObjectGet("topline",OBJPROP_PRICE1))
          {
           ObjectDelete("topline");
          }
       }

and then after that simply drew new lines if the line had been deleted... it works seamlessly... :)

thank you very much for your input... this tool is getting MAJOR use from Monday in my trading

how nice to FINALLY have Fib levels of different colors and thicknesses in MT4!!!! :)

thanks again!