Coding help - page 389

 
triip:
I have found nice scalping system and template but it runs so slowly after installing this system. Maybe someone is able to look it and detect what could cause it.

Template and indicators:

1m_alf_scalp.zip

Looks like candle color indicator(IT_Candles) is the problem. Someone understands what is wrong with that code that MT4 runs slowly ?

//+------------------------------------------------------------------+//| IT_Candles.mq4

//+------------------------------------------------------------------+

#property indicator_chart_window

#include

#property indicator_buffers 2

extern color UpColor = LimeGreen;

extern color DnColor = Red;

extern int Width = 5;

extern double alpha = 0.09;

double ev=EMPTY_VALUE,Trend,Trigger,ALF;

double Up[];

double Dn[];

int init()

{

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_HISTOGRAM,0,Width,UpColor);

SetIndexBuffer(0,Up);

SetIndexStyle(1,DRAW_HISTOGRAM,0,Width,DnColor);

SetIndexBuffer(1,Dn);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1); //---- check for possible errors

if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted

int limit = Bars-counted_bars;

for (int i=limit;i>=0;i--)

{

Up = ev;

Dn = ev;

Trend = iCustom(NULL,0,"Instant_Trendline",alpha,0,i);

Trigger = iCustom(NULL,0,"Instant_Trendline",alpha,1,i);

ALF = iCustom(NULL,0,"ALF",0,i+1);

if (Trigger > Trend && Close > Open && Close > ALF)

{

Up = MathMax(Open,Close);

Dn = MathMin(Open,Close);

}

if (Trigger < Trend && Close < Open && Close < ALF)

{

Dn = MathMax(Open,Close);

Up = MathMin(Open,Close);

}

}

}

 
triip:
Looks like candle color indicator(IT_Candles) is the problem. Someone understands what is wrong with that code that MT4 runs slowly ?
//+------------------------------------------------------------------+//| IT_Candles.mq4

//+------------------------------------------------------------------+

#property indicator_chart_window

#include

#property indicator_buffers 2

extern color UpColor = LimeGreen;

extern color DnColor = Red;

extern int Width = 5;

extern double alpha = 0.09;

double ev=EMPTY_VALUE,Trend,Trigger,ALF;

double Up[];

double Dn[];

int init()

{

IndicatorBuffers(2);

SetIndexStyle(0,DRAW_HISTOGRAM,0,Width,UpColor);

SetIndexBuffer(0,Up);

SetIndexStyle(1,DRAW_HISTOGRAM,0,Width,DnColor);

SetIndexBuffer(1,Dn);

return(0);

}

int deinit()

{

return(0);

}

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars<0) return(-1); //---- check for possible errors

if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted

int limit = Bars-counted_bars;

for (int i=limit;i>=0;i--)

{

Up = ev;

Dn = ev;

Trend = iCustom(NULL,0,"Instant_Trendline",alpha,0,i);

Trigger = iCustom(NULL,0,"Instant_Trendline",alpha,1,i);

ALF = iCustom(NULL,0,"ALF",0,i+1);

if (Trigger > Trend && Close > Open && Close > ALF)

{

Up = MathMax(Open,Close);

Dn = MathMin(Open,Close);

}

if (Trigger < Trend && Close < Open && Close < ALF)

{

Dn = MathMax(Open,Close);

Up = MathMin(Open,Close);

}

}

}

triip

Check if you have the "Instant_Trendline" and "ALF" indicators in the indicators folder too (both are needed for that indicator to work correctly). If you do not have them, extract the ex4 files from that zip archive and the indicator will work OK (if you do not have them there, it will be very slow)

Files:
it.gif  75 kb
 
mladen:
triip Check if you have the "Instant_Trendline" and "ALF" indicators in the indicators folder too (both are needed for that indicator to work correctly). If you do not have them, extract the ex4 files from that zip archive and the indicator will work OK (if you do not have them there, it will be very slow)

Yes I put the other indicators on the chart too, but as soon as I add IT_Candles, MT4 slows down, specially switching timeframes slows down..

 
triip:
Yes I put the other indicators on the chart too, but as soon as I add IT_Candles, MT4 slows down, specially switching timeframes slows down..

triip

They don't need to be on the chart. But they must exist (using those exact names) in the indicators folder. The easiest way to check is to go to experts tab of the terminal and see if there is some error there (like the one on the picture)

Files:
error_2.gif  98 kb
 
mladen:
triip They don't need to be on the chart. But they must exist (using those exact names) in the indicators folder. The easiest way to check is to go to experts tab of the terminal and see if there is some error there (like the one on the picture)

No errors there.

But I noticed that ALF.ex4 not slowing much, but ALF-MTF.ex4 slowing totally. I have a sub-folder in the indicators folder, where stays all those mentioned indicators. Maybe I should re-install clean MT4.

Files:
errors.png  27 kb
 
triip:
No errors there.

But I noticed that ALF.ex4 not slowing much, but ALF-MTF.ex4 slowing totally. I have a sub-folder in the indicators folder, where stays all those mentioned indicators. Maybe I should re-install clean MT4.

Move them from the sub-folder to the main indicators folder and try it then

 
mladen:
Move them from the sub-folder to the main indicators folder and try it then

Much better, works like a charm Thank you mladen !!!

 
sunshineh:
Hi,

I am always having problems with writing text objects over the bars in my chart.

For example

ObjectCreate ("Xh", OBJ_TEXT,0,Time[0],High[0]+1*pips2dbl);

ObjectSetText("Xh","1",10,"Tahoma",Orange);

ObjectCreate ("X", OBJ_TEXT,0,Time[0],Low[0]-1*pips2dbl);

ObjectSetText("Xl","1",10,"Tahoma",Orange);

This is working fine with text objects below my bars because my font object is fixed "on the head of" my text.

But if I want to write some text above the bar, I don't now how my pips my text in font size 10 is an so it is written into the bars.

There is also a problem when I write my text in bigger timeframes f.e. "H1", "D1" oder "W1" because there I had to change my font-distance to the high- or low-value, too.

I know I can rotate my text to 90° but I don't want to do that.

So do you know a solution for that problem?

For start try using ATR instead of 1*pips2dbl (that way it will adjust itself to different time frames and symbols).

Also try adjusting the anchor point (OBJPROP_ANCHOR) of the text to ANCHOR_LOWER for the text object that is displayed above the high

 
madopter:
The adjustable parts should be the lot size, and the account balance to which the lot is applied to. For example, the parameters might be A = 0.01, B = $5000, or, A = 1.00, B = $10000.

In that case you have to have multiple parameter values usable for comparison

You can define the parameters like: extern double accountBalanceA = 5000; and then use those parameters in comparison in that code that did the same thing without parameters

 
mladen:
jbozman

the macd indicator does not need any change (it will calculate only 1 or 2 bars in 99.99% of cases)

hilo indicator seeks for values in a very clomplicated way. Better to use some other indicator that does that task in a much simpler way (no need to make it so complicated)

Hi mladen. I searched and couldn't find a high/low that had previous day, week and month all in one that paints simple line segments and doesn't make a mess of chart.

I know you said to try to find another one; however, I really looked and wasn't able. I posted a request at mql4 forum, too. Haven't heard back.

Quite simply, I'd be willing to pay someone (you) to modify this indicator.

I would like "Number of Days" added as this one plots every previous day. On EUR/USD and GBP/USD, my chart history goes back to 1996 or more so it takes up too much memory with all these lines.

If you're not for hire (maybe someone else would be?), is it too complicated to just add Number of Days to this current one? I can continue to use it until I find another or find someone who would modify. If that's a time-consuming request, I completely understand and thank you for your help on everything.

jbozman

Files:
Reason: