Reply

change of value of parameters

3 replies

chengsmine

Subscriber, bbp_participant, community, 42 replies.

Visit profile

10 years ago #111615

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?

 

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #122729

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

0

chengsmine

Subscriber, bbp_participant, community, 42 replies.

Visit profile

10 years ago #122733

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?

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

10 years ago #122751

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

0

Viewing 3 replies - 1 through 3 (of 3 total)