Like a WHEN function

To add comments, please log in or register
godinho25
12
godinho25  

hi!

i know that a WHEN function doesn't exists on MQ4, so I tried to do something like this:

if(SelectLastOrder() && OrderProfit() < 0 && ((Ask - Bid * myPoint) <= MaxSpread) && _current_martingale_level < MM_Martingale_MaxLevel) { 
if(OrderType()==OP_BUY)
if (iCustom(NULL,PERIOD_M1,"F",0,0)>F_buy)
BuyMartingale(); 
else
if (iCustom(NULL,PERIOD_M1,"F",0,0)<F_sell)
SellMartingale();

The martingale was working properly until I made the changes in red.

Where F is an indicator.

however if the F indicator doesn't have the right value, the EA forgets to make the martingale afterwards...

Do you have any ideas?

whroeder1
17944
whroeder1  
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Do you really expect an answer? Do you really expect us to know what "F" is? What the right value is? Or if it even creates a value on bar zero? There are no mind readers here and our crystal balls are cracked.

  3. Martingale, guaranteed to blow your account eventually.
godinho25
12
godinho25  
whroeder1:
  1. Why did you post your MT4 question in the Root / MT5 General section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. Do you really expect an answer? Do you really expect us to know what "F" is? What the right value is? Or if it even creates a value on bar zero? There are no mind readers here and our crystal balls are cracked.

  3. Martingale, guaranteed to blow your account eventually.

Sorry about the place I post it. My mistake.


about my question:

the F indicator isn't the issue or even the value. Instead the f_buy suppose there's a 0, and doesn't matter the indicator. My question is, there's any kind of funcion or code, that forces the EA to "wait", without "forgetting" some variable to act?

whroeder1
17944
whroeder1  
godinho25: any kind of funcion or code, that forces the EA to "wait", without "forgetting" some variable to act?

Save it in a global or static variable. Return from OnTick, wait for the next tick.

To add comments, please log in or register