One click to draw fibonacci

 
Is it possible that i click mouse click on chart and it draws OBJ_FIBO on chart near the click area.
 
Arpit T:
Is it possible that i click mouse click on chart and it draws OBJ_FIBO on chart near the click area.

Interesting . like , it finds the nearest pivots and drops it there ?

 
Arpit T:
Is it possible that i click mouse click on chart and it draws OBJ_FIBO on chart near the click area.
Yes, you have to program it ...
 
Arpit T: Is it possible that i click mouse click on chart and it draws OBJ_FIBO on chart near the click area.

Makes no sense. A Fib object is from two prices, not one. Click on one price and drag to the other.

 
Lorentzos Roussos #:

Interesting . like , it finds the nearest pivots and drops it there ?

yes bro, thanks for your interest. by the way some code is here but it draws fibo fan

https://c.mql5.com/2/43/Peek_2021-10-22_09-24.gif

want to draw OBJ_FIBO like this, any code will help me learn

Manual charting and trading toolkit (Part III). Optimization and new tools
Manual charting and trading toolkit (Part III). Optimization and new tools
  • www.mql5.com
In this article, we will further develop the idea of drawing graphical objects on charts using keyboard shortcuts. New tools have been added to the library, including a straight line plotted through arbitrary vertices, and a set of rectangles that enable the evaluation of the reversal time and level. Also, the article shows the possibility to optimize code for improved performance. The implementation example has been rewritten, allowing the use of Shortcuts alongside other trading programs. Required code knowledge level: slightly higher than a beginner.
 
William Roeder #:

Makes no sense. A Fib object is from two prices, not one. Click on one price and drag to the other.

yes logically right you said.

 
Arpit T #:

yes bro, thanks for your interest. by the way some code is here but it draws fibo fan

https://c.mql5.com/2/43/Peek_2021-10-22_09-24.gif

want to draw OBJ_FIBO like this, any code will help me learn

It depends on which pivots you want to use .

Will it utilize the first pivots it finds from right to left and plot a fibo on those 2

Will it utilize the pivots it finds within a range of bars and plot a fibo on those 2

 

auto fibonacci forex

here is my attempt , that was fun  😊 ☕️


(although there are some issues :

the include does not adjust properly for finding a range from a bar in the past if i recall correctly

so if you drop it in the past with max bars it will probably fail)

#property copyright "Read More Here"
#property link      "https://www.mql5.com/en/forum/440310"
#property version   "1.00"
#include <PlugAndPlay\fractals\findHighLowWithLowestHighestSearch.mqh>
/*
enum search_mode{
search_recent=0,//recent
search_with_max_bars=1//with max bars
};
*/
input int BarsRight=5;//bars to the right to be "wider" than
input int BarsLeft=5;//bars to the left to be "wider" than
input search_mode searchMode=search_recent;//Search mode from the drop point
input int searchMaxBars=250;//Max bars (or -1 for unlimited recent mode)
/*
okay , the include is self commented out , ignore it for now it finds pivots 
we want user to click somewhere and deploy from there 
Basics:
*/
string system_tag="DROP_FIBO_";
bool fibo_down=false;
string psparam="0";//remember last click
int OnInit()
  {
  fibo_down=false;
  //delete all objects 
    ObjectsDeleteAll(ChartID(),system_tag);
  //prompt the user 
    Comment("Left Click to drop a fibonacci");
  ChartSetInteger(ChartID(),CHART_CONTEXT_MENU,false);
  ChartSetInteger(ChartID(),CHART_EVENT_MOUSE_MOVE,true);
  return(INIT_SUCCEEDED);
  }
  
void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
  {
  //
  if(id==CHARTEVENT_MOUSE_MOVE){
    if(!fibo_down&&sparam=="1"&&psparam=="0"){   
    //get coordinates  
      int x=(int)lparam;
      int y=(int)dparam;
    //turn to price time 
      datetime drop_time=0;
      double drop_price=0.0;
      int sub=-1;
      ChartXYToTimePrice(ChartID(),x,y,sub,drop_time,drop_price);
    //if dropped on subwindow 0 : cancel follow up drops
      if(sub==0){
    //find the bar 
      int drop_bar=iBarShift(_Symbol,_Period,drop_time,false);
      //from that bar backwards we look for the first low and the first high 
        int lowBar=findHighLow(drop_bar,BarsLeft,BarsRight,searchMode,-1,searchMaxBars);
        int highBar=findHighLow(drop_bar,BarsLeft,BarsRight,searchMode,1,searchMaxBars);
        //now if these are both valid and if they are not at the same spot
          if(lowBar!=-1&&highBar!=-1&&lowBar!=highBar){
          fibo_down=true;
            datetime dropTime=iTime(_Symbol,_Period,drop_bar);
          //now turn them to point from and point to
            int pFrom=(int)MathMax(lowBar,highBar);
            int pTo=(int)MathMin(lowBar,highBar);
            datetime pFromTime=iTime(_Symbol,_Period,pFrom);
            datetime pToTime=iTime(_Symbol,_Period,pTo);
            double pFromPrice=iHigh(_Symbol,_Period,pFrom);
            double pToPrice=iHigh(_Symbol,_Period,pTo);
            if(pFrom==lowBar){pFromPrice=iLow(_Symbol,_Period,pFrom);}
            if(pTo==lowBar){pToPrice=iLow(_Symbol,_Period,pTo);}
            //debug
              Comment("DropPoint >>>>\n"+TimeToString(dropTime,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+"\nFrom >>>>>>> \n"+TimeToString(pFromTime,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" "+DoubleToString(pFromPrice,_Digits)+"\nTo >>>>>> \n"+TimeToString(pToTime,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" "+DoubleToString(pToPrice,_Digits)+"\nRight click to delete");
            //draw the fibo 
              string name=system_tag+"_FIB";
              ObjectCreate(ChartID(),name,OBJ_FIBO,0,pFromTime,pFromPrice,pToTime,pToPrice);
          }
      }
    }
    else if(fibo_down&&sparam=="2"&&psparam=="0"){
    Comment("Left Click to drop a fibonacci");
    fibo_down=false;
    ObjectsDeleteAll(ChartID(),system_tag);
    }
    psparam=sparam;
    }
  }

void OnDeinit(const int reason)
  {
//---
  ObjectsDeleteAll(ChartID(),system_tag); 
  ChartSetInteger(ChartID(),CHART_CONTEXT_MENU,true);
  }

void OnTick()
  {
//---
   
  }
 
Lorentzos Roussos #:

It depends on which pivots you want to use .

Will it utilize the first pivots it finds from right to left and plot a fibo on those 2

Will it utilize the pivots it finds within a range of bars and plot a fibo on those 2

wow, appreciate the way you commented out everything with codes, which is really helpful for learning code, good and thanks for your time and effort, the code is super helpful to start my own custom project.

 
Arpit T #:

wow, appreciate the way you commented out everything with codes, which is really helpful for learning code, good and thanks for your time and effort, the code is super helpful to start my own custom project.

Awesome , little note , the left bars and right bars are set too high (5,5) (leftover from another project) so if you find yourself asking "why did it pick this pivot and not this one"

lower these values (min is 1,1)

Enjoy 


Reason: