Not logged in

Forums

Viewing 7 posts - 31 through 37 (of 37 total)

Forums>EA Wizard>Strategy Samples>Building an EA for all as tutorial

  • #197203 |
    Conmariin
    Participant
    84 Posts

    Hi 🙂

    I integrated the SandR-Rules+Determining Trend Direction as suggested from Tomas262 (thank you!!) into the EA.
    I also made the ability to chose wich pattern do you like to be activated (from 1 to 3). It seems it works, but I’m not really sure. Please test it. Thanks! 🙂

    With the backtest method only controll points it looks really good. I think we can take this method, because it’s a candle EA and we are opening trades with the next candle. But maybe I’m wrong. Anny suggestions or corrections of faults are welcome! Thank you! 🙂

    • This reply was modified 7 months, 3 weeks ago by Conmariin Conmariin.
    Attachments:
    You must be logged in to view attached files.
    #197213
    Conmariin
    Participant
    84 Posts

    There was something missing. Sorry. I corrected it in this version. 🙂

    Attachments:
    You must be logged in to view attached files.
    #197239
    Conmariin
    Participant
    84 Posts

    I have a problem with the condition to buy orders.
    I want that the EA is opening an order when following conditions are met:

    (GoLongSandR=true and(Pattern1=true or Pattern2=true or Pattern3=true)

    But it is opening orders when any of theses Patterns are met. It opens when GoLongSandR=true. It opens when Pattern1=true and Pattern3=true (but not GoLongSandR). It opens when only Pattern2=true…etc. For example sometimes it opens correct with GoLongSandR=true and Pattern1=true.
    I attached a picture of my conditionssetting in EAWizard for Long. Where is the error? Can anyone help?

    This is the code from the EA:

    //--------------------------------------
       // Open Long 
       if(sqIsBarOpen == true) {
          if (((sqGetMarketPosition() == 0) 
          && ((GoLongSandR == true) 
          && ((Pattern1Long == true) 
          || ((Pattern2Long == true) 
          || (Pattern3Long == true))))))
          {
          // Action #1
          sqOpenOrder("NULL", OP_BUY, getOrderSize(MagicLong, OP_BUY ), getOrderPrice(MagicLong), Comment1, MagicLong, "Open Long");
    
          // Action #2
          sqDrawUpArrow(1);
          }
       }
       //--------------------------------------
       // Open Short 
       if(sqIsBarOpen == true) {
          if (((sqGetMarketPosition() == 0) 
          && ((GoShortSandR == true) 
          && ((Pattern1Short == true) 
          || ((Pattern2Short == true) 
          || (Pattern3Short == true))))))
          {
          // Action #1
          sqOpenOrder("NULL", OP_SELL, getOrderSize(MagicShort, OP_SELL ), getOrderPrice(MagicShort), Comment2, MagicShort, "Open Short");
    
          // Action #2
          sqDrawDownArrow(1);
          }
       }
    Attachments:
    You must be logged in to view attached files.
    #197256
    Administrator
    519 Posts

    Hello,

    I see in the original file attached you omitted parentheses but on the screenshot you provided they are present (correctly). Attached modified file

    Attachments:
    You must be logged in to view attached files.
    #197258
    Administrator
    519 Posts

    One problem could be you set “pattern” to TRUE but you never set it back to FALSE so the condition will remain always valid.
    I think you should set pattern = FALSE with order entry

    #197259
    Conmariin
    Participant
    84 Posts

    Yes I added the parentheses when I searched the error for this behaviour. And I thought it might be with something is not resettet. But I was unsure. Okay you had the same thought. Now I’m trying to find out how to set the pattern after order entry. Thank you Tomas262! 🙂

    #197277
    Conmariin
    Participant
    84 Posts

    Hi,

    unfortunately I didn’t find out how I can solve this in EAWizard, but I took the code and solved there manually. It was just a 1 Liner in every Pattern condition to set pattern = FALSE. Now it works 🙂

Viewing 7 posts - 31 through 37 (of 37 total)

You must be logged in to reply to this topic.