Not logged in
Viewing 4 posts - 1 through 4 (of 4 total)

Forums>AlgoWizard / EA Wizard>Application Support>change of value of parameters

  • #111615 |
    Participant
    18 Posts

    I have an initial value of a certain parameter DS set to be 5 (input)) when the EA starts. After the closing of some trades, DS is increased to 10. But it appears that this new value has not replaced the original value of DS when the EA restarts. For example,

    Input:  DS=5;

     

    Rule 1:

    PU= Open (0) + ConvetToRealPips(DS)

     

    After many rules:

    Close all orders

    DS=DS+5

     

    So the new value of DS is now 10, But DS is found to be still <=5 in Rule 1 when the EA restarts (returns to Rule 1).

     

    Why? Is there a solution to this problem?

     

    #122729
    Mark Fric
    Administrator
    1182 Posts

    when you restart an EA, it will forget all the values that were stored in memory and it will use default values again.

    There’s no easy solution for it, it simply works like this.

     

    The only way to keep some previous values from before EA restart would be to save it to a file and then load it again.

     

    Or you can try to recognize DS from your orders – for example if you use different size with each order you can use the size of actual order to recognize what DS value was used last time.

     

    Mark

    Mark
    StrategyQuant architect

    #122733
    Participant
    18 Posts

    How can you remember the size of the last order, you mention above that all values that were stored in memory are erased once you restart an EA?

    #122751
    Mark Fric
    Administrator
    1182 Posts

    you cannot remember value of last order, but you can get it from orders history.

     

    Just add this function to the end of {EA Wizard}/code/CustomFunctions.mq4 file:

     

    double sqGetLastPositionSize(int orderMagicNumber) {
       for(int i=OrdersHistoryTotal(); i>=0; i–) {
          if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true && OrderSymbol() == Symbol()) {
             if(orderMagicNumber == 0 || OrderMagicNumber() == orderMagicNumber) {
                return(OrderLots());
             }
          }
       }
     
       return(0);
    }

     

    Then you can use it in conditions by calling Custom Function : sqGetLastPositionSize(YourMagicNumber)

     

    Mark

    Mark
    StrategyQuant architect

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.