This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

problem with trend line to alligator jaw


Back to topics list
avatar
66
ivo 2009.02.16 12:19 

Hello

I'm trying to plot a trendline (in orange) which should finish to last available alligator jaw's value.

Because 0 (zero) is the last bar I use it, but jaw line, showing on chart, has another prise.

On picture is visible that Aligator jaw under bar[0] has different prise that the jsw itself

Next (in green) is drawn desired result. Hope it is clear. Source is quoted below.

Please advise how to plot it to last available point of the jaw.

      
desired result


trend to gattor jaw

//+------------------------------------------------------------------+
//|                                                         test.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#include <stdlib.mqh>
#property link      ""

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
{
  string lineName = "test_line";
  int    err;
  bool   res;
  double jaw = iAlligator(NULL, 0, 13,8,8,5,5,3,MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 0);
  double teeth = iAlligator(NULL, 0, 13,8,8,5,5,3,MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 0);


  if(ObjectFind(lineName)  == -1)
  {
    res = ObjectCreate(lineName, OBJ_TREND, 0, Time[0], jaw, Time[5], Open[5]);
    if(res)
    {
      ObjectSet(lineName, OBJPROP_COLOR, Orange);
      ObjectSet(lineName, OBJPROP_STYLE, STYLE_SOLID);
      ObjectSet(lineName, OBJPROP_WIDTH, 2);
      ObjectSet(lineName, OBJPROP_BACK, true);
      ObjectSet(lineName, OBJPROP_RAY, false);
    }
    else
    {
      err = GetLastError();
      Print("Error [#", err, "] creating object ", lineName, " -> ", ErrorDescription(err));
    }
  }
  else
  {
    res = ObjectMove(lineName, 0, Time[0], jaw) || ObjectMove(lineName, 0, Time[5], Open[5]);
    if(!res)
    {
      err = GetLastError();
      Print("Error [#", err, "] moving object ", lineName, " -> ", ErrorDescription(err));
    }
  }
  
}
//+------------------------------------------------------------------+


Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets