MQL4 Learning - page 97

 

Problem with output values of indicators - has anybody noticed it ?

Hi,

I'm new to mql4 coding, and have a problem with output values of indicators when coding my EA, for example stochastics or CCI.

I noticed that there is a remarkable difference between the values of an indicator seen on the chart after a backtest and the value the program "read" and use.

For exemple, for the CCI, i can read a value of 55 on the chart at a precise bar, let's say 6h the 20/04/2010 (on a H1 period) and if i read the value of the CCI on the journal at the same time (with the print operator) value can be randomly between around 35 to 75 !

This keep happening and make my EA ineficient because the value it takes to operate are inacurate.

Has anybody noticed it or could explain me how to solve this very strange thing ?

Thank you very much !

keyrama

 

Sell Orders

Hi,

I am in the process of writing an EA to trade EUR/USD on 5m timeframe and it works really well for Buy orders. However I had envisioned that I would just be able to 'reverse' the conditions for Sell Orders, however what is very profitable for buy orders, is not so for Sell orders. Is this normal or is there a reason for it, or perhaps something to do with the dynamic of the EUR/USD on a fundamental basis in that when it falls (i.e. sold) it behaves differently on account of traders and institutions 'flighting' to the USD in a larger hurry than what they do to EUR. Any ideas? I have also posed a Strategy tester report below for Buy orders only if anyone would like to comment.

Files:
report.jpg  135 kb
 
keyrama:
Hi,

I'm new to mql4 coding, and have a problem with output values of indicators when coding my EA, for example stochastics or CCI.

I noticed that there is a remarkable difference between the values of an indicator seen on the chart after a backtest and the value the program "read" and use.

For exemple, for the CCI, i can read a value of 55 on the chart at a precise bar, let's say 6h the 20/04/2010 (on a H1 period) and if i read the value of the CCI on the journal at the same time (with the print operator) value can be randomly between around 35 to 75 !

This keep happening and make my EA ineficient because the value it takes to operate are inacurate.

Has anybody noticed it or could explain me how to solve this very strange thing ?

Thank you very much !

keyrama

If you are reading the value of the indicators for the [0] bar, they will constantly fluctuate until that bar has closed. Particulary using a 1hr timeframe these values will change rather substantially as the indicator changes with the high/low value of the current bar. I suggest using indicating data from the previous bar and a simple for the current bar. Say you want to buy on oversold conditions, i would code it as such

double CCI_1= (cci with chart shift 1), CCI_2 =(cci of chart shift 2)

CCI_1CCI_0 (just to check current bar is heading upwards and not continuing south.

 

Bump??????

 

Problem with output values of indicators - has anybody noticed it ?

Hi,

I'm new to mql4 coding, and have a problem with output values of indicators when coding my EA, for example stochastics or CCI.

I noticed that there is a remarkable difference between the values of an indicator seen on the chart after a backtest and the value the program "read" and use.

For exemple, for the CCI, i can read a value of 55 on the chart at a precise bar, let's say 6h the 20/04/2010 (on a H1 period) and if i read the value of the CCI on the journal at the same time (with the print operator) value can be randomly between around 35 to 75 !

This keep happening and make my EA ineficient because the value it takes to operate are inacurate.

Has anybody noticed it or could explain me how to solve this very strange thing ?

Thank you very much !

keyrama

 

Just Impossible! Please explain

The following order of my expert advisor:

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-400*Point,0,"",Magic,0,Green);

does not respond to any MT4 platform. It makes nothing as if it didn't exist!!!However, it executes normally on backtesting!!!

Moreover, the order :

OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"",Magic,0,Green);

has no problems and it executes absolutely normally...

It is totally crazy. Any idea which would help me?

Thank you very much

 

Trade only when crossing ?

Hi,

Tx u Kelenzo

 

is it possible to open an oreder lets suppose 1 lot and the splitt it into 2 different orders ? ex . enter long with 1 lot then first exit 0.5 lot at a target price and then continue with the other 0.5 lot untill the set up is met

my problem is that my code exit all conditions for an exit at close price of the bar and there is no intrabar lookup even if do not use close but bid and ask . so does with the first exit 0.5 lot at a target setted up when enter the trade .

i do not know why cuold please sambody help

is it better to make two ea s or can i do the job done on one ?

please help me out

 
pariatore:
is it possible to open an oreder lets suppose 1 lot and the splitt it into 2 different orders ? please help me out

you may find answer here ...

Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial

 

Very simple MQ4 coding problem Andrews Pitchfork-Reaction Lines...can anyone help?

I have a very simple problem with an custom Indicator that draws pitchforks /ML's , inner lines, trigger lines, sliding parallels etc.

I trade reaction lines... ie the distance of P0 to the midpoint of P1/P2.....all i want to do is add a 50% RL at half the distance of P0 toP1/P2 so i have double the number of reaction lines lines. This facility is available on Ensign Windows pitchfork tool but i use Metatrader for my trading account. I have torn my hair out trying to get my head around what i need to do with the code but guess it may take someone who actually knows what they are doing a few seconds?

if (Draw_Reaction_Lines)

{

for(x=1; x <= Num_Of_Reaction_Lines;x++)

{

txt = AL_Name+"Reaction_LN1"+x;

SetLN(txt, BarToTime(T2Bar - TimeShift/accuracy_factor*x), p2 + PriceShift/accuracy_factor*x , BarToTime(T3Bar - TimeShift/accuracy_factor*x), p3 + PriceShift/accuracy_factor*x, Reaction_LN_Color,Reaction_LN_Style,Reaction_LN_Width, Extend_Reaction_Lines);

txt = AL_Name+"Reaction_LN2"+x;

SetLN(txt,BarToTime(T3Bar - TimeShift/accuracy_factor*x), p3 + PriceShift/accuracy_factor*x , BarToTime(T2Bar - TimeShift/accuracy_factor*x), p2 + PriceShift/accuracy_factor*x, Reaction_LN_Color,Reaction_LN_Style,Reaction_LN_Width, Extend_Reaction_Lines);

Any help would be very much appreciated by someone like me who is a complete stranger to the world of coding

Files:
aml_v1.mq4  24 kb
Reason: