Coding help - page 406

 
elfural:
Dear mrtools and mladen

Can anybody assist? Tom Demark Moving Average is a key indicator within my strategy, however, an alarm would be very useful for when a new shelf is indicated; I would be very grateful if an alarm could coded into the indicator. Looking forward to your kind assistance.

Many thanks

Elfural, added an alerts to the version you posted, and want to show you a version corrected by Mladen you may be interested in from here: https://www.mql5.com/en/forum/178551/page2 just in case added alerts to that version too.

 

hi guys,

I need help with coding this indicator. Its a great indicator though it delays 4-5 candles. Please help.

grail_indic.ex4

Files:
 
mrtools:
Elfural, added an alerts to the version you posted, and want to show you a version corrected by Mladen you may be interested in from here: https://www.mql5.com/en/forum/178551/page2 just in case added alerts to that version too.

It now does exactly what I needed.

Thanks very much for your great help.

 

1 trade per signal.Hi MQL pro-coders,

I wonder if someone could help me. I would like to implement "one trade per signal"

into my EA. If the EA reaches it's profit target, it may well be that the EA opens

another trade in the same trend direction. This may lead into a loosing trade because

the signal is about to change (please see attached screen shots).

What would be the best way for me to implement the "one trade per signal" functionality?

I could of course increase the profit target to prevent the EA from open another trade,

but this is probably not the best way.

I have tried to implement this but,the code compiles and it gives a warning:

"Check operator precedence for possible error; use parentheses to clarify precedence"

What may be the best way to implement this feature?Thank you in advance!

extern int maxshorttrades = 1;

extern int maxlongtrades = 1;

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

//| ORDER Logic / Indicators |

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

if(openedOrders<=0)

{

double CCIFilter = iCCI(NULL,0,CCIPeriod,CCIMethod,0);

double trendc = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

//+-----+

//| BUY |

//+-----+

for (i=OrdersTotal()-1;i>=0; i--)

if(OrderType()==OP_BUY<maxlongtrades) break; // Check Position and Longtrades.

{

if(trendc!=trendp)

{

if(trendc==1 && CCIFilter<-80) // code for buy

OpenBuy();

return(0);

}

openedOrders++;

}

//+------+

//| SELL |

//+------+

for (i=OrdersTotal()-1;i>=0; i--)

if(OrderType()==OP_SELL<maxshorttrades) break; // Check Position and Shorttrades.

{

if(trendc==-1 && CCIFilter>80) // code for sell

{

OpenSell();

return(0);

}

openedOrders++;

}

}

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

//| Close Positions |

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

void CheckForClose()

{

RefreshRates();

double CCIFilter_c = iCCI(NULL,0,CCIPeriod,CCIMethod,0);

double trendc_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,1);

double trendp_c = iCustom(Symbol(),0,"Hull moving average 2 strict nmc", "", HMA_Period, HMA_Price, HMA_Speed,0,3,2);

for(int i=0;i<OrdersTotal(); i++)

{

if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;

if(OrderMagicNumber()!= MAGIC) continue;

if(OrderSymbol() != s_symbol) continue;

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

//| Close BUY |

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

if(trendc_c!=trendp_c) // Check trend

{

if(OrderType()==OP_BUY)

{

if(trendc_c==-1 && CCIFilter_c>80) // SELL and CCI filter?

{

bool buyClose=OrderClose(OrderTicket(),OrderLots(),MarketInfo(s_symbol,MODE_BID),Slippage*pipMultiplier,clCloseBuy);

if(buyClose==false)

{

int ErrorCode = GetLastError();

string ErrDesc = ErrorDescription(ErrorCode);

string ErrAlert= StringConcatenate("Close Buy Order - Error ",ErrorCode,": ",ErrDesc);

if(ShowAlerts == true) Alert(ErrAlert);

string ErrLog=StringConcatenate("Bid: ",MarketInfo(s_symbol,MODE_BID)," Lots: ",OrderLots()," Ticket: ",OrderTicket());

Print(ErrLog);

}

break; }

}

}

Files:
signal1.jpg  19 kb
 

Hello!

Could someone please help me with the Linear Price Line indicator? I am trying to make an altered version of it that substracts the high from the low. If the low is greater than the high or if the high is the same as the openprice and thus zero (because there is no high) then the output should be a negative value (the line in the indicator should shoot under the 0.00 level) Right now it remains a positive number no matter if the high part of the candlestick is larger then the low part of the candlestick or not.

Here is the normal version and faulty difference indicator.linear_price_bar.zip

linear_price_bartestdiff.mq4

Thank you in advance

 
tfi_markets:

1 trade per signal.Hi MQL pro-coders,

I wonder if someone could help me. I would like to implement "one trade per signal"

into my EA. If the EA reaches it's profit target, it may well be that the EA opens

another trade in the same trend direction. This may lead into a loosing trade because

the signal is about to change (please see attached screen shots).

What would be the best way for me to implement the "one trade per signal" functionality?

I could of course increase the profit target to prevent the EA from open another trade,

but this is probably not the best way.

I have tried to implement this but,the code compiles and it gives a warning:

"Check operator precedence for possible error; use parentheses to clarify precedence"

What may be the best way to implement this feature?Thank you in advance!

try this :

bool Result;

int openedOrders = 0;

for (i=OrdersTotal()-1; i>=0; i--)

{

Result = OrderSelect(i, SELECT_BY_POS,MODE_TRADES);

if (OrderSymbol() != Symbol()) continue;

if (OrderMagicNumber() != MagicNumber) continue;

openedOrders++;

}

if (openedOrders <= 0)

{ .....

 
mrcodix:
Hello!

Could someone please help me with the Linear Price Line indicator? I am trying to make an altered version of it that substracts the high from the low. If the low is greater than the high or if the high is the same as the openprice and thus zero (because there is no high) then the output should be a negative value (the line in the indicator should shoot under the 0.00 level) Right now it remains a positive number no matter if the high part of the candlestick is larger then the low part of the candlestick or not.

Here is the normal version and faulty difference indicator.linear_price_bar.zip

linear_price_bartestdiff.mq4

Thank you in advance

mrcodix

Low can never be greater from the high of the same bar

 

Yes i understand but what i would like to plot in my indicator is the difference between HIGH to OPEN and LOW to OPEN. If the absolute number of low to open is greater then the absolute number of high to open then i would like the difference between those 2 to be negative so that it is plotted under the zero line. So how do i make the output of (High - open)-(Low-open) negative when the latter is greater then the former.

Kind regards

 

I have now tried this

for(i=0; i<Bars; i++)

{

BarH = High-Open;

BarL = Low-Open;

BarC = Close-Open;

if(BarC>0) UpDays += 1;

else if(BarC<0) DownDays +=1;

else if(BarC==0) NeutralDays +=1;

if (BarL > BarH) ExtMapBuffer7 = 0-(BarH-BarL);

else if (BarL < BarH) ExtMapBuffer7 =(BarH-BarL);

Output is nevertheless still a positive number! please help.

 
mrcodix:
Yes i understand but what i would like to plot in my indicator is the difference between HIGH to OPEN and LOW to OPEN. If the absolute number of low to open is greater then the absolute number of high to open then i would like the difference between those 2 to be negative so that it is plotted under the zero line. So how do i make the output of (High - open)-(Low-open) negative when the latter is greater then the former. Kind regards

Not sure what you're trying to make. Maybe this ?