BCParticipant
Master
I found this strategy via below link and use my limited knowledge translate to PRT robot, please kindly try, comment and feel free modify to fit for your need.
http://www.tradingstrategyguides.com/big-three-trading-str
// Big Three Trading Strategy
// Original Idea from: http://www.tradingstrategyguides.com/big-three-trading-strategy/
// Market: DAX 30
// Time Frame: 1 Hour
// Time Zone: Any
// Spread: 2.9
// Version : V 2.0
defparam preloadbars = 3000
defparam cumulateorders =false //true //false
//// Core Indicator Parameter Setting ////
// Moving Average Setting (Original: 20, 40, 80)
Fast = 20 //
Medium = 40 //
Slow = 80 //
// Look Back Bar (Original: N/A)
CP = 3 // 1-20
//// Optional Function Switch ( 1 = Enable 0 = Disable ) ////
FixedMinMaxStopLoss = 1
TargetProfit = 1
TimeExit = 1
MFETrailing = 1
MoneyManagement = 0
//// Optional Function and Parameter Setting ////
// 1) Fixed Min Max Stop Loss Setting
If FixedMinMaxStopLoss = 1 then
//Long
MaxLong = 80 // 40-100 (90) 80
MinLong = 30 // 5-30 (30) 30
//Short
MaxShort = 60 // 40-100 (50) 60
MinShort = 5 // 5-30 (10) 5
Endif
// 2) Take Profit Setting
If TargetProfit = 1 then
//Long
TakeProfitLongRate = 2.5 // 1-5
//Short
TakeProfitShortRate = 2.5 // 1-5
Endif
// 3) Time Exit Setting
If TimeExit = 1 then
//Long
ONCE maxCandlesLongWithProfit = 78 // 12-120 (72)
ONCE maxCandlesLongWithoutProfit = 66 // 12-72 (72)
//Short
ONCE maxCandlesShortWithProfit = 60 // 12-96 (60)
ONCE maxCandlesShortWithoutProfit = 54 // 12-48 (48)
Endif
// 4) MFE Step Setting
If MFETrailing = 1 then
//Long
MFELongStep = 1.5 // 2-12 2
//Short
MFEShortStep = 1 // 2-12 9
Endif
// 5) Money Management
If MoneyManagement = 1 then
LongRisk = 5 //% 1-5
ShortRisk = 3 //% 1-5
CloseBalanceMaxDrop = 50 //% 30-60
Capital = 2000 //$
Equity = Capital + StrategyProfit
LongMaxRisk = Round(Equity*LongRisk/100)
ShortMaxRisk = Round(Equity*ShortRisk/100)
//Max Contract
MaxLongContract = 500 // 50-100 (1000)
MaxShortContract = 100 // 10-50 (200)
//Check system account balance
If equity<QuickLevel then
Quit
Endif
RecordHighest = MAX(RecordHighest,Equity)
QuickLevel = RecordHighest*((100-CloseBalanceMaxDrop)/100)
Endif
// Core indicator
//Big Three MA
FMA = Average[Fast](close) //green coloured(0,255,0)
MMA = Average[Medium](close)//blue coloured(0,0,255)
SMA = Average[Slow](close)//red coloured(255,0,0)
// Entry Rules
//Buy Signal
B1 = low > SMA and low>MMA and low>FMA
B2 = high >= highest[CP](high)
BC = B1 and B2
//Buy Candle
BC1 = Close[1] < Close[2]
BC2 = Close > Close[1]
BC3 = Close > Open
BCandle = BC1 and BC2 and BC3
//Sell Signal
S1 = high < FMA and high<MMA and high<SMA
S2 = low <= lowest[CP](low)
SC = S1 and S2
//Sell Caandle
SC1 = Close[1] > Close[2]
SC2 = Close < Close[1]
SC3 = Close < Open
SCandle = SC1 and SC2 and SC3
// Exit Rules
LongExit = Close crosses under SMA
ShortExit = Close crosses over SMA
//Long Entry
If BC and BCandle then
BuyPrice = Close
If FixedMinMaxStopLoss = 1 then
StopLossLong = MIN(MaxLong,MAX(MinLong,(BuyPrice - SMA)))
Else
StopLossLong = BuyPrice - SMA
Endif
If TargetProfit = 1 then
TakeProfitLong = StopLossLong * TakeProfitLongRate
TakeProfit = TakeProfitLong
Endif
If MoneyManagement = 1 then
PositionSizeLong = min(MaxLongContract,(max(1,abs(round((LongMaxRisk/StopLossLong)/PointValue)*pipsize))))
BUY PositionSizeLong CONTRACT AT MARKET
Else
BUY 1 CONTRACT AT MARKET
Endif
Endif
//Long Exit
If LongonMarket and LongExit then
sell at market
Endif
//short entry
If SC and SCandle then
SellPrice = Close
If FixedMinMaxStopLoss = 1 then
StopLossShort = MIN(MaxShort,MAX(MinShort,(SMA - SellPrice)))
Else
StopLossShort = SMA - SellPrice
Endif
If TargetProfit = 1 then
TakeProfitShort = StopLossShort * TakeProfitShortRate
TakeProfit = TakeProfitShort
Endif
If MoneyManagement = 1 then
PositionSizeShort = min(MaxShortContract,(max(1,abs(round((ShortMaxRisk/StopLossShort)/PointValue)*pipsize))))
SELLSHORT PositionSizeShort CONTRACT AT MARKET
Else
SELLSHORT 1 CONTRACT AT MARKET
Endif
Endif
//Short Exit
If ShortonMarket and ShortExit then
exitshort at market
Endif
// Time Exit
If TimeExit = 1 then
If LongonMarket then
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
elsif ShortonMarket then
posProfit = (((positionprice - close) * pointvalue) * countofposition) / pipsize
Endif
m1 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfit
// take profit after max candles
IF LONGONMARKET AND (m1 OR m3) THEN
sell at market
endif
IF SHORTONMARKET AND (m2 OR m4) THEN
exitshort at market
endif
Endif
//MFE Trailing stop
If MFETrailing = 1 then
MFELong = (TakeProfitLong/MFELongStep)
MFEShort = (TakeProfitShort/MFEShortStep)
If not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
Endif
If longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
If MAXPRICE-tradeprice(1)>=MFELong*pointsize then
priceexit = MAXPRICE-MFELong*pointsize
Endif
Endif
If shortonmarket then
MINPRICE = MIN(MINPRICE,close)
If tradeprice(1)-MINPRICE>=MFEShort*pointsize then
priceexit = MINPRICE+MFEShort*pointsize
Endif
Endif
If onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
Endif
Endif
// Stop Loss
if LongonMarket then
SET STOP LOSS StopLossLong
endif
if ShortonMarket then
SET STOP LOSS StopLossShort
endif
// Target Profit
If TargetProfit = 1 then
SET TARGET PROFIT TakeProfit
Endif
//graph BuyPrice
//graph SellPrice
//graph StopLossLong
//graph StopLossShort
interesting strategy but seems pretty flat the last months? Hows your trading been with this? running in demo/live?
BCParticipant
Master
No, I don’t trade with this robot.
Aw okay, well, it seems pretty flat for now. But it has been relatively stable up until this point, so might as well add to demo and see where it goes 🙂
Thank you Bin, nice one. In order to get the complete view of it, what are the variables optimized? Did you try WFA on any other instrument?
This one could probably be a part of the library, can I post it there for you?
BCParticipant
Master
Mainly on CP and test with DAX, I try HS but no good result.
It’s my pleasure to post at library. THX.
Thank you Bin for the strategy. I like the neat and modular approach to your coding and hope you don’t mind me cutting and pasting so that I may use some of it in future ideas of my own!
As for being flat for the last few months…. it is a trend following strategy and markets haven’t really known which way to go recently with all the political turmoil so it is not really surprising to me that a trend reliant strategy has gone a bit flat.
Great work – thanks.
BCParticipant
Master
Hi Nicolas
Please kindly post this latest version to library with detailed remark which variables were optimized and their unit. THX.
// Big Three Trading Strategy
// Original Idea from: http://www.tradingstrategyguides.com/big-three-trading-strategy/
// Market: DAX 30
// Time Frame: 1 Hour
// Time Zone: Any
// Spread: 2.9
// Version : 2.8
// Revised on 2017-11-14
Defparam preloadbars = 3000
Defparam cumulateorders =false //true //false
//// Optional Function Switch ( 1 = Enable 0 = Disable ) ////
FixedMinMaxStopLoss = 1 // Optional Function 1
TargetProfit = 1 // Optional Function 2
TimeExit = 1 // Optional Function 3
MFETrailing = 1 // Optional Function 4
MoneyManagement = 0 // Optional Function 5
//// Core Indicator Parameter Setting ////
// Moving Average Setting (Original: 20, 40, 80)
Fast = 20 // Not Optimize
Medium = 40 // Not Optimize
Slow = 80 // Not Optimize
// Look Back Bar (Original: N/A)
CP = 3 // Variables Optimized
//// Optional Function ////
// 1) Fixed Min Max Stop Loss Setting
If FixedMinMaxStopLoss then
//Long
MaxLong = 80 // by points, Variables Optimized
MinLong = 30 // by points, Variables Optimized
//Short
MaxShort = 60 // by points, Variables Optimized
MinShort = 5 // by points, Variables Optimized
Endif
// 2) Take Profit Setting
If TargetProfit then
//Long
TakeProfitLongRate = 2.6 // by %, Variables Optimized
//Short
TakeProfitShortRate = 2.5 // by %, Variables Optimized
Endif
// 3) Time Exit Setting
If TimeExit then
//Long
ONCE maxCandlesLongWithProfit = 78 // by bar, Variables Optimized
ONCE maxCandlesLongWithoutProfit = 66 // by bar, Variables Optimized
//Short
ONCE maxCandlesShortWithProfit = 60 // by bar, Variables Optimized
ONCE maxCandlesShortWithoutProfit = 54 // by bar, Variables Optimized
Endif
// 4) MFE Step Setting
If MFETrailing then
//Long
MFELongStep = 1.5 // by %, Variables Optimized
//Short
MFEShortStep = 1 // by %, Variables Optimized
Endif
// 5) Money Management
If MoneyManagement then
LongRisk = 5 // by %, Variables Optimized
ShortRisk = 3 // by %, Variables Optimized
CloseBalanceMaxDrop = 50 // by %, Personal preference
Capital = 3000 // by $
Equity = Capital + StrategyProfit
LongMaxRisk = Round(Equity*LongRisk/100)
ShortMaxRisk = Round(Equity*ShortRisk/100)
//Max Contract
MaxLongContract = 500 // by contract, Variables Optimized
MaxShortContract = 100 // by contract, Variables Optimized
//Check system account balance
If equity<QuitLevel then
Quit
Endif
RecordHighest = MAX(RecordHighest,Equity)
QuitLevel = RecordHighest*((100-CloseBalanceMaxDrop)/100)
Endif
// Core indicator
//Big Three MA
FMA = Average[Fast](close) //green coloured(0,255,0)
MMA = Average[Medium](close) //blue coloured(0,0,255)
SMA = Average[Slow](close) //red coloured(255,0,0)
// Entry Rules
//Buy Signal
B1 = low > SMA and low>MMA and low>FMA
B2 = high >= highest[CP](high)
BC = B1 and B2
//Buy Candle
BC1 = Close[1] < Close[2]
BC2 = Close > Close[1]
BC3 = Close > Open
BCandle = BC1 and BC2 and BC3
//Sell Signal
S1 = high < FMA and high<MMA and high<SMA
S2 = low <= lowest[CP](low)
SC = S1 and S2
//Sell Candle
SC1 = Close[1] > Close[2]
SC2 = Close < Close[1]
SC3 = Close < Open
SCandle = SC1 and SC2 and SC3
// Exit Rules
LongExit = Close crosses under SMA
ShortExit = Close crosses over SMA
//Long Entry
If Not LongonMarket and BC and BCandle then
BuyPrice = Close
If FixedMinMaxStopLoss then
StopLossLong = MIN(MaxLong,MAX(MinLong,(BuyPrice - SMA)))
Else
StopLossLong = BuyPrice - SMA
Endif
If TargetProfit then
TakeProfitLong = StopLossLong * TakeProfitLongRate
TP = TakeProfitLong
Endif
SL = StopLossLong
If MoneyManagement then
PositionSizeLong = min(MaxLongContract,(max(2,abs(round((LongMaxRisk/StopLossLong)/PointValue)*pipsize))))
BUY PositionSizeLong CONTRACT AT MARKET
Else
BUY 2 CONTRACT AT MARKET
Endif
Endif
//Long Exit
If LongonMarket and LongExit then
sell at market
Endif
//short entry
If Not ShortonMarket and SC and SCandle then
SellPrice = Close
If FixedMinMaxStopLoss then
StopLossShort = MIN(MaxShort,MAX(MinShort,(SMA - SellPrice)))
Else
StopLossShort = SMA - SellPrice
Endif
If TargetProfit then
TakeProfitShort = StopLossShort * TakeProfitShortRate
TP = TakeProfitShort
Endif
SL = StopLossShort
If MoneyManagement then
PositionSizeShort = min(MaxShortContract,(max(2,abs(round((ShortMaxRisk/StopLossShort)/PointValue)*pipsize))))
SELLSHORT PositionSizeShort CONTRACT AT MARKET
Else
SELLSHORT 2 CONTRACT AT MARKET
Endif
Endif
//Short Exit
If ShortonMarket and ShortExit then
exitshort at market
Endif
// Time Exit
If TimeExit then
If LongonMarket then
posProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsize
elsif ShortonMarket then
posProfit = (((positionprice - close) * pointvalue) * countofposition) / pipsize
Endif
m1 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithProfit
m2 = posProfit > 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithProfit
m3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfit
m4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfit
// take profit after max candles
IF LONGONMARKET AND (m1 OR m3) THEN
sell at market
endif
IF SHORTONMARKET AND (m2 OR m4) THEN
exitshort at market
endif
Endif
//MFE Trailing stop
If MFETrailing then
MFELong = (TakeProfitLong/MFELongStep)
MFEShort = (TakeProfitShort/MFEShortStep)
If not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
Endif
If longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
If MAXPRICE-tradeprice(1)>=MFELong*pointsize then
priceexit = MAXPRICE-MFELong*pointsize
Endif
Endif
If shortonmarket then
MINPRICE = MIN(MINPRICE,close)
If tradeprice(1)-MINPRICE>=MFEShort*pointsize then
priceexit = MINPRICE+MFEShort*pointsize
Endif
Endif
If onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
Endif
Endif
// Stop Loss a
SET STOP LOSS SL
// Target Profit
If TargetProfit then
SET TARGET PROFIT TP
Endif
//graph BuyPrice
//graph SellPrice
//graph StopLossLong
//graph StopLossShort
I downloaded the itf of v2 and notice that tick by tick data is not selected. Results are terrible once tick by tick data is used!
BCParticipant
Master
Hi Vonasi
Tick by tick back test screen shot attached. I don’t suggest play this robot with real money, just for study purpose. THX.