This scalping strategy is based on the concept of following a coin flip randomized approach to picking market direction and then simply managing the trade according to a Risk:Reward ratio of 1:2. The strategy also has equity curve management built-in to help optimize performance.
The direction of the trade is randomly determined based on the fact that at any given point the direction of a candle will be either be red or green. The algorithm used will pick an historic candle between 1 and 5 bars back and use this as a binary coin flip to determine direction.
Stoploss distance is determined dynamically through the use of a smoothed ATR and Take Profit is simply twice the Stoploss distance.
DEFPARAM CUMULATEORDERS = FALSE
CurvePeriod = 90
Type = 0
Capital = 10000
Equity = Capital + StrategyProfit
EquityCurve = Average[CurvePeriod,Type](Equity)
If hour >= 9 and hour <= 22 Then
possize = 1
Else
possize = 0
If longonmarket Then
Sell at market
ElsIf shortonmarket Then
Exitshort at market
EndIf
EndIf
once RX = 1
once SV = 1
If RX > 5 Then
If SV > 5 Then
SV = 2
EndIf
RX = RX-SV
If RX <=0 Then
SV = 2
EndIf
Else
RX = RX + 2
SV = SV + 1
EndIf
once dir = 0
If dir = 0 and close[RX] > open[RX] Then
dir = 1
ElsIf dir = 1 and close[RX] < open[RX] Then
dir = 0
EndIf
//GRAPH RX coloured(255,0,0) AS "RX"
//GRAPH SV coloured(255,0,255) AS "SV"
//GRAPH DIR AS "DIR"
If countofposition = 0 and (barindex < curveperiod or (barindex > curveperiod and equity >= equitycurve)) and dir = 0 Then
Buy possize contract at market
ElsIf countofposition = 0 and (barindex < curveperiod or (barindex > curveperiod and equity >= equitycurve)) and dir = 1 Then
Sellshort possize contract at market
EndIf
SL = ((average[20](range)+1.2*STD[20](range))*100000)
SET STOP pLOSS SL*possize
SET TARGET pPROFIT SL*2*possize
Thank you Juanj, interesting concept 🙂 I move your post submission from the Library to the forum, because I’m not able to replicate the same interesting result on my side. Do you know why?
Hi Nicolas, maybe it is the way prices are quoted on your system.
Change the multiplication factor on line 55, start removing zeros until you get the same result as me.
SL = ((average[20](range)+1.2*STD[20](range))*100000)
@Nicolas or it could be due to our time zone difference, so you can try changing line 10 to:
If hour >= 8 and hour <= 21 Then
But can’t think it would have such large effect. The strategy if adjusted for timezone differences is profitable on multiple markets that I have tested.
LeoParticipant
Veteran
This concept interesting, what is your opinions about: trend is your friend, follow the SMA200 , bla bla Bla?
can you please post a pic of the values RX and SV, why you are saying is random? Looks pretty deterministic for me.
In your fuction for ATR, you can use the function “pipsize”
Cheers
@juanj
Better, but still not as good as your own test.. with or without spread.. I don’t understand why. Do anybody get the same result as juanj?
@Leo
Did you test the code? You can decomment lines 45 and 46 to get the RX and SV values on your own screen 🙂
@Leo, yes I do believe trading with the 200SMA is a good idea athough for this specific strategy I did not want to add a trend bias. I consider the trade direction random, because if you GRAPH DIR you will not see any recognizable pattern.
@Nicolas, I cannot understand your result. I tested with a spread of 0.8, maybe see if that makes the difference.
Attached is the exact same algorithm on the AUDUSD tested with a spread of 1 and trading time of 2-19 (GMT), you need to adjust for GMT+1
Same spread and GMT+1, tick mode, no same result! Can someone else confirm?
This is my result. Looks like Nicolas.
I´m GMT+1 but it dosen´t matter how I change the time in the code, I still get bad results.
I realize now that because the direction is technically random the result will never be exactly the same as the starting point is always different.
Yet the results should still not differ much. Will back test in my demo account to see if there is a difference.
LeoParticipant
Veteran
The system is chaotically in a pure sense. Slight difference in input cause totally different results.
Very interesting approach in any case.
LeoParticipant
Veteran
I am not at home at the moment, but I still thinking in your concept @juanj. Many authors can be agreed that invest in finantial markets is like flipping a coin.
Therefore, try the same with some bias or another conditions,
-momentum Like: ” close[RX] > Close”
– a filter like for entry long, price should be avobe a parabolic SAR.
Did you try another reward ratio like 1.5 or 3 ?
Cheers
LeoParticipant
Veteran
Here my test.
I will start experimenting
LeoParticipant
Veteran
Hi,
I tried several things but still not being profitable.
I tried: parabolic SAR and momentum and pending ordes
Hope you get some other ideas
DEFPARAM CUMULATEORDERS = FALSE
DEFPARAM PreLoadBars = 10000
possize=1
once RX = 1
once SV = 1
If RX > 5 Then
If SV > 5 Then
SV = 2
EndIf
RX = RX-SV
If RX <=0 Then
SV = 2
EndIf
Else
RX = RX + 2
SV = SV + 1
EndIf
dir = 0
if not onmarket and hour >= 7 and hour <= 21 then
If close[RX] > open[RX] Then
dir = 1
ELSE
dir = -1
EndIf
ENDIF
//GRAPH RX coloured(255,0,0) AS "RX"
//GRAPH SV coloured(255,0,255) AS "SV"
//GRAPH DIR AS "DIR"
SL = average[20](range)+2*STD[20](range)
SL = SL/pipsize
MySAR= SAR[0.02,0.02,0.2]
If not longonmarket and dir = 1 and close > mySAR and close>close[RX] Then
Buy possize contract at high+2*pipsize stop
SET STOP pLOSS SL
SET TARGET pPROFIT 3*SL
ENDIF
If not shortonmarket and dir = -1 and close <mySAR and close<close[RX] Then
Sellshort possize contract at low-2*pipsize stop
SET STOP pLOSS SL
SET TARGET pPROFIT 3*SL
EndIf
If longonmarket Then
if hour <= 7 or hour >= 22 Then
Sell at market
ENDIF
If close crosses under mySAR then
Sell at market
ENDIF
ENDIF
If shortonmarket Then
if hour <= 7 or hour >= 22 Then
Exitshort at market
EndIf
If close crosses over mySAR then
Sell at market
ENDIF
EndIf
Hi,
I just studied this strategy whose concept is very interesting.
However, it is not profitable such as with a TF 1min on a full day.
So I set up a trading limit and go out every day with a gain.
To optimize the number of trades per day, I’m spending on an 18s TF.
The results are positive over a period of 20,000 units (impossible to go beyond, with a TF of 18s there is no more history)
I give you my version below. I look forward to your comments.