Fibonacci Tools Manual Trading

 

Hello,

If my strategy requires frequently using the Fibonacci tools with different levels each time, what is the best way to make the process quicker? I'm thinking of writing a script that takes the price/time extremes as input, then computes the relevant levels and draws lines on the chart. Does anyone know a better solution by any chance?

 
Create a fibo object
void Fibo(  string name, datetime T0, double P0, datetime T1, double P1,
            color clr){
    if (!Show.Objects)  return;                 // #define WINDOW_MAIN 0
    if      (ObjectMove( name, 0, T0, P0 ))     ObjectMove(name, 1, T1, P1);
    else if(!ObjectCreate( name, OBJ_FIBO, WINDOW_MAIN, T0, P0, T1, P1 ))
        Alert("ObjectCreate(",name,",FIBO) failed: ", GetLastError() );
    else{
      ObjectSet(name, OBJPROP_RAY,           false );
      ObjectSet(name, OBJPROP_BACK,          true);
      ObjectSet(name, OBJPROP_STYLE,         STYLE_SOLID);
        ObjectSet(name, OBJPROP_FIBOLEVELS,  6);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+0,   0.000);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+1,   0.250);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+2,   0.382);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+3,   0.618);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+4,   0.750);
        ObjectSet(name, OBJPROP_FIRSTLEVEL+5,   1.000);
        ObjectSetFiboDescription (name, 0, "0.0");
        ObjectSetFiboDescription (name, 1, "25.0");
        ObjectSetFiboDescription (name, 2, "38.2");
        ObjectSetFiboDescription (name, 3, "61.8");
        ObjectSetFiboDescription (name, 4, "75.0");
        ObjectSetFiboDescription (name, 5, "100.0");
      //   TF2+" High -  %$" displays Hourly High - 1.5191
   }
    if (!ObjectSet(name, OBJPROP_COLOR, clr )) // Allow color change
        Alert("ObjectSet(", name, ",Color) [5] failed: ", GetLastError());
}
 

using OBJ_FIBO* objects may make the job easier, maybe faster.

( https://docs.mql4.com/constants/objects )

 
BenLinus:

Hello,

If my strategy requires frequently using the Fibonacci tools with different levels each time, what is the best way to make the process quicker? I'm thinking of writing a script that takes the price/time extremes as input, then computes the relevant levels and draws lines on the chart. Does anyone know a better solution by any chance?

Create the Fib with the levels you require, save the template, add any Fib types you require and save the template, you now have a template with all the different Fibs you require. To make a new Fib of a specific type find that type on your chart and look at it's properties, this sets those properties on the standard Fib tool, so to draw a Fib of this type go to the chart you want to draw it on and use the standard Fib tool to draw a Fib, this new Fib will have the same settings as the only you last looked at the properties of. Done.

Alternatively, create a script for each type.

 
WHRoeder:
Create a fibo object

Do I have to create/move the object in a while(1) loop inside init(). Or, is it possible to implement objects just like the built-ins that you click their icons.
 
RaptorUK:

Create the Fib with the levels you require, save the template, add any Fib types you require and save the template, you now have a template with all the different Fibs you require. To make a new Fib of a specific type find that type on your chart and look at it's properties, this sets those properties on the standard Fib tool, so to draw a Fib of this type go to the chart you want to draw it on and use the standard Fib tool to draw a Fib, this new Fib will have the same settings as the only you last looked at the properties of. Done.

Alternatively, create a script for each type.


I don't think that works. When I switch templates, the fib objects are removed. I need all of them at once.
 
BenLinus:

I don't think that works. When I switch templates, the fib objects are removed. I need all of them at once.

It does work, you use a template to save your selection of Fibs.

When you want to draw a specific one add the template to a temporary chart, select the Fib, view it's properties, then draw a new Fib using the standard Fib tool on the chart you want to draw it on . . . don't add the template to the chart where you want to place the Fib.

 
RaptorUK:

It does work, you use a template to save your selection of Fibs.

When you want to draw a specific one add the template to a temporary chart, select the Fib, view it's properties, then draw a new Fib using the standard Fib tool on the chart you want to draw it on . . . don't add the template to the chart where you want to place the Fib.


Yes. It works. Wohoo...

I guess I would have to find an other excuse to do some coding. I learned mql4 mostly to make my manual trading easier. But, coding turned out to be more fun than I thought.


Thank you RaptorUK.

 
BenLinus: Do I have to create/move the object in a while(1) loop inside init(). Or, is it possible to implement objects just like the built-ins that you click their icons.
Init() MUST return within 2.5 seconds. You can NOT loop in init(). You can move the object in start(). it looks just like the built-in because it is.
 
WHRoeder:
Init() MUST return within 2.5 seconds. You can NOT loop in init(). You can move the object in start(). it looks just like the built-in because it is.


Good to know.

Anyways, an infinite loop is not necessary since the the fib object will take care of moving and updating.


Probably, the scripting approach is more convenient. I will write scripts to summon all the fib tools I want. Using templates involves more clicking and I might forget not to apply the template to a chart that has an EA running, or has been customized.

Reason: