How to code? - page 159

 

Indicator Price Label

Help Please!

Can anyone tell me why the following indicator code will plot a down arrow but will NOT plot a price label. Any other style will show up at the correct level, but it doesn't have the price shown?

int init()

{

DeleteAllObjects();

IndicatorBuffers(2);

SetIndexBuffer(0,Buy);

SetIndexStyle(0,DRAW_ARROW,DRAW_ARROW,BuySize,BuyColor);

SetIndexArrow(0,SYMBOL_LEFTPRICE); < doesn't show up

SetIndexShift(0,1);

SetIndexBuffer(1,Sell);

SetIndexStyle(1,DRAW_ARROW,DRAW_ARROW,SellSize,SellColor);

SetIndexArrow(1,SYMBOL_ARROWDOWN); < plots just fine

SetIndexShift(1,1);

return(0);

}

Thanks!

 

Squize_MA indicator

Nice indicator.

Maybe someone can put an alert when the blue line crosses the red one.

Thanks

Files:
squize_ma.mq4  3 kb
 

please, can u give me an hint for tracking down the biggest loss?

 
Wiley:
On this site, at this link https://www.mql5.com/en/forum/176053/page25 is a copy of the DIN_Kukus_EA_V2.6. If you view the EA's contents, you will find a function that checks for order losses in your order history, just as you have discribed doing for yourself. You can use this working example of how to extract the number of successful trades from your order history. You can modify it to extract history for a particular period of time as well, but I hope this will help you see how to accomplish what you propose to do for yourself...

Hi Wiley,

Thanks for the help.

To be honest, I have been so busy working on a solution, I forgot that I posted the question.

I spent that day going through the mql4 manual and figured out a way to do it.

When it is time to start trading, I set a variable called "OpeningTime" equal to the current time. During the trading session and if a trade has been closed, I have the EA cycle through the order history and look for any orders that are from the given chart and EA and also have a closing time that is greater than "OpeningTime". It then compares the profit (or loss) of the order (using the OrderProfit() function) with what I have set (with an external variable) as being enough. I set it up so that I can stop trading if I made enough of a profit and/or if I have lost a given amount.

Backtesting has shown that it really doesn't improve the results of an already optimized EA any (in fact, more often it makes them worse), which is to be expected because we never know if the next trade (which I have now eliminated) will make things better or worse.

It does allow me to set more stringent conditions from the start though. So, the EA can be optimized using the "get out, I've had enough" option from the start. And that does seem to make my results quite a bit better.

Thanks for your help.

Ron

 

Trying to use the attached Dianpoli in an EA I added arrows to read those in icustom, but my icustom line does not pick the up, any help please?

Here is what I use in the EA val2 = iCustom(Symbol(), Period(), "test3",300,15,1,1,0); & val3 = iCustom(Symbol(), Period(),"test3",300,15,1,2,0);

Files:
test3.mq4  5 kb
 
rwb181:
Hi Wiley,

Thanks for the help.

To be honest, I have been so busy working on a solution, I forgot that I posted the question.

I spent that day going through the mql4 manual and figured out a way to do it.

When it is time to start trading, I set a variable called "OpeningTime" equal to the current time. During the trading session and if a trade has been closed, I have the EA cycle through the order history and look for any orders that are from the given chart and EA and also have a closing time that is greater than "OpeningTime". It then compares the profit (or loss) of the order (using the OrderProfit() function) with what I have set (with an external variable) as being enough. I set it up so that I can stop trading if I made enough of a profit and/or if I have lost a given amount.

Backtesting has shown that it really doesn't improve the results of an already optimized EA any (in fact, more often it makes them worse), which is to be expected because we never know if the next trade (which I have now eliminated) will make things better or worse.

It does allow me to set more stringent conditions from the start though. So, the EA can be optimized using the "get out, I've had enough" option from the start. And that does seem to make my results quite a bit better.

Thanks for your help.

Ron

no it is not what i need

 

this will get you the maximum loss

void history()

{max_loss=0;

int i,hstTotal=OrdersHistoryTotal();

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

{

//---- check selection result

if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false)

{

Print("Access to history failed with error (",GetLastError(),")");

break;

}

if (OrderSymbol()==Symbol()&&OrderProfit()>=max_loss)max_loss=OrderProfit();

{

//code

}

}

}
 

OrderSymbol()==Symbol()&&OrderProfit()>=max_loss

I'm sure it was just a typo but...

If you're looking for the maximum loss the comparison operator should be the 'less than ()'.

Lux

 
increase:
Trying to use the attached Dianpoli in an EA I added arrows to read those in icustom, but my icustom line does not pick the up, any help please? Here is what I use in the EA val2 = iCustom(Symbol(), Period(), "test3",300,15,1,1,0); & val3 = iCustom(Symbol(), Period(),"test3",300,15,1,2,0);

Never seem to get anyone to help, guys please respond

 

Automated Expert Advisor Builder

Fastbrokersfx has a free (they call exclusive) Automated Expert Advisor Builder.

They say, "FastBrokersFX offers a free Expert Advisor Builder. With us you don't need to be an experienced programmer to design your trading robots for MT4. Just a few clicks, save your generated EA file and you're done!"

You can create one by clicking on that link from their home page:

Fastbrokersfx | Forex Trading | Forex ECN Access |

Good luck!