Wednesday, 26 December 2012

iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1); //uptrend value


Code:
 
iCustom(NULL,0,"SuperTrend",10,3,0,1) //buffer 0 ie uptrend
 
iCustom(NULL,0,"SuperTrend",10,3,1,1) //buffer 1 ie downtrend



Code:
int start()
  {
//----
   
      ExtMapBuffer1[1] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1);  //uptrend value
 
      ExtMapBuffer1[2] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,1,1);  //downtrend value
      
      if(Bid <= ExtMapBuffer1[1]) 
      {
         TrendDirection = "Up!";
      }
      if(Bid >= ExtMapBuffer1[2]) 
      {
         TrendDirection = "Down!";
      }
   
      Comment("UpTrend: ", ExtMapBuffer1[1], "n", "DownTrend: ", ExtMapBuffer2[2], "n", "Trade Direction: ", TrendDirection);
   
//----
   return(0);
  }
We are our own best indicator.

I have put the following for a call to the indicator, would this be correct to get the current price? It only works on the output of the bar I am asking (which is fine) I believe and does this seem right?

Code:
//+------------------------------------------------------------------+
//|                                                SuperTrend V1.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
double ExtMapBuffer1[];
double ExtMapBuffer2[];

int      Periods = 3;
double   Multiplier = 1.25;
int      TimeFrame = 240;
string   TrendDirection = "Long";

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
  
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
      ExtMapBuffer1[1] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1);  //downtrend value
 
      ExtMapBuffer1[2] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,1,1);  //uptrend value
      
      if(ExtMapBuffer1[1] < ExtMapBuffer1[2])
      {
         TrendDirection = "Down";
      }
   
      Comment("UpTrend: ", ExtMapBuffer1[1], "n", "DownTrend: ", ExtMapBuffer2[2], "n", "Trade Direction: ", TrendDirection);
   
//----
   return(0);
  }
I added the Timeframe option in the indicator so I can switch through the timeframes...


I think I got it! 

I changed to the following and it is outputting fine!

Code:
//+------------------------------------------------------------------+
//|                                                SuperTrend V1.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
double ExtMapBuffer1[];
double ExtMapBuffer2[];

int      Periods = 3;
double   Multiplier = 1.25;
int      TimeFrame = 240;
string   TrendDirection = "Long";


double   UpTrend,DownTrend;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
  
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   
      //ExtMapBuffer1[1] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1);  //uptrend value
 
      //ExtMapBuffer1[2] = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,1,1);  //downtrend value
      UpTrend = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,0,1);
      DownTrend = iCustom(NULL, 0, "SuperTrend",Periods,Multiplier,TimeFrame,1,1);
      
      /*if(Bid <= ExtMapBuffer1[1]) 
      {
         TrendDirection = "Up!";
      }
      if(Bid >= ExtMapBuffer1[2]) 
      {
         TrendDirection = "Down!";
      }
   
      //Comment("UpTrend: ", ExtMapBuffer1[1], "n", "DownTrend: ", ExtMapBuffer2[2], "n", "Trade Direction: ", TrendDirection);
   */
      Comment("UpTrend: ", UpTrend, "n", "DownTrend: ", DownTrend);
//----
   return(0);
  }
We are our own best indicator.









1 comment: