Thanks Peter & Roberto, when I run that code no trades get activated.
Im trying to develop a scalping strategy but struggling with the code.
I want to enter a long position if the change of price is 4 points within 1 minute tf bar, the trade must then be executed immediately on the 1 second tf, So immediate if it reached +4 points in 1 minutetf point it must buy.
The TP will be 1 points and the SL will be 1 points after activation.
I want to enter a short position if the change of price is -4 points within 1 minute tf bar, the trade must then be executed immediately on the 1 second tf, So immediate if it reached -4 points in 1 minute tf point it must sell.
The TP will be 1 points and the SL will be 1 points after activation.
<span style=”text-decoration: underline;”>The code from the PRT simplifier looks likes this:</span>
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = close-close[1]
c1 = (indicator1 >= 4)
IF c1 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
indicator2 = close-close[1]
c2 = (indicator2 <= -4)
IF c2 THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 1
SET TARGET pPROFIT 1
The problem with this code is that it then executes the trade on the next 1 minute bar which by then is too late and the trade is a loss, as it does not allow for MTF.
The image attached at point 1 shows 4 point change (where i want to buy) and it went beyond 5 points (where i want to exit long at 5 point). Point 2 shows -4 point change (where i want to short) and it went beyond 5 points (where i want to exit long at 5 points).
So I would scalp 1 pont at each of these positions
How will that code look?