Hi, that’s right Nicolas I only optimised the variables above with an IN/OUT sample until beginning 2014 with 200k units (sorry don’t have exact date) The only other addition was the pprofit at the end of the code as it improved things slightly. This is really optional and doesn’t change equity curve/profit that much.
@Smurfy I’m sorry but not sure why you don’t get any trades. Have you adjusted time zones in PRT options as well and they are conflicting?
Hi Nicolas! Long vacation for me. I hope also for you!
Actually.. we can optimize also time 😉
@smurfy
You need to adapt the parameters accordingly to the instrument you trade. For forex pairs, you have to convert the whole points parameters to the instrument pipsize by multiplying all of them by “pipsize”.
@david
There is no vacation for the braves! 🙂
Hi Cosmic,
I’m not very sure. I basically just copied your EURUSD copy and make the changes on the timezone that’s all.
however I couldn’t get any trades.
by the way, how do we backtest with a bigger date range? I noticed I couldn’t get it even I specify the date range.
@smurfy
These 3 variables need to be adapted to forex digits with pipsize information, like this:
MaxAmplitude = 85 * pipsize
MinAmplitude = 9 * pipsize
OrderDistance = 0 * pipsize
Gosh Sir Nicolas,
I think I’m totally lost in entire coding here. I don’t understand at all how it works.. 🙁
any kind souls can explain on the MaxAmplitude why is it 85 and need to multiply pipsize?
entire strategy is to look at what portion then perform what? So sorry Im really a newbie and super blur…
Because the strategy was first intended to be traded on french CAC40 in points.
MaxAmplitude = 85, means for example 4200 + 85 = 4285 points
But in forex, you got 5 digits and 1 point/1 pip is equal to 0.0001 (EUR/USD pipsize for example)
So if you want to trade it on forex, you need to adapt these values.
Hi Nicolas,
let me digest on this. but the problem is I copied the EURUSD code in this thread and not getting results. Also, I cannot backtest with the dates. Seems like I need to see the dates on the Chart before backtesting can work.
This weekend I will test again.
thanks!
@Cosmic1
Did you launch it in demo at least Cosmic? I mean, it would have its place into the Library, if you are ok to post it there!
This is my version. I traded it for a while live, but recently I switched completely.
And I changed the Stop Loss Level.
//Dax 15min 1.2 SPread
// We do not store datas until the system starts.
// If it is the first day that the system is launched and if it is afternoon,
// it will be waiting until the next day for defining sell and buy orders
DEFPARAM PreLoadBars = 0
// Position is closed at 7h45 PM, frenh time (in case of CAC40 trading)
DEFPARAM FlatAfter = 173000
// No new posit5ion will be initiated after the 5h00 PM candlestick
LimitHour = 171500
// Market scan begin with the 15 minute candlestick that closed at 9h15 AM
StartHour = 091500
// The 24th and 31th days of December will not be traded because market close before 7h45 PM
IF (month=3 and day=28) or (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THEN
TradingDay = 0
ELSE
TradingDay = 1
ENDIF
// Variables that would be adapted to your preferences
if time = 084500 then
PositionSize = 1
// max(1,1+ROUND((strategyprofit-1000)/1000))
//constant trade volume over the time
endif
MaxAmplitude = 120
MinAmplitude = 30
OrderDistance = 6
PourcentageMin = 26
// Variable initilization once at system start
ONCE StartTradingDay = -1
// Variables that can change in intraday are initiliazed
// at first bar on each new day
IF (Time <= StartHour AND StartTradingDay <> 0) OR IntradayBarIndex = 0 THEN
BuyTreshold = 0
SellTreshold = 0
BuyPosition = 0
SellPosition = 0
StartTradingDay = 0
ELSIF Time >= StartHour AND StartTradingDay = 0 AND TradingDay = 1 THEN
// We store the first trading day bar index
DayStartIndex = IntradayBarIndex
StartTradingDay = 1
ELSIF StartTradingDay = 1 AND Time <= LimitHour THEN
// For each trading day, we define each 15 minutes
// the higher and lower price value of the instrument since StartHour
// until the buy and sell tresholds are not defined
IF BuyTreshold = 0 OR SellTreshold = 0 THEN
HighLevel = Highest[IntradayBarIndex - DayStartIndex + 1](High)
LowLevel = Lowest [IntradayBarIndex - DayStartIndex + 1](Low)
// Spread calculation between the higher and the
// lower value of the instrument since StartHour
DaySpread = HighLevel - LowLevel
// Minimal spread calculation allowed to consider a significant price breakout
// of the higher and lower value
MinSpread = DaySpread * PourcentageMin / 100
// Buy and sell tresholds for the actual if conditions are met
IF DaySpread <= MaxAmplitude THEN
IF SellTreshold = 0 AND (Close - LowLevel) >= MinSpread THEN
SellTreshold = LowLevel + OrderDistance
ENDIF
IF BuyTreshold = 0 AND (HighLevel - Close) >= MinSpread THEN
BuyTreshold = HighLevel - OrderDistance
ENDIF
ENDIF
ENDIF
// Creation of the buy and sell orders for the day
// if the conditions are met
IF SellTreshold > 0 AND BuyTreshold > 0 AND (BuyTreshold - SellTreshold) >= MinAmplitude THEN
IF BuyPosition = 0 THEN
IF LongOnMarket THEN
BuyPosition = 1
ELSE
BUY PositionSize CONTRACT AT BuyTreshold STOP
ENDIF
ENDIF
IF SellPosition = 0 THEN
IF ShortOnMarket THEN
SellPosition = 1
ELSE
SELLSHORT PositionSize CONTRACT AT SellTreshold STOP
ENDIF
ENDIF
ENDIF
ENDIF
// Conditions definitions to exit market when a buy or sell order is already launched
IF LongOnMarket AND ((Time <= LimitHour AND SellPosition = 1) OR Time > LimitHour) THEN
SELL AT SellTreshold STOP
ELSIF ShortOnMarket AND ((Time <= LimitHour AND BuyPosition = 1) OR Time > LimitHour) THEN
EXITSHORT AT BuyTreshold STOP
ENDIF
// Maximal risk definition of loss per position
// in case of bad evolution of the instrument price
SET STOP PLOSS (BuyTreshold - SellTreshold)
//SET TARGET pprofit 180
@flowsen123 Looks good, I will take a look later. Did you avoid cure fitting?
@smurfy The code that I posted here does work on demo and live. I ran it for two days to make sure and it works as expected without making any modifications or adding * pipsize so I really don’t know what is happening with yours not working. Maybe a call to IG, PRT or both?
@Nicolas I am actually happier posting the DAX one as I have used on demo and live with good results. I am still playing with EUR/USD and analysing. Just submitted DAX to you 🙂
Hi Cosmic,
mind if you provide me the coding for EURUSD and teach me how to change it to USDJPY?
I give up.. lolx…. I can’t figure out at all. Perhaps if you set as EURUSD I can figure out more.
hope you don’t mind.
Cheers!
Thread resurrection!
I would really like to get these algo’s running again but they have performed poorly since posting to the library, despite my best efforts to avoid curve fitting etc…
I have tried a re opp of the most recent years / months but not really much joy.
Any ideas from you guys? Thoughts?
https://www.prorealcode.com/prorealtime-trading-strategies/dow-breakout-15min/
https://www.prorealcode.com/prorealtime-trading-strategies/breakout-dax-15min/
Hi Cosmic, naturally this algorithm works will in trending markets and as you may have seen recently, not so well in sideways markets. I have reversed the buy/sell commands (effectively trading support/resistance reversals) and the algo does well over the recent sideways period. Now for the million dollar question, how do you determine if the market is trending?
Has anyone done any work in determining trending strength (possibly using rate of change of ADX) and possibly looked at feeding this into this algo?
Yes, I tried something similar myself but without a lot of confidence. What is the code you are running for reversed?