This is a continuation of my last article on creating the Day Scalper strategy on Visual JForex. To familiarize with what I will be covering read, Day Scalper strategy and automating Day Scalper in VJF Part 1.

In the last article, I developed the strategy up to the separation point of buy and sell signals and so, this article will cover buy and sell entry and trade management.

The image below shows where I stopped in the last article. To the left is the sell side and the right is the buy side.


Getting the Spread

Since there is no function of getting the spread in Visual JForex, I had to create it. Getting the spread is relatively easy; it is the difference between the Ask and the Bid price. To debug the value in pips divide the output by pipsSize. A ‘Calculation Expression’ block is used for this.



Buy Pending Position Rules
  1. Place buy at setup day high + defaultSlippage + spread (candleHigh).
  2. Place the stop loss at setup day low minus defaultSlippage minus spread (candleLow).
To do this, drag ‘Calculation Expression’ blocks to the workspace with the above values. The output should be held in the variables ‘buyPending’ and ‘buyStopLoss’. Refer to the image below.

Note: You have to convert the slippage from pips to a decimal value by multiplying it by pipsScale. If you don’t, the result will be a whole number.



Use a ‘Pending Open’ block to place the buy order as follows. We will be using price for the stop loss, so ensure you change the ‘settings’ field from pips to price. The fields should be:-
  • Buy Stop by Bid
  • Price should be the variable buyPending
  • Stop loss should be the variable buyStopLoss
  • Take profit none
  • Good till time


The image below shows a buy pending order.



Sell Pending Position Rules

The same rules and blocks as for buy order are used but in reverse.
  1. Place a buy at setup day low minus defaultSlippage minus spread (candleLow).
  2. Place the stop loss at setup day low + defaultSlippage + spread (candleHigh).
The output should be held in the variables ‘sellPending’ and ‘sellStopLoss’ as shown below.



Trade Management

This part of the strategy only runs when at least 1 position is open. As a refresher, refer to the image below.


We will attach trade management on the “last trade event is long” Boolean check. I learned from a mistake that leaving this block creates undesirable effects when moving stop loss in JForex. The trade management rules are as follows:

Day 1: Move your stop loss to current day’s low minus spread minus defaultSlippage. This will be the previous day when it clocks 21:01 GMT.
Day 2: If you have made over 100 pips, exit half the position and move stop loss to entry day low minus 5 pips (or minus defaultSlippage minus spread if automating).

Use an ‘if’ block to check if the position profit is over 100pips then close half the position.
The next ‘if’ block should check whether the last bid candle (previous day) is greater than buyStopLoss. If true, move the stop loss to last bid candle minus spread minus defaultSlippage. Use the reverse for a sell position.

Note: The 'Cancel and Close Position' block should flow to the last bid candle 'IF block' whether half the position is closed or not as seen in the image below.



Day Scalper does not use a take profit. It uses a stop loss to lock in profits in a trend until the trend reverses. Closing 50% of the position frees the initial investment that was used. This allows the same money to be used for other trades as I discussed in the first Day Scalper strategy article. It is also proper money management to use dynamic lots that change as your balance grows instead of fixed lots.

I am still working on the final touches of Day Scalper and it will be available on my JStore account after thorough backtesting, optimization and a month on live testing.
Translate to English Show original