Download MetaTrader 5

A script that draws easily draggable Gann angles (for manual trading)

To add comments, please log in or register
Have you developed a profitable strategy? Launch your trading signal and make profit from it!
kypa
72
kypa 2016.05.31 14:36 

This script prompts for 1x1 angle value then puts two Fibonacci fans (bull and bear) with custom levels 50 pixels from the top, bottom and left borders of chart. The fans are ready selected for manual dragging over the chart.

#property copyright "Copyright 2016, МегаКурец Software Corp."
#property link "https://www.mql5.com/en/users/kypa"
#property version "2.01"

#property script_show_inputs

input double Ъглец = 1;

color МечовЦвят = clrForestGreen;
color ГоведовЦвят = clrForestGreen;
ENUM_LINE_STYLE МечовСтил = STYLE_SOLID;
ENUM_LINE_STYLE ГоведовСтил = STYLE_SOLID;
int МечоваШирина = 1;
int ГоведоваШирина = 1;

int ChartHeightInPixelsGet(const long chart_ID=0,const int sub_window=0)
  {
   long result=-1;
   ResetLastError();
   if(!ChartGetInteger(chart_ID,CHART_HEIGHT_IN_PIXELS,sub_window,result))
     {
      Print(__FUNCTION__+", Error Code = ",GetLastError());
     }
  return((int)result);
  } 

int bullX = 50;
int bullY = 50;
int bearX = 55;
int bearY = ChartHeightInPixelsGet(0,0) - 50;
datetime bulltime = 0;
datetime beartime =0;
double bullprice  =0;
double bearprice  =0;
int window =0;

void OnStart()
{
if(ChartXYToTimePrice(0,bullX,bullY,window, bulltime,bullprice))
{
if(ChartXYToTimePrice(0,bearX,bearY,window,beartime,bearprice))
{ResetLastError();
   if(!ObjectCreate(0,"Мечовата Ганювица",OBJ_FIBOFAN,0,bulltime,bullprice,bulltime+3600,bullprice-Ъглец))
     {
      Print(__FUNCTION__,
            ": failed to create \"Мечовата Ганювица\"! Error code = ",GetLastError());  
            }  
            ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_DIRECTION, true);        
}}        

{ResetLastError();  
   if(!ObjectCreate(0,"Говедовата Ганювица",OBJ_FIBOFAN,0,bulltime,bearprice,bulltime+3600,bearprice+Ъглец))
     {
      Print(__FUNCTION__,
            ": failed to create \"Говедовата Ганювица\"! Error code = ",GetLastError());                       
}}

ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_SELECTABLE, true);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_SELECTED, true);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_COLOR, clrBlue);

ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELS,7);

ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,0,-7);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,1,-3);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,2,-1);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,3,0);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,4,0.5);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,5,0.75);
ObjectSetDouble(0,"Мечовата Ганювица",OBJPROP_LEVELVALUE,6,0.875);

ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,0,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,1,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,2,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,3,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,4,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,5,МечовЦвят);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELCOLOR,6,МечовЦвят);

ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,0,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,1,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,2,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,3,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,4,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,5,МечовСтил);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELSTYLE,6,МечовСтил);

ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,0,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,1,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,2,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,3,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,4,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,5,МечоваШирина);
ObjectSetInteger(0,"Мечовата Ганювица",OBJPROP_LEVELWIDTH,6,МечоваШирина);

ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,0,"8x1");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,1,"4x1");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,2,"2x1");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,3,"1x1");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,4,"1x2");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,5,"1x4");
ObjectSetString(0,"Мечовата Ганювица",OBJPROP_LEVELTEXT,6,"1x8");
 
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_SELECTABLE, true);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_SELECTED, true);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_COLOR, clrBlue);

ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELS,7);

ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,0,-7);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,1,-3);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,2,-1);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,3,0);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,4,0.5);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,5,0.75);
ObjectSetDouble(0,"Говедовата Ганювица",OBJPROP_LEVELVALUE,6,0.875);

ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,0,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,1,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,2,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,3,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,4,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,5,ГоведовЦвят);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELCOLOR,6,ГоведовЦвят);

ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,0,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,1,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,2,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,3,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,4,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,5,ГоведовСтил);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELSTYLE,6,ГоведовСтил);

ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,0,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,1,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,2,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,3,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,4,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,5,ГоведоваШирина);
ObjectSetInteger(0,"Говедовата Ганювица",OBJPROP_LEVELWIDTH,6,ГоведоваШирина);

ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,0,"8x1");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,1,"4x1");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,2,"2x1");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,3,"1x1");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,4,"1x2");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,5,"1x4");
ObjectSetString(0,"Говедовата Ганювица",OBJPROP_LEVELTEXT,6,"1x8");

}
If you have no idea what Gann angles are about but want to try the script put some of these values - EURUSD 0.0014, EURJPY 0.14, GBPUSD 0.0020, most other crosses 0.0010, Gold 2.5, Oil 0.25 - and drag the fans to tops and bottoms where they match best and use the angles as trendlines or just measure the slope of the trendlines you draw by yourself.
kypa
72
kypa 2016.05.31 14:42  

I wanted to use this:

//+------------------------------------------------------------------+
//| Set number of levels and their parameters                        |
//+------------------------------------------------------------------+
bool FiboFanLevelsSet(int             levels,         // number of level lines
                      double          &values[],      // values of level lines
                      color           &colors[],      // color of level lines
                      ENUM_LINE_STYLE &styles[],      // style of level lines
                      int             &widths[],      // width of level lines
                      const long      chart_ID=0,     // chart's ID
                      const string    name="FiboFan") // fan name
  {
//--- check array sizes
   if(levels!=ArraySize(colors) || levels!=ArraySize(styles) ||
      levels!=ArraySize(widths) || levels!=ArraySize(widths))
     {
      Print(__FUNCTION__,": array length does not correspond to the number of levels, error!");
      return(false);
     }
//--- set the number of levels
   ObjectSetInteger(chart_ID,name,OBJPROP_LEVELS,levels);
//--- set the properties of levels in the loop
   for(int i=0;i<levels;i++)
     {
      //--- level value
      ObjectSetDouble(chart_ID,name,OBJPROP_LEVELVALUE,i,values[i]);
      //--- level color
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELCOLOR,i,colors[i]);
      //--- level style
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELSTYLE,i,styles[i]);
      //--- level width
      ObjectSetInteger(chart_ID,name,OBJPROP_LEVELWIDTH,i,widths[i]);
      //--- level description
      ObjectSetString(chart_ID,name,OBJPROP_LEVELTEXT,i,DoubleToString(100*values[i],1));
     }
//--- successful execution
   return(true);
  }


function from the codebase to set up the custom levels instead of last 90-100 lines of neanderthal's intelect level code, but couldn't figure out how to properly write it down.

To add comments, please log in or register