Hi guys,
I have coded a simple idea i had for the Henken Ashi Indy...but my EA just refuses to take sell trades.
can anyone see what I have done wrong? its really not complicated code as I am still learning ...so hopefully you will see what
my fault is easily enough.
I have attached the EA
thanx
Not too sure but I think that the "comment" should be in quotes in the order send line.
Other than that I'd put a print statement in to see if the program ever tries to open a sell, the logic may not be correct and/or not doing what
you want or think that it is.
Also do you get any error messages in the journal or experts tab?
HTH
Keith
Hi guys,
I have coded a simple idea i had for the Henken Ashi Indy...but my EA just refuses to take sell trades.
can anyone see what I have done wrong? its really not complicated code as I am still learning ...so hopefully you will see what
my fault is easily enough.
I have attached the EA
thanx
if(newbar()==true)
{
if (total==0&&previndex3<previndex2&&index3>index2)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,sll,tpl,comment,magic,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
}// endif(newbar()==true) -->>close this if statement here
ronaldosim, I did the change you suggested and it still only takes buy trades...this is very strange to me..is there anything else it could be maybe?
What I did as a test is I took the sell criteria and placed it above the buy criteria...and now it sells only.!!!!
it seems to get stuck in a loop of the 1st set of criteria and wont check the next set.
I closed the newbar() with the } like you suggested and it still does this...
I am really all out of ideas and now must ask again for the better coders out there to please help me understand what i have done wrong.
thanx guys
ronaldosim, I did the change you suggested and it still only takes buy trades...this is very strange to me..is there anything else it could be maybe?
I've not tried out this code, or even viewed it in anything other than my web browser, so apologies if the following is nonsense... but isn't the problem that you've got two calls to the newbar() function? I've not checked the indenting and number of brackets, but it looks as though your code works as follows:
if (newbar() == true)
{
<Consider doing long trade>
if (newbar() == true)
{
<Consider doing short trade>
}
}
From the looks of newbar() it can't possibly return true on consecutive calls like this. Once it's returned true, it will then always return false until a new bar starts. If you swapped round the long and short code, it would always go short and never go long. Therefore, broadly speaking, I think that you need to re-organise your code as follows so that there's only a single call to newbar():
if (newbar() == true)
{
<Consider doing long trade>
<Consider doing short trade>
}
I've not tried out this code, or even viewed it in anything other than my web browser, so apologies if the following is nonsense... but isn't the problem that you've got two calls to the newbar() function? I've not checked the indenting and number of brackets, but it looks as though your code works as follows:
if (newbar() == true)
{
<Consider doing long trade>
if (newbar() == true)
{
<Consider doing short trade>
}
}
From the looks of newbar() it can't possibly return true on consecutive calls like this. Once it's returned true, it will then always return false until a new bar starts. If you swapped round the long and short code, it would always go short and never go long. Therefore, broadly speaking, I think that you need to re-organise your code as follows so that there's only a single call to newbar():
if (newbar() == true)
{
<Consider doing long trade>
<Consider doing short trade>
}
right on!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
I have coded a simple idea i had for the Henken Ashi Indy...but my EA just refuses to take sell trades.
can anyone see what I have done wrong? its really not complicated code as I am still learning ...so hopefully you will see what
my fault is easily enough.
I have attached the EA
thanx