[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 4

 
on a signal: fractal (indicator olyakish). only 1 position is opened, which is closed on the opposite fractal and the opposite position is immediately opened. Objective: to code a stop at the minimum or maximum value of the fractal at which the position was opened +\- 5 pips.
 
You should definitely check
- if the price at the time of opening the order has gone +/-5 pt from the fractal
- or catch the moment to open when the price is in the corridor +/-5 from the fractal
= put stops / sticks + then check the freezing levels
 

Hello Gentlemen Professionals!

Finally my brain has figured out how to install an EA, but,

I've installed Rabbit3 - run it, set autotrade permission. I've got Rabbit3 here, I've got a Buy or Sell order. Lot 0.01, Sell and Buy buttons are inactive, and when I change lot to 0.1, "Not enough money". What should I do? Is this EA capable of micro lot trading or not?

 

I decided to code position opening using MACD_Histogram indicator(found in base https://www.mql5.com/ru/code/8253), but I can't figure out how to code it correctly. I should add some fixes to indicator, it has no errors when compiling, but tester blames buffers. Please advise how and what to fix.

//+------------------------------------------------------------------+
//|                                                           E .mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- input parameters
extern string separator1 = "*** MACD Settings ***";
extern int FastMAPeriod = 12;
extern int SlowMAPeriod = 26;
extern int SignalMAPeriod = 9;
extern double Lots = 0.01;
#define arrowsDisplacement 0.0001

//---- buffers
double MACDLineBuffer[];
double SignalLineBuffer[];
double HistogramBuffer[];
double bullishDivergence[];
double bearishDivergence[];
//---- variables
double alpha = 0;
double alpha_1 = 0;
static datetime lastAlertTime;
static string   indicatorName;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  { 
//---- 
   SetIndexStyle(0, DRAW_LINE);                        SetIndexBuffer(0, MACDLineBuffer);
   SetIndexStyle(1, DRAW_LINE);                        SetIndexBuffer(1, SignalLineBuffer);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID,2);    SetIndexBuffer(2, HistogramBuffer);
   SetIndexStyle(3, DRAW_ARROW);                       SetIndexArrow(3, 233);
   SetIndexStyle(4, DRAW_ARROW);                       SetIndexArrow(4, 234);
//----
	  alpha = 2.0 / ( SignalMAPeriod + 1.0);
	  alpha_1 = 1.0 - alpha;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   for(int i = ObjectsTotal() - 1; i >= 0; i--)
     {
       string label = ObjectName( i);
       if(StringSubstr( label, 0, 19) != "MACD_DivergenceLine")
           continue;
       ObjectDelete( label);   
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   int limit;
   int counted_bars = IndicatorCounted();
   //---- check for possible errors
   if( counted_bars < 0) 
       return(-1);
   //---- last counted bar will be recounted
   if( counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
   CalculateIndicator( counted_bars);
//----
   for(int i = limit; i >= 0; i--)
     {
       MACDLineBuffer[ i] = iMA(NULL, 0, FastMAPeriod, 0, MODE_EMA, PRICE_CLOSE, i) - 
                           iMA(NULL, 0, SlowMAPeriod, 0, MODE_EMA, PRICE_CLOSE, i);
       SignalLineBuffer[ i] = alpha* MACDLineBuffer[ i] + alpha_1* SignalLineBuffer[ i+1];
       HistogramBuffer[ i] = MACDLineBuffer[ i] - SignalLineBuffer[ i];
     }

//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateIndicator(int countedBars)
  {
   for(int i = Bars - countedBars; i >= 0; i--)
     {
       CalculateMACD( i);
       CatchBullishDivergence( i + 2);
       CatchBearishDivergence( i + 2);
     }              
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateMACD(int i)
  {
   MACDLineBuffer[ i] = iMA(NULL, 0, FastMAPeriod, 0, MODE_EMA, PRICE_CLOSE, i) - 
                       iMA(NULL, 0, SlowMAPeriod, 0, MODE_EMA, PRICE_CLOSE, i);
   SignalLineBuffer[ i] = alpha* MACDLineBuffer[ i] + alpha_1* SignalLineBuffer[ i+1];
   HistogramBuffer[ i] = MACDLineBuffer[ i] - SignalLineBuffer[ i];      
  }
//+------------------------------------------------------------------+
//|         сигнал                                                         |
//+------------------------------------------------------------------+
void CatchBullishDivergence(int shift)
  {   
   int currentTrough = shift;
   int lastTrough = GetIndicatorLastTrough( shift);
//----   
   if( MACDLineBuffer[ currentTrough] > MACDLineBuffer[ lastTrough] && 
      Low[ currentTrough] < Low[ lastTrough])
     {
       bullishDivergence[ currentTrough] = MACDLineBuffer[ currentTrough] - 
                                          arrowsDisplacement;
       // OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"",0,0,Red);
       //----
       
       //----
       
       //----
       
     }
//----   
 
Can't anyone help me with a question...
 
you need to set the properties
- #property buffers
- #property colours
see examples in the same MASD code
 
Korey >> :
need to set properties
- #property buffers
- #property colours
see examples in the code of the same MASD

Unfortunately, does not help. The same log says 2009.02.11 00:08:10 2009.01.05 00:00 E_ EURGBP,M1: SetIndexBuffer function must be called from custom indicator only

Repeats 3 times and ..... looks like there is a problem...what else is there?

Here is the translation...2009.02.11 00:08:10 2009.01.05 00:00 E_ EURGBP,M1: SetIndexBuffer function must be called from custom indicator only

 
amur писал(а) >>

Here is the translation...2009.02.11 00:08:10 2009.01.05 00:00 E_ EURGBP, M1: function SetIndexBuffer should be called from custom indicator only

Custom?) In the tester, you test Expert Advisors, not indicators, and if they are indicators, you test Expert Advisors. And this is still an indicator, even if it is crooked by daredevil hands. If you want to code by yourself, you have to fill the gaps in your knowledge.

 
Figar0 >> :

Customs?) In the tester you test EAs, not indicators, and if there are indicators, then by testing EAs. And this is still an indicator, even if it is mutilated by dull hands. If you want to code by yourself, you have to fill the gaps in your knowledge.

Figar0, I am trying to learn, I wrote above that I can not understand how to describe the buffers from the tutorial - in general, the Expert Advisor to trade on the MACD_Histogram indicator signals.

>> That's why I decided to ask for help from you - professionals. thanks for your help))


 
amur писал(а) >>

Figar0, I'm trying to learn, above I wrote that I can not understand from the tutorial how to describe the buffers - in general, that the Expert Advisor has traded on the signals of MACD_Histogram indicator.

I decided to ask for help from you, professionals. Thank you for your help))

Take the Expert Advisor, e.g. MACD Sample, comes with MT4. Look at its code. It uses the MACD indicator but does not have any buffers. Doesn't it? Instead it accesses the indicator values through iMACD(....). It is the same in your case, you should not redo the indicator for trading, but take your Expert Advisor and modify it to work with your indicator. And to address to indicator values through iCustom (....) (Rules of use are in the help and tutorial). If you have more exact questions, please, ask.

Reason: