Sapphire Strat Maker - Mathematical operations (part. V)

Sapphire Strat Maker - Mathematical operations (part. V)

25 March 2024, 19:27
Emanuel Cavalcante Amorim Filho
0
140

1. Introduction


This is the continuation on Sapphire Strat Maker and Sapphire Strat Maker Alt (Free) expert advisor - an EA which allows you to create your own strategy without coding. This is the beauty of this Expert Advisor: create your own strategies - be creative - and don't be locked to a single strategy anymore. Optimize the parameters you want to find the best sets and you're ready to go!


Please, note that some of these features may only be available in the full version.


Before continuing, check out the other blog posts:



Today we are gonna have an insight on the possible mathematical operations - which can be quite useful when defining entry conditions or tp/sl levels.


2. Mathematical operations


A mathematical operation can be applied to a reference value inside a condition block or to a defined tp/sl placement method. The highlighted parameters in the following screenshot show both the inputs that are used when a mathematical operation is defined:



In this example, we see that no mathematical operation ('None' is set to both Math operation to series inputs) is defined for the reference prices at the buy condition block 1. Thus, the Value parameter is completely ignored.


In the next screenshot, on the other hand, we defined the Take Profit type as Distance by Indicator. This means that we fetch a value from the desired indicator buffer/bar. The TP/SL will be defined as the distance between the entry price and the indicator. However, we make use of the operation Mult (*) - as the name implies, a multiplication - at the value of 2.5. This means that the value fetched from the indicator will be multiplied by 2.5, and then the TP/SL will be placed.




Let's say in this example the Indicator 3 (defined in the input [TP-Buy/Sell] Indicator Index) is an Average True Range. In this case, if the buy conditions are met, the EA will enter a long position, while the TP will be set as 2.5 * ATR. If the current ATR at bar 1 is 100, the TP will be placed at 250 above the entry price.


Another valid example is the usage of Highest, Lowest and Average methods. See the next screenshot:



Please, consider the Indicator 2 as an ATR. All this tells the EA is to open both buy/sell position (since it is in the Common Signals group, so it serves to open both types of position) when the Simple Average of the Amplitude (High-Low) of the last 20 candles, starting the count from the bar at index 1, is higher than the ATR at bar 1.

As you can see, the Value parameter refers to the amount of bars in the past to realize the calculation - if the math operation was set to Highest, for example, it would fetch the highest amplitude from the last 20 bars, starting from bar 1. If Bar shift/Fixed value was set to any other value, like 5, the EA would fetch the Simple Average of the last 20, starting from the bar 5 (so, it would calculate the average from the bar 5 to the bar 25).


4. Available mathematical operations and compatibility with price series or TP/SL types


  • Add (+), Sub (-), Mult (-), Div (-): can be applied to any price series.
  • Highest, Lowest and Average: can be applied for any price series, although have no effect for fixed prices, like the Fixed ticks method itself, Distance by Indicator, Price (%), Money, etc., and other TP/SL methods that imply a fixed value.


The ability to apply math to your TP/SL adds an infinity of possibilities to your strategy - just like shown, you can set the TP to a certain multiple of the ATR/StdDev, calculate the mid point of two moving averages, etc.