Can't enable/disable rays on trendlines

Back to topics list To post a new topic, please log in or register
avatar
147
nondisclosure 2016.01.11 05:47
 

So, this code will draw the trendlines using the coordinates correctly.  It doesn't matter what I set the RayLeft and RayRight values to, Left is always on (true) and Right is always off (false).  And what I want is the reverse.

 Anyone got any ideas? 

//+------------------------------------------------------------------+
//|                                                     Binaries.mq4 |
//|                                 Copyright 2016, Nondisclosure007 |
//|                                               http://no.link.yet |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Nondisclosure007"
#property link      "http://no.link.yet"
#property version   "1.00"
#property strict

#include <ChartObjects\ChartObjectsLines.mqh>

input color Ncolor=clrLime;         //North trend line 
input color Scolor=clrYellow;       //South trend line

bool IsInit=false;   //Initilization on first tick
datetime LastTime;   //New candle

CChartObjectTrend NorthSideTrend;
CChartObjectTrend SouthSideTrend;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   IsInit=true;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   NorthSideTrend.Delete();
   SouthSideTrend.Delete();
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   if(IsInit)
     {//First Tick
      LastTime=Time[0];
      IsInit=false;
      DrawLines();
     }
   else if(LastTime!=Time[0])
     {//New Bar
      LastTime=Time[0];
      DrawLines();
     }
  }
//+------------------------------------------------------------------+

void DeleteLines()
{

}

void DrawLines()
{
   bool FoundAll=false, FoundUpOne=false, FoundUpTwo=false, FoundDownOne=false, FoundDownTwo=false, FoundFirst=false;
   int i=0;
   double UpOne=0.0, UpTwo=0.0, DownOne=0.0, DownTwo=0.0, temp=0.0;
   datetime dtUpOne=Time[i], dtUpTwo=Time[i], dtDownOne=Time[i], dtDownTwo=Time[i];
   while(!FoundAll)
     {
      temp=iCustom(NULL,0,"ZigZag",12,5,3,0,i);
      if(!FoundFirst && (temp==High[i] || temp==Low[i]))
        {
         FoundFirst=true;
        }
      else if(!FoundUpOne && temp==High[i])
             {
              FoundUpOne=true;
              UpOne=High[i];
              dtUpOne=Time[i];
             }
      else if(!FoundUpTwo && temp==High[i])
             {
              FoundUpTwo=true;
              UpTwo=High[i];
              dtUpTwo=Time[i];
             }
      else if(!FoundDownOne && temp==Low[i])
             {
              FoundDownOne=true;
              DownOne=Low[i];
              dtDownOne=Time[i];
             }
      else if(!FoundDownTwo && temp==Low[i])
             {
              FoundDownTwo=true;
              DownTwo=Low[i];
              dtDownTwo=Time[i];
             }
      i++;
      if(FoundDownOne && FoundDownTwo && FoundUpOne && FoundUpTwo)
        {
         FoundAll=true;
        }
     }
   NorthSideTrend.Create(0,"NorthSideTrend",0,dtUpOne,UpOne,dtUpTwo,UpTwo);         
   NorthSideTrend.Color(Ncolor); 
   NorthSideTrend.RayLeft(false);
   NorthSideTrend.RayRight(true);
   NorthSideTrend.Hidden(false);
   SouthSideTrend.Create(0,"SouthSideTrend",0,dtDownOne,DownOne,dtDownTwo,DownTwo); 
   SouthSideTrend.Color(Scolor); 
   SouthSideTrend.RayLeft(false);
   SouthSideTrend.RayRight(true);
   SouthSideTrend.Hidden(false);
}

 Add to that, just an FYI, there is no code in the class files to move the trendlines.  Not that I could find.

avatar
147
nondisclosure 2016.01.11 06:10 #
 
nondisclosure:

So, this code will draw the trendlines using the coordinates correctly.  It doesn't matter what I set the RayLeft and RayRight values to, Left is always on (true) and Right is always off (false).  And what I want is the reverse.

 Anyone got any ideas? 

 Add to that, just an FYI, there is no code in the class files to move the trendlines.  Not that I could find.

Fixed it.  Switched the Time and Price coordinates around.
Back to topics list  

To add comments, please log in or register