Ok groen! you did it! you have posted something on the forum 🙂
So if this the result of a backtest or a real-traded strategy performance? And tell us what is your question?
i want not more loss then 300 a day
this is my code
// Definitie van code parameters
DEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd
DEFPARAM FLATBEFORE=080000
DEFPARAM FLATAFTER=120000
dayprofitmax=1500
daylossmax=300
if intradaybarindex=0 then
trading=1
lastdayprofit=strategyprofit
endif
if trading=1 and (strategyprofit > lastdayprofit+dayprofitmax or strategyprofit < lastdayprofit-daylossmax) then
trading=0
sell at market
exitshort at market
endif
//indi
st = SuperTrend[2.8,3]
//resetting variable
once lasttrade = 0
IF LONGONMARKET then
lasttrade = 1
elsif SHORTONMARKET then
lasttrade = -1
elsif hour<8 OR hour>12 then
lasttrade = 0
endif
// Condities om long posities te openen
IF close>st AND lasttrade<>1 THEN
EXITSHORT AT MARKET
BUY 1 LOT AT MARKET nextbaropen
ENDIF
// Condities om long posities te sluiten
IF close<st AND lasttrade<>-1 THEN
SELL AT MARKET
SELLSHORT 1 lot at market nextbaropen
ENDIF
// Stops en targets
SET STOP $LOSS 150
SET TARGET $PROFIT 1500
Hello groen200, I see that someone else have changed the code a bit since the last time I helped you.
In your code, the “daylossmax” parameter cut only actual trade but do not un-allow new ones to be launched. I think that I solved your problem :
// Definitie van code parameters
DEFPARAM CumulateOrders = False // Opstapelen posities gedeactiveerd
DEFPARAM FLATBEFORE=080000
DEFPARAM FLATAFTER=120000
dayprofitmax=1500
daylossmax=300
if intradaybarindex=0 then
trading=1
lastdayprofit=strategyprofit
endif
if trading=1 and (strategyprofit > lastdayprofit+dayprofitmax or strategyprofit < lastdayprofit-daylossmax) then
trading=0
sell at market
exitshort at market
endif
//indi
st = SuperTrend[2.8,3]
//resetting variable
once lasttrade = 0
IF LONGONMARKET then
lasttrade = 1
elsif SHORTONMARKET then
lasttrade = -1
elsif hour<8 OR hour>12 then
lasttrade = 0
endif
// Condities om long posities te openen
IF close>st AND lasttrade<>1 THEN
EXITSHORT AT MARKET
if trading>0 then
BUY 1 LOT AT MARKET nextbaropen
endif
ENDIF
// Condities om long posities te sluiten
IF close<st AND lasttrade<>-1 THEN
SELL AT MARKET
if trading>0 then
SELLSHORT 1 lot at market nextbaropen
endif
ENDIF
// Stops en targets
SET STOP $LOSS 150
SET TARGET $PROFIT 1500
wp01Participant
Master
Dear Nicolas,
Thank you for the support on this forum.
I’ve also tried your code with the supertrend. I understand that this is for trading with daily bars.
My question is if this code easily can be modified for usage on the 15 or 20 minutes timeframe?
Thanks in advance for your reply.
Regards,
Patrick
Hello wp01,
Since SuperTrend is an indicator that can be traded in any timeframe, this automated trading strategy code can be used for 15 or 20 minutes ones with no problem. This is not my code but a strategy made/submitted by groen200.
As I remember correctly this strategy is already traded by this member in intraday charts, so you can use it as is, or adapt the Supertrend period to the instrument or timeframe you’d like to trade with. Change the period at line 20 :
st = SuperTrend[2.8,3]
wp01Participant
Master
Thanks for the reply Nicolas.
I understand that i can use it in 15 or 20 minutes but I have no idea what to change in line 20.
The System is performing very well , I ‘m using it with one more timesetup e.g from 09:00 – 13:00 with also good results
@wp01
At line 20, you’ll find the Supertrend parameters to adapt, look at the documentation and you’ll understand what I mean : http://www.prorealcode.com/documentation/supertrend/