Ask! - page 8

 

hi coders,

is it possible to create the EA for Triggerlines as i see on history, it did a great job but it's a bit hard to babysit it all the times.

ussualy i combined it with trend manager, so when the triggerlines crossing up and change the color to blue and TM has blue buy signal, if you can create an ea that can combined both indicators, it would be so helpfull .thx a lot

 

ema cross

Hi codersguru,

I have been trying to get some help with an EA similar to yours because I am not a programmer by any means. I, however, can not drum up any interest so I thought, since yours is so close maybe it can be adjusted for what I am trying to do. Below is an easy explanation of the 3 variables:

If EMA 9 crosses above EMA 30 and Momentum(21) crosses 100 a buy signal is created. A buy exit would be generated when EMA 9 crosses below EMA 30 no matter what the momentum line is doing.

If EMA 9 crosses below EMA 30 and Momentum(21) crosses below 100 a sell signal is created. A sell exit would be generated when EMA 9 crosses above EMA 30 no matter what the momentum line is doing.

What do you think? Is it something that can be adjusted or is it even a feasible EA? Any help would be appreciated!

BW

 

IndicatorCounted

Hi Codegru,

First I want to thank you for doing such a remarkable work, for MT4 lessons. A week ago MT4 was like very hard, but now I start leaning.

I am trying to convert a indicator into EA. Indicator is using "int counted_bars = IndicatorCounted()", for counting bars, in EA I think I can't use this since it related to indicator.

How could I fix this problem.

Thanks a lot....

 

ADX system

Hi Coder's Guru,

I just read the MQL4 guide this last weekend and designed my first EA.

BTW, thanks so much for your guide. I wasn't able to find anything on the Net that made learning the language such a breeze. You really built on each lesson at the right gradient.

Anyways, here's my first EA: I don't know if it's a profitable system or not, but the results of my EA back-test don't match up with some manual back-testing I did. I know there are two filters I wasn't able to figure out how to program but I'll get to that after I explain everything. (I attached a text file with the code in it).

Here's the basis of my system:

Initial setup:

15m time period

If it's between 200 and 1400 EST.

If ADX is greater than 20.

If last bar's [1] range is less than the previos bar's [2] range. (Inside Period).

If last bar's [1] range is less than 7 pips.

Conditional setup A:

If 20-period EMA is up.

If Bid is greater than last bar's high [1] (I'm assuming the charts show Bid only... is that right?)

Buy at ask price with stop loss at one tick below last period's low.

Conditional setup B:

If 20-period EMA is down.

If Bid is less than last bar's low [1].

Sell as Bid with stop loss one tick above last bar's high+ask.

I want to set the take profit at a certain Risk:Reward rate. In my back-testing I found that when the Inside period's bar is less that 5, a 3:1 reward ratio is good. (a 30 pip limit order (5(range) + 3(spread) + 2(SL and entry))*3=30).... I don't think I programmed that correctly in my code though.

First question:

Am I using the right code to initiate the trades? Did I correctly use the highs, asks, etc.?

Second question:

My time filter doesn't seem to work. Am I doing this correctly?

Third question:

I only want the trades initiated ONE PIP above last bar's High+ask. I think my current code will initiate trades if prices gap above this price. How do I fix this?

fourth question:

I think this is the biggest error in my code: I don't have a filter for when the 20-EMA reverses but the ADX is still over 20. I would ALSO like to see how this system works if the 20-EMA reverses, the ADX goes down (but not lower than 20) and then goes back up, so MAYBE we could filter out trades when the ADX is down-trending, but then again this might filter out many profitable trades). If I could get some help on the coding, I would be fine experimenting on these different factors.

From my manual back-testing I think I may have a profitable system here, so any help would be appreciated.

Thanks in advance!

Jason

Files:
ipadxema.txt  5 kb
 

Help in programming

Hi codersguru,

I need help in creating EA. Can you help, if so what are your fees?

 

Hi Codersguru,

it would be great if you would find some time to take a look at my problem:https://www.mql5.com/en/forum/general

Best Regards

Peter

 

Newbie question

Can you help, just starting

Can you tell me how to change the default colours on heiken ashi candles?

I can change colours on chart but they revert to default of red and white if I chage times or currencies.

thanks

Gordon

 
gordon:
Can you help, just starting

Can you tell me how to change the default colours on heiken ashi candles?

I can change colours on chart but they revert to default of red and white if I chage times or currencies.

thanks

Gordon

Hi Gordon, could you post the MQ4 file here, then we could together help you. Hope this help

 

thanks Dave,

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 Red

#property indicator_color2 White

#property indicator_color3 Red

#property indicator_color4 White

//---- buffers

double ExtMapBuffer1[];

double ExtMapBuffer2[];

double ExtMapBuffer3[];

double ExtMapBuffer4[];

//----

int ExtCountedBars=0;

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

//| Custom indicator initialization function |

//|------------------------------------------------------------------|

int init()

{

//---- indicators

SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, Red);

SetIndexBuffer(0, ExtMapBuffer1);

SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, White);

SetIndexBuffer(1, ExtMapBuffer2);

SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, Red);

SetIndexBuffer(2, ExtMapBuffer3);

SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, White);

SetIndexBuffer(3, ExtMapBuffer4);

//----

SetIndexDrawBegin(0,10);

SetIndexDrawBegin(1,10);

SetIndexDrawBegin(2,10);

SetIndexDrawBegin(3,10);

//---- indicator buffers mapping

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexBuffer(2,ExtMapBuffer3);

SetIndexBuffer(3,ExtMapBuffer4);

//---- initialization done

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//---- TODO: add your code here

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

double haOpen, haHigh, haLow, haClose;

if(Bars<=10) return(0);

ExtCountedBars=IndicatorCounted();

//---- check for possible errors

if (ExtCountedBars<0) return(-1);

//---- last counted bar will be recounted

if (ExtCountedBars>0) ExtCountedBars--;

int pos=Bars-ExtCountedBars-1;

while(pos>=0)

{

haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;

haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;

haHigh=MathMax(High[pos], MathMax(haOpen, haClose));

haLow=MathMin(Low[pos], MathMin(haOpen, haClose));

if (haOpen<haClose)

{

ExtMapBuffer1[pos]=haLow;

ExtMapBuffer2[pos]=haHigh;

}

else

{

ExtMapBuffer1[pos]=haHigh;

ExtMapBuffer2[pos]=haLow;

}

ExtMapBuffer3[pos]=haOpen;

ExtMapBuffer4[pos]=haClose;

pos--;

}

//----

return(0);

}

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

 

Hi Gordon, as you can see on the code you've just posted, if you like to change the color permanent, just change ALL WHITE and RED word to whatever color you like, then compile the custom indicator. Please let me know should this could solve your problem. Hope this help