EA vs Indicators
Results 1 to 9 of 9

Thread: EA vs Indicators

  1. #1
    I am trying to compose an EA based on an indior I researched. The indior is rather complex(particularly for a novice coder) and was drifting of the ideal way to utilize the indior's logic in the EA. The problem I am having is I have no idea of how an EA assesses the price data to create by decisions. In order for this EA to generate a buy/sell sign about 50 or even more of those last bars will need to be analyzed. In are predicated on some type of cross logic which require no prior data to be analyzed other than calculated. So here are some of my question:

    1. Should I make a function prior to the start() that could have all the logic for triggering a buy/sell and then have the function return a 1=buy 2=market type thing?
    2. Should I contain the logic inside the start()function?
    3. Is the exact same EA acceptable for back testing and trading?
    4. Reside generate signs that have open trades that should have never been open live and happen before?

  2. #2
    Quote Originally Posted by ;
    1. Should I make a function prior to the start() that could have all the logic for tripping a buy/sell and then have the function return a 1=buy 2=market kind item?
    2. Should I include the logic within the start()function?
    3. Is the precise EA trading and testing?
    4. Can an EA that is being traded reside generate signs that have open transactions which should happen to be available dwell and happen in the past?
    1. Yes, that is a wonderful strategy I use.
    2. No! Don't clutter the start function, and try to avoid writing long or heavily functions generally.
    3. Should be. The only limitation that comes to mind is, that backtesting basket egies with more than the current emblem will not work.
    4. If you don't code it especially so that shouldn't happen. You will see that it might actually be a lot easier to compose the EA compared to the indior, as you don't have to create the signs for bars that are old. All you have to analyze is the status quo.

    Hope that helps, and good luck with your EA!

  3. #3
    Quote Originally Posted by ;
    1. Yes, that is a wonderful strategy I use fairly often.
    2. No! Don't clutter the start feature, and try to avoid writing long or heavily functions in general.
    3. Should be. The sole limitation that springs to mind isthat backtesting basket egies with over the current symbol won't operate.
    4. If you don't code it so that should not happen. You will see because you don't need to make the historical signs for bars that it may actually be a lot easier to compose the EA when compared with the indior. Is the status quo.

    Hope that helps, and great luck with your EA!
    Thank you for the reply!

    I chose to have all my perception inside the start() function. The reason is that the logic is somewhat complicated (and im an MQL noob) and was not sure how to properly make a function based on it. So the logic generates 2 things:Whether it is ok to go long/short and at what price. The entries need to be performed with OB_BUYSTOP/OP_SELLSTOP.
    That is what I have at the end of my entry perception:

    Inserted Code total=OrdersTotal(); if (totallt;1) if (okToBuy) ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PendingB O,3,Ask-StopLoss*Point, Ask TakeProfit*Point,My EA, 12345,0,Blue); The thing is that if the order is not triggered inside the current pub I would prefer the order canceled. So I added this at the end of the code:

    Inserted Code if ((ticketgt;0) (totallt;=0)) OrderDelete(ticket,Green);
    This however seems to delete the order just as it is generated. Placing the code before the OrderSend() (believing it will only return true on the next bar) won't cancel the order in any way.

    Any suggestions will be appreciated!

  4. #4
    Additionally I see this published in the journal when seeking to backtest:

    2007.06.14 19:12:57 2007.06.08 14:15 My_EA EURUSD.spot,M15: invalid price 1.34429000 for OrderSend function

    Why is the price ?

  5. #5
    Quote Originally Posted by ;
    Additionally I see this published in the diary when trying to backtest:

    2007.06.14 19:12:57 2007.06.08 14:15 My_EA EURUSD.spot,M15: Ranked price 1.34429000 for OrderSend function

    Why is the price ?
    I'm also pretty new, but I will answer this question. The price has to have same number of digits as your broker's feed. 1.34429 includes five specimens, but it should be only four for this pair. You have to use
    NormalizeDouble(Price?? ,Digits)
    to induce it to round until the appropriate digits. The Price?? Is your entrance price, StopLoss and TakeProfit. All have to be piled up with this kind of statement.

    -chandra

  6. #6
    Quote Originally Posted by ;
    Thank you for the answer!

    I decided to have all of my perception within the beginning () function. The main reason is that the logic is a bit complex (and im an MQL noob) and wasn't sure how to properly create a function based on it. So the logic generates 2 things:Whether it's ok to go long/short and at what price. The entries should be done with OB_BUYSTOP/OP_SELLSTOP.
    This is what I have at the conclusion of my entry logic:

    Inserted Code total=OrdersTotal(); if (totallt;1) if (okToBuy) ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PendingB O,3,Ask-StopLoss*Point, Ask TakeProfit*Point,My EA, 12345,0,Blue); The problem is that in the event the order isn't triggered inside the current bar I would like the order . So I added this at the end of the code:

    Inserted Code if ((ticketgt;0) (totallt;=0)) OrderDelete(ticket,Green); This however appears to delete the exact order as soon as it's generated. Placing the code prior to the OrderSend() (believing that it will only return true on the next bar) will not cancel the order at all.

    Any hints will be appreciated!
    Try to use the expiry date for pending orders:
    Inserted Code total=OrdersTotal(); should (totallt;1) if (okToBuy) datetime expiration = Time#91;0#93; Period()*60; ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PendingB O,3,Ask-StopLoss*Point, Ask TakeProfit*Point,My EA, 12345,expiration,Blue); I occasionally found it will not operate if the time to expiry is to close, though. If that's the case you'll have to manually check that the pending order open time, for example like this:
    Inserted Code if ((ticketgt;0) (totallt;=0)) if(OrderOpenTime() lt; Time#91;0#93;-RRB- OrderDelete(ticket,Green);
    I also wanted to mention, that you should consider calling the indior with iCustom() rather than copy and pasting the code. However, it must not necessarily be simple and it slower.

  7. #7
    It works!
    Only for much better comprehension could you explain why you've Period()*60 rather than simply Period()?
    Thanks!

  8. #8
    Quote Originally Posted by ;
    It works!
    Only for much better understanding could you explain why you have Period()*60 instead of only Period()?
    Thanks!
    Very easy: Period() is in moments and datetime are seconds.

  9. #9
    Quote Originally Posted by ;
    Try to use the expiry date for pending orders:
    Inserted Code total=OrdersTotal(); if (totallt;1) if (okToBuy) datetime expiry = Time#91;0#93; Period()*60; ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,PendingB O,3,Ask-StopLoss*Point, Ask TakeProfit*Point,My EA, 12345,expiration,Blue); I occasionally found it will not work if the time to expiration is to close, though. In that case you will need to manually check the pending order open time, for example like this:
    Inserted Code if ((ticketgt;0) (totallt;=0)) if(OrderOpenTime() lt; Time#91;0#93;-RRB- OrderDelete(ticket,Green); I also wanted to mentionthat you should consider calling the indior with iCustom() rather than copy and pasting the code. However, it must not be simple and it is probably slower.
    Well, unfortunately there is a little problem. Your initial solution does cancel the pending orders however, it happens every pub rather than the next pub. And in respect where could I put that code?
    Thank you for your help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.