how do i get my ea to trade from the change of the color on the histogram - page 2

To add comments, please log in or register
Viffer
614
Viffer  
hustlerscreed:

ok found the function i need to use

below is the function

heres the deal i need to

buy when buffer 0 is greater than -0.00000 && buffer 1 is absolute 0.00000

sell when buffer 0 is absolute 0.00000 && buffer 1 is greater then -0.00000

bool SetIndexBuffer( int index, double array[])
Binds the array variable declared at a global level to the custom indicator pre-defined buffer. The amount of buffers needed to calculate the indicator is set with the IndicatorBuffers() function and cannot exceed 8. If it succeeds, TRUE will be returned, otherwise, it will be FALSE. To get the extended information about the error, one has to call the GetLastError() function.
Parameters:

index - Line index. Must lie between 0 and 7.
array[] - Array that stores calculated indicator values.
Sample:

Not quite... imho.... that is the function in the indicator that sets the line colour.... but you can see the buffer ID (0) for this line.... you will need to use icustom in your ea to extract the value held in the indicator buffer. You are correct in saying you will need 2 variables... one for each buffer colour.... when 1 is >0 the other will be ==0 and you can determine your actions from that...

hth

V
derek
98
derek  

how do i use icustom to extract the values on the two indicator buffers..

can someone help

much thanks

hustlerscreed

Viffer
614
Viffer  
hustlerscreed:

how do i use icustom to extract the values on the two indicator buffers..

can someone help

much thanks

hustlerscreed

Read the link I gave you and have a look at other posts... its a regular question...in fact one is ongoing at the moment...https://www.mql5.com/en/forum/128838

V

whroeder1
17945
whroeder1  
  1. You are not a programmer? I am not a teacher.

    No slaves here. Either learn to program or pay someone.


derek
98
derek  

how do i just pull out buffer 0 and buffer 1 values and use them for buy and sell

much thanks

hustlerscreed

also whroeder i read the topic and worked on it over 4 hours it did not works

all the topic explains is how to order verables in icustom but not how to use specific verables to use and trade signals

thanks

creed

/+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double macd1=iCustom(Symbol(),0,"macd1",120,80,0,0,0,1);
//double macd2=iCustom(Symbol(),0,"macd3",120,80,1,0,1);
double macd3=iCustom(Symbol(),0,"macd1",120,80,1,0,0,2);
//double macd4=iCustom(Symbol(),0,"macd3",120,80,1,1,2);
static int trade_bar;
if(macd1>= -0.00000 && macd3==0 && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,NULL,0,0,Green);trade_bar=Bars;}
if(macd3>= -0.00000 && macd1==0 && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,NULL,0,0,Red);trade_bar=Bars;}
//----
derek
98
derek  

ok heres the indicator Parameter order, as you see is has there extern int and 4 buffers.

how do i order iCutoms() arrange it so on buffers 0 and 1 values or read

or set it up to where it buy and sell off of buffer 0 and 1

/---- indicator parameters
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//---- indicator buffers
double     MacdBuffer[],   MacdBufferUp[],   MacdBufferDown[];
double     SignalBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
  IndicatorBuffers(4);
   
   SetIndexBuffer (0,MacdBufferUp);
   SetIndexStyle  (0,DRAW_HISTOGRAM);
   SetIndexBuffer (1,MacdBufferDown); 
   SetIndexStyle  (1,DRAW_HISTOGRAM);
   SetIndexBuffer (2,SignalBuffer);
   SetIndexStyle  (2,DRAW_LINE);
   SetIndexDrawBegin(2,SignalSMA);
   SetIndexBuffer (3,MacdBuffer);
   SetIndexStyle  (3,DRAW_NONE);   
   
   SetIndexLabel  (0,"Buffer 0");
   SetIndexLabel  (1,"Buffer 1");
   SetIndexLabel  (2,"Signal");
   IndicatorDigits(Digits+3);
   IndicatorShortName("MACD_color("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   return(0);
  }
Viffer
614
Viffer  
         double up=iCustom(NULL,0,"indicator name here",12,26,9,0,0);
         double down=iCustom(NULL,0,"indicator name here",12,26,9,1,0);
V
derek
98
derek  

ok heres what i got.. now it looks simple enough to but unfortunetly it does not work

now i understand about how you have to line up the icustom in the correct order and that the secound to the last diget of the iCustom is the int mode which indicates which buffer you're looking use . in my case 0-3.. but it open orders at ramdom and back to back pull it uses ever bar as a singal and keep opening order plus it only opens sell once the histogram crosses the 0 line..

i want it to stop and revese.. follow the trend

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

double macd1=iCustom(Symbol(),0,"macd1",40,80,1,0,0);
double macd2=iCustom(Symbol(),0,"macd1",40,80,1,1,1);

static int trade_bar;
if((macd1>macd2 ) && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,NULL,0,0,Green);trade_bar=Bars;}
if((macd1<macd2) && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,NULL,0,0,Red);trade_bar=Bars;}
//----

   SetSLTP();
//----
   return(0);

whole code try it your self

//+------------------------------------------------------------------+
//|                                        EA based off of MACD1.mq4 |
//|                  Copyright © 2010, dostapyuk@gmail.com, MtCoding |Tested on GbpJpy M5 (hustlerscreed on skype)
//|                                          http://www.mtcoding.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, dostapyuk@gmail.com, MtCoding"
#property link      "http://www.mtcoding.com"

extern double LotSize=0.1;
extern int SL=50,
           TP=30;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   if(Digits==3 || Digits==5)
    {
     SL*=10;
     TP*=10;
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

double macd1=iCustom(Symbol(),0,"macd1",40,80,1,0,0);
double macd2=iCustom(Symbol(),0,"macd1",40,80,1,1,1);

static int trade_bar;
if((macd1>macd2 ) && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,NULL,0,0,Green);trade_bar=Bars;}
if((macd1<macd2) && TOOC()==0 && Bars-trade_bar>0){OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,NULL,0,0,Red);trade_bar=Bars;}
//----

   SetSLTP();
//----
   return(0);
  }
//+------------------------------------------------------------------+

int TOOC()
{
  int tooc;
  for(int a=0;a<OrdersTotal();a++) 
   if(OrderSelect(a,0,0))
    if(OrderSymbol()==Symbol())
      tooc++;
  return(tooc);
}

void SetSLTP()
{
  for(int a=0;a<OrdersTotal();a++)
   if(OrderSelect(a,0,0))
    if(OrderSymbol()==Symbol())
     {
      if(OrderType()==OP_BUY)
       {
        RefreshRates();
        if(OrderStopLoss()==0)OrderModify(OrderTicket(),OrderOpenPrice(),Bid-SL*Point,OrderTakeProfit(),0,Yellow);
        RefreshRates();
        if(OrderTakeProfit()==0)OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Bid+TP*Point,0,Yellow);
       }
      if(OrderType()==OP_SELL)
       {
        RefreshRates();
        if(OrderStopLoss()==0)OrderModify(OrderTicket(),OrderOpenPrice(),Ask+SL*Point,OrderTakeProfit(),0,Yellow);
        RefreshRates();
        if(OrderTakeProfit()==0)OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),Ask-TP*Point,0,Yellow);
       }
     }
  return;
}
Viffer
614
Viffer  

Your macd2 variable is shifted to bar 1 whilst macd1 is on the current bar. (the final parameter is shift) so That is not going to compare properly... set them both to 1 or 0... not sure what trade_bar is but assuming it's confirming to only trade on a new bar... try this function instead..


// Identify new bars
   bool Fun_New_Bar()
      {
      static datetime New_Time = 0;
      bool New_Bar = false;
      if (New_Time!= Time[0])
         {
         New_Time = Time[0];
         New_Bar = true;
         }
      return(New_Bar);
      }

hth

V

yujiao522
3
yujiao522  
Love is a telephone which always keeps silent when you are longing for a call, but rings when you are not ready for it. As a result, we often miss the sweetness from the other end.

Love is a telephone which is seldom program-contr moncler jacketsyou onlyolled or directly dialed. You cannot get an immediate answer by a mere "hello", let alone go deep into your lover's heart by one call. Usually it had to be relayed by an operator, and you have to be patient in waiting. Destiny is the operator of this phone, who is always irresponsible and fond of laying practical jokes to which she may make you a lifelong victim intentionally or unintentionally.

Love is a telephone which is always busy, When you are ready to die for love, moncler coats find, to your disappointment, the line is already occupied by someone else, and you are greeted only by a busy line. This is an eternal regret handed down from generation to generation and you are only one of those who languish for followers.

Love is telephone, but it is difficult to seize the center time for dialing, and you will let slip the opportunity if your call is either too early or too late.

Love is a telephone which is not always associated with happiness. Honeyed words are transmitted by sound waves, but when the lovers are brought together, the phone servers no purpose that many lovers observe that marriage is the doom of love.
123
To add comments, please log in or register