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

To add comments, please log in or register
derek
98
derek  
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..

hth

V

ok where do i put this and what do i take out the code....

so thanks much for being patient with me...

also i tryed the commen shift thing before too it did not work, it still did the same thing

// 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);
      }
derek
98
derek  
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.

what is this ...nice read but how does that help with the programming

derek
98
derek  

can someone show me how to put this in my code

// 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);
      }

//+------------------------------------------------------------------+
//|                                        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  
hustlerscreed:

can someone show me how to put this in my code

Sorry, missed it... put the function right at the bottom of the page... outside the start() function. Then in your if statement where you have all that stuff saying bars-trade_bars, replace with Fun_New_Bar().

V

derek
98
derek  

is it like this

//+------------------------------------------------------------------+
//| 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-Fun_New_Bar()>0){OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,NULL,0,0,Green);Fun_New_Bar()=Bars;}
if((macd1<macd2) && TOOC()==0 && Bars-Fun_New_Bar()>0){OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,NULL,0,0,Red);Fun_New_Bar()=Bars;}
//----

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

// 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);
Viffer
614
Viffer  

Erm... not quite... Try reading the function code and see if you can work out what it's doing. Whilst that may actually compile... and may even run... think about what you have asked it to compare... What do you think will be the answer to Bars-TRUE. The best way, in an EA to detect new bars is to compare time rather than counting bars. The function simply detects if there is a new bar or not.

V

123
To add comments, please log in or register