EA from scratch - Part 1 - page 5

 
Sadly:
void SetIndexDrawBegin( int index, int begin)

Sets the bar number (from the data beginning) from which the drawing of the given indicator line must start. The indicators are drawn from left to right. The indicator array values that are to the left of the given bar will not be shown in the chart or in the DataWindow. 0 will be set as default, and all data will be drawn.

Having put this into the code, it appears to do absolutely naff all - groan

...don't be so sad, I have this weekend set up for heavy studying and the answer lies within, also I will look at similar indicators with that same set up, you want a line drawn from the bottom of a bar to the top of the highest price, like "zig-zag" or could you illustrate it by graphically depicting it?

 

I thought the idea is to colour the bars on the chart. I've asked about but nothing yet. As the MT4 help file isn't very helpful for beginners like us, we really don't have much to go on other than the Coderguru MQl lessons but even those are very limited in scope with less than a handful of functions explained throughout. I'm loath to ask for help as I don't want other members of the forum to feel obliged in any way. Meantime, the only way I see us working this out is to look at several MQL files to see how keywords and functions are used although we will still be in the dark about how they fully function.

 

...for example I've downloaded all the indicators you have created, do you want the histograms to change color or the candle sticks to color when selling/buying power is prevelent?

 

I reckon the excercise is to figure out how to change the colour of the bars on the chart instead of having a histogram much in the same way as Heiken Ashi colours.

Looking at other indicators that colour the colour the bars on the chart (ie: colour the candlesticks or OHLC bars) we need to definitely look at SetIndexDrawBegin and SetIndexStyle(n,HISTOGRAM) keywords and functions.

 

Hey mycode, I've found this article about EA programming which may come in useful later on.

 

and this article about MQL language for newbies

 

this article, Features of Custom Indicators Creation I think may be useful too.

 

...I found this indicator, look at it, it looks like it colors the candles...

Files:
 

Money Management for ALL Brokers

If your going to write an EA you will need a good Money Management Function. I posted this in Ideas but maybe it is better here. This function will handle any broker and any account--mini, micro, standard.

//+++++++++++++++++++++++++++++++++++++++++

double TradeLots(double percentRisk,int typeMM)

{

/*SPRTN LLC (sprtn.com) Money management function for all brokers.*/

RefreshRates();

double lotSize=MarketInfo(Symbol(),MODE_LOTSIZE);

double totalLots=0.0;

if(typeMM==1) //Account Balance

{

double balance=AccountBalance();

totalLots=balance/lotSize*percentRisk;

}

if(typeMM==2) //Account Equity

{

double equity=AccountEquity();

totalLots=equity/lotSize*percentRisk;

}

if(typeMM==3) //Account Margin

{

double freeMargin=AccountFreeMargin();

double requiredMargin=MarketInfo(Symbol(),MODE_MARGINREQUIRED);

double marginDesired=percentRisk/100*freeMargin;

double marginFactor=marginDesired/requiredMargin;

totalLots=marginFactor;

}

double lotStep=MarketInfo(Symbol(),MODE_LOTSTEP);

totalLots=NormalizeDouble(totalLots/lotStep,0)*lotStep;

double maxLot=MarketInfo(Symbol(),MODE_MAXLOT);

double minLot=MarketInfo(Symbol(),MODE_MINLOT);

if(totalLots>maxLot)totalLots=maxLot;

if(totalLots<minLot)totalLots=minLot;

return (totalLots);

}

 
sprtn:
If your going to write an EA you will need a good Money Management Function. I posted this in Ideas but maybe it is better here. This function will handle any broker and any account--mini, micro, standard.

...thanks, were trying to work out a candle coloring function, this code might come in handy for when were ready to write the "ea"...

Reason: