Q: I like to setup one condition that if Price per tick is arising or falling not to open buy / sell position.
The question is how can I define a falling or rising price per tick?
A: You just need to store the price value on each tick, and compare it to the last value. The trick is to compare the value before storing it. (Actually there are 2 tricks, keep reading to learn). Here are the steps:
Drag and drop a Variable of type double, name it something logical, in this case, I chose “lastAsk”. In the Assignment tab, enter the price value. For tick values, use Ask or Bid, but it could be any MQL price value.
Next, drap and drop a Logic Element, I named this one “IsAskGreater”. Here is the 2nd trick: Add a conditon to test for lastAsk to not be zero, because the first time the EA runs, lastAsk will be 0 – and the next price will always be greater. This would lead to false signals when you first attach your EA.
Add another condition to check if the current Ask price is greater than the last Ask price.
Now the elements of the Drawing can be connected. Note the numbering of the links to control the order of execution. To number a link, double-click the link to edit the Link Number dialog:
The link to test the value should be #1, and the link to store the value should be #2. Here is the drawing:
To get notified about the latest questions and answers, follow us!