Other News

Open Buy Trade on Higher Stochastic

Q:

I’d like to open a buy trade if the value of the Stochastic Oscillator of the present bar is higher than the value the Stochastic Oscillator had with the previous bar.

 

How can I get these values?

 

A:

Just use the “shift” parameter to get the correct value – for the current candle, and any other candle.




When you change the shift value, save the function with a new name that makes sense, like “stoch_current”, “stoch_last”, etc.




There is more info on shift here:


http://www.iexpertadvisor.com/what-is-the-metatrader-shift-parameter2/


 


 


Eample for current bar:


 



 Example for Last Fully formed Bar:


 


 Example for value from two bars ago:



You can access these values using the Choose button with your Logic Element to create this Logic:



 The Drawing with Elements will look something like this:


 

 



To get notified about the latest questions and answers, follow us!



RAQ

How to Use a Candle’s Low Value as a StopLoss: 1 Step


 

Q:
I would like to code an EA to close a trade if the price closes below the opening candle Low when each trade was taken.
Also, how can I tell the difference between two open trades.

 

A:
You can set the stoploss to the Low of the opening candle by setting the stoploss value to Low[0] and choosing “Absolute value (price):

  



 

On the advanced tab, you can set the MagicNumber to a special value to distinguish between trades:

 


 

 

There is more info about the MQL MagicNumber here:


 



To get notified about the latest questions and answers, follow us!



RAQ