Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 for iPad and trade anywhere!
coiler
220
coiler 2014.02.28 07:58 
Hi All,

I would like to know if designing and EA this way it's wrong.
My EA it's design to open and close a position on the open of the candle (market orders, no limit and stop orders).
But sometimes the close and the open are at the same time, my question is, shoud the ea avoid entry signals when a

position is opened? i mean, not to check for a signal on everytick if a position was open.

Could you help me with this please?

Best.


Tjipke de Vries
6284
Tjipke de Vries 2014.02.28 08:53  
coiler:
Hi All,

I would like to know if designing and EA this way it's wrong.
My EA it's design to open and close a position on the open of the candle (market orders, no limit and stop orders).
But sometimes the close and the open are at the same time, my question is, shoud the ea avoid entry signals when a

position is opened? i mean, not to check for a signal on everytick if a position was open.

Could you help me with this please?

Best.



look to your post ....

do you understand there is no help to give

ofcours if a new trade is opend on a signal new candle there is no need opening another one you know that too

check signal at opening new bar and if all handlings are done on that signal than you can make it false, reset,..... whatever

no need to use signal until you get new bar

so code it and if you have more to ask about it then please show your attempt

coiler
220
coiler 2014.02.28 12:01  

Hi @deVries,

thank you, sorry about my english, i am not talking about opening more that one position at the same time, i'll try to explain one scenario:

- Entry signal lowest low of 4 bars back.

- Exit 10 bars after the entry.

What about if the exit bar, the opening of de 11 bar matchs with and opening position signal?, close and open in the same next bar, because the last bar before exit has a signal entry (is the lowest of 4 bars back). Sorry about my englis again, if you don't understand me i'll try explain the situation again.

I think i i should have to ignore entry signals produced during an opened position, shouldn't i?

Tjipke de Vries
6284
Tjipke de Vries 2014.02.28 21:47  
coiler:

Hi @deVries,

thank you, sorry about my english, i am not talking about opening more that one position at the same time, i'll try to explain one scenario:

- Entry signal lowest low of 4 bars back.

- Exit 10 bars after the entry.

What about if the exit bar, the opening of de 11 bar matchs with and opening position signal?, close and open in the same next bar, because the last bar before exit has a signal entry (is the lowest of 4 bars back). Sorry about my englis again, if you don't understand me i'll try explain the situation again.

I think i i should have to ignore entry signals produced during an opened position, shouldn't i?


this is all bla bla ....

i wrote so code it and if you have more to ask about it then please show your attempt

your scenario ...... - Entry signal lowest low of 4 bars back.

I like to see how you code it if you have questions....

Daniel Petrovai
440
Daniel Petrovai 2014.02.28 23:00  
//--- ----------------------------------------------------------------------------------

//--- Here you count the trades (if any) placed by this EA
myTrades = CountTrades();
if(myTrades > 0)return(0);// or whatever you want to do , maybe manage the open trade or whatever...
//--- else, if no trades open, look for a new entry
if(myTrades < 1)
// check for entry conditions
....

....

return(0);
/*
CountTrades() will select your orders placed by this EA ,count them and return the count.

*/
//========================================================================
int CountTrades()
  {
   int count=0;
   int trade;
   for(trade=OrdersTotal();trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)// Not this EA orders 
         continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)// If EA order , count them
         if(OrderType()==OP_SELL || OrderType()==OP_BUY)
            count++;
     }//for
   return(count);
  }
//========================================================================

Tjipke de Vries
6284
Tjipke de Vries 2014.03.01 12:13  
thrdel:


int CountTrades()
  {
   int count=0;
   int trade;
   for(trade=OrdersTotal();trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)// Not this EA orders 
         continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)// If EA order , count them
         if(OrderType()==OP_SELL || OrderType()==OP_BUY)
            count++;
     }//for
   return(count);
  }
look you do twice say the same only with other words
Daniel Petrovai
440
Daniel Petrovai 2014.03.02 11:47  
deVries:

look you do twice say the same only with other words


Buddy, do ALL your comments need to be destructive? I've seen quite a few of them and still I'm yet to read one that's intended to do some good especially to people who are just starting.

"look to your post ....do you understand there is no help to give"

"this is all bla bla ....i wrote so code it and if you have more to ask about it then please show your attempt "

"look you do twice say the same only with other words "

And this is on this page only !!! Do you get some sort of a sick thrill out of it?

You should at least put on your reading glasses before you find faults with others. Now if you really want to learn the difference between this

if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)// Not this EA orders 
         continue;

and this

  if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)// If EA order , count them

you should go back to basics and learn the difference between " == " and " != "

The code you highlighted in green basically says that if the order symbol doesn't match the chart symbol go to next order

and the code you highlighted in blue says that if the symbol matches and the magic number matches, that's the order that counts.

So it's not " the same but with other words " it's quite " different but with almost the same words"

Are you so determined to pick on others that you can't even read the code anymore or you're not as good as you think you are?

That code works perfectly. Is the one you've posted working any better? Oh, yeah, you didn't post any ! Is it because you didn't want to help or because you couldn't write 5 lines that make sense and work?

Tjipke de Vries
6284
Tjipke de Vries 2014.03.02 13:30  
thrdel:


Buddy, do ALL your comments need to be destructive?

If the OP is not showing his/her attempt then why should i come coding it

if the OP is asking for helping on his/her code like above then we have to see the code

if you think you have to do it for the OP then do it

if you make failures on it and i give you hints about those errors then still it is not for me a reason to give the OP without trying anything a correct solution

for you

if The code i highlighted in green basically says that if the order symbol doesn't match the chart symbol go to next order

then what is happening if it is not going to the next order.....

int CountTrades()
  {
   int count=0;
   int trade;
   for(trade=OrdersTotal();trade>=0;trade--)
     {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber)continue;// Not this EA orders 
      if(OrderType()==OP_SELL || OrderType()==OP_BUY) count++;// If EA order , count them
     }//for
   return(count);
  }

check this is there any difference in results you get ??

Alain Verleyen
Moderator
28701
Alain Verleyen 2014.03.02 14:47  
Guys, I suggest to calm down. Anyone if free to help the OP as he wishes. If you don't agree with some approaches, use your own and simply ignore others.
Daniel Petrovai
440
Daniel Petrovai 2014.03.02 22:01  
deVries:

If the OP is not showing his/her attempt then why should i come coding it

if the OP is asking for helping on his/her code like above then we have to see the code

if you think you have to do it for the OP then do it

if you make failures on it and i give you hints about those errors then still it is not for me a reason to give the OP without trying anything a correct solution

for you

if The code i highlighted in green basically says that if the order symbol doesn't match the chart symbol go to next order

then what is happening if it is not going to the next order.....

check this is there any difference in results you get ??


I suggest you test the code first and only if it doesn't work you may point out the error in it.

Are we debating here if x=x+1 is better than x++ or x+=1? Really?

"then what is happening if it is not going to the next order..... "." continue" will get the execution up to " trade=OrdersTotal()" .Is it so hard to follow such simple code?

Have you ever heard that there are "many ways to skin a cat " not just your way?

Please stop going around telling people that "the code is wrong" if you don't bother to read it properly and test it or if you don't understand it.

It's not helpful.

/
To add comments, please log in or register