ProRealCode - Trading & Coding with ProRealTime™
//-------------------------------------------------------------------------
// Main code : Elsborgtrading 5magics DAX5min
//-------------------------------------------------------------------------
REM Elsborgtrading Ichimoku
defparam cumulateorders=false
defparam preloadbars=200
defparam preloadbars=2000
defparam flatbefore=090000
defparam flatafter=220000
//ONCE Crosslow=0
//ONCE Crosshigh=0
ONCE Tenkansen=0
ONCE Kijunsen=0
ONCE SenkouSpanA=0
ONCE SenkouSpanB=0
ONCE TreBarsAbove=0
ONCE TreBarsBelow=0
ONCE TenkansenBelow=0
ONCE KijunsenBelow=0
ONCE ChikouBelow=0
//REM Money Management
Capital = 1000
Risk = 0.01
StopLoss = 10 // Could be our variable X
// Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//If PositionSize>100 then
//PositionSize=100
//endif
Tenkansen = (highest[9](high)+lowest[9](low))/2
Kijunsen = (highest[26](high)+lowest[26](low))/2
SenkouSpanA = (Tenkansen[26]+Kijunsen[26])/2
SenkouSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
Chikou = close[26]
// buy
//TreBarsAbove = close[3] > SenkouSpanA and close[3] > SenkouSpanB and close[2] > SenkouSpanA and close[2] > SenkouSpanB and close > SenkouSpanA and close > SenkouSpanB and close[3]<Close[2] and Close[2]<Close //REM does not test for 3 bullish candle
//TreBarsAbove = close[3] > SenkouSpanA and close[3] > SenkouSpanB and close[2] > SenkouSpanA and close[2] > SenkouSpanB and close > SenkouSpanA and close > SenkouSpanB and close[3]<Close[2] and Close[2]<Close and open[3]<close[3] and open[2]<close[2] and open<close //REM test for 3 bullish candle
//TreBarsAbove = close[2] > SenkouSpanA and close[2] > SenkouSpanB and close > SenkouSpanA and close > SenkouSpanB and Close[2]<Close and open[2]<close[2] and open<close // REM test for only 2 bullish candles above
TreBarsAbove = close[3] > SenkouSpanA and close[3] > SenkouSpanB and close[2] > SenkouSpanA and close[2] > SenkouSpanB and open[1] > SenkouSpanA and open[1] > SenkouSpanB and close[3]<Close[2] and medianprice[2]<open[1] and open[3]<close[3] and open[2]<close[2] and open[1]>medianprice[2] // REM test med open candle3
//Crosshigh = Tenkansen crosses over Kijunsen: NOT USED
TenkansenAbove = Tenkansen > SenkouSpanA and Tenkansen > SenkouSpanB
KijusenAbove = Kijunsen > SenkouSpanA and Kijunsen > SenkouSpanB
ChikouAbove = Chikou > SenkouSpanA[26] and Chikou > SenkouSpanB[26]
IF TreBarsAbove and TenkansenAbove and KijusenAbove and ChikouAbove THEN
BUY PositionSize CONTRACTS AT MARKET
ENDIF
// Sell
//TreBarsBelow = close[3] < SenkouSpanA and close[3] < SenkouSpanB and close[2] < SenkouSpanA and close[2] < SenkouSpanB and close < SenkouSpanA and close < SenkouSpanB and close[3]>Close[2] and Close[2]>Close //REM does not test for 3 bearish candle
//TreBarsBelow = close[3] < SenkouSpanA and close[3] < SenkouSpanB and close[2] < SenkouSpanA and close[2] < SenkouSpanB and close[1] < SenkouSpanA and close[1] < SenkouSpanB and close[3]>Close[2] and Close[2]>Close[1] and open[3]>close[3] and open[2]>close[2] and open[1]>close[1] // REM test for 3 berish candle
//TreBarsBelow = close[2] < SenkouSpanA and close[2] < SenkouSpanB and close < SenkouSpanA and close < SenkouSpanB and Close[2]>Close and open[2]>close[2] and open>close // REM test for only 2 berish candles below
TreBarsBelow = close[3] < SenkouSpanA and close[3] < SenkouSpanB and close[2] < SenkouSpanA and close[2] < SenkouSpanB and open[1] < SenkouSpanA and open[1] < SenkouSpanB and close[3]>Close[2] and medianprice[2]>open[1] and open[3]>close[3] and open[2]>close[2] and open[1]<medianprice[2] // REM test med open candle3
//Crosslow = Tenkansen crosses under Kijunsen: NOT USED
TenkansenBelow = Tenkansen < SenkouSpanA and Tenkansen < SenkouSpanB
KijunsenBelow = Kijunsen < SenkouSpanA and Kijunsen < SenkouSpanB
ChikouBelow = Chikou < SenkouSpanA[26] and Chikou < SenkouSpanB[26]
IF TreBarsBelow and TenkansenBelow and KijunsenBelow and ChikouBelow THEN
SELLSHORT PositionSize CONTRACTS AT MARKET
ENDIF
// stop and profit
//Sl=ABS(highest[3](high)-lowest[3](Low))/2
candlesperiods=15
NoMumentum1 = 30
NoMumentum2 = 40
If ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMumentum1 THEN
TP=2
SL=15
ELSIF ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMumentum2 THEN
TP=4
SL=3
else
TP=5
SL=2
Endif
set stop ploss SL
set target pprofit TP
//Debugging
//GRAPH SenkouSpanB COLOURED(0,0,255) AS "Take Profit" //Blue
//GRAPH SenkouSpanA COLOURED(255,0,0) AS "Stop Loss" //Red
//GRAPH Chikou COLOURED(0,0,0) AS "chikou" //Black
GRAPH TP COLOURED(0,255,255) AS "TP" //Aqua
GRAPH SL COLOURED(0,255,0) AS "SL" //Lime
//-------------------------------------------------------------------------
// Main code : 5magic3 newtest4
//-------------------------------------------------------------------------
defparam cumulateorders=false
defparam preloadbars=2000
defparam flatbefore=090000
defparam flatafter=220000
//ONCE Crosslow=0
//ONCE Crosshigh=0
ONCE Tenkansen=0
ONCE Kijunsen=0
ONCE SenkouSpanA=0
ONCE SenkouSpanB=0
//ONCE TreBarsAbove=0
//ONCE TreBarsBelow=0
ONCE TenkansenBelow=0
ONCE KijunsenBelow=0
ONCE ChikouBelow=0
ONCE Bullish0=0
ONCE Bullish1=0
//ONCE Bullish2=0
ONCE Bearish0= 0
ONCE Bearish1= 0
//ONCE Bearish2= 0
NoMomentum1=35
candlesperiods=15
//REM Money Management
Capital = 1000
Risk = 0.01
StopLoss = 10 // Could be our variable X
// Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
//If PositionSize>100 then
//PositionSize=100
//endif
//REM ICHIMOKU
Tenkansen = (highest[9](high)+lowest[9](low))/2
Kijunsen = (highest[26](high)+lowest[26](low))/2
SenkouSpanA = (Tenkansen[26]+Kijunsen[26])/2
SenkouSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
Chikou = close[26]
// REM BUY
Bullish0 = close > SenkouSpanA and close > SenkouSpanB and open < close
Bullish1 = close [1]> SenkouSpanA and close[1] > SenkouSpanB and open[1] < close[1]
//Bullish2 = close[2] > SenkouSpanA and close[2] > SenkouSpanB and open[2] < close[2]
TenkansenAbove = Tenkansen > SenkouSpanA and Tenkansen > SenkouSpanB
KijusenAbove = Kijunsen > SenkouSpanA and Kijunsen > SenkouSpanB
ChikouAbove = Chikou > SenkouSpanA[26] and Chikou > SenkouSpanB[26]
If ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMomentum1 THEN
condition=0
Else
condition=1
endif
IF condition and Bullish0 and Bullish1 and TenkansenAbove and KijusenAbove and ChikouAbove THEN
BUY PositionSize CONTRACTS AT MARKET
ENDIF
// REM SELL
Bearish0= close < SenkouSpanA and close < SenkouSpanB and close > open
Bearish1=close[1] < SenkouSpanA and close[1] < SenkouSpanB and close[1] > open[1]
//Bearish2= close[2] < SenkouSpanA and close[2] < SenkouSpanB and close[2] > open[2]
TenkansenBelow = Tenkansen < SenkouSpanA and Tenkansen < SenkouSpanB
KijunsenBelow = Kijunsen < SenkouSpanA and Kijunsen < SenkouSpanB
ChikouBelow = Chikou < SenkouSpanA[26] and Chikou < SenkouSpanB[26]
IF condition and TenkansenBelow and KijunsenBelow and ChikouBelow and Bearish0 and Bearish1 THEN
SELLSHORT PositionSize CONTRACTS AT MARKET
ENDIF
// REM stop and profit
//Sl=ABS(highest[3](high)-lowest[3](Low))/2
candlesperiods=15
TP=8
SL=6
set stop ploss SL
set target pprofit TP
//Debugging
//GRAPH SenkouSpanB COLOURED(0,0,255) AS "Take Profit" //Blue
//GRAPH SenkouSpanA COLOURED(255,0,0) AS "Stop Loss" //Red
//GRAPH Chikou COLOURED(0,0,0) AS "chikou" //Black
//GRAPH TP COLOURED(0,255,255) AS "TP" //Aqua
//GRAPH SL COLOURED(0,255,0) AS "SL" //Lime
//GRAPH TreBarsAbove COLOURED(0,255,255) AS "TreBarsAbove" //Aqua
//GRAPH TreBarsBelow COLOURED(255,0,0) AS "TreBarsBelow" //red
//GRAPH condition COLOURED(255,0,0) AS "condition" //red
***** new in 9.5
Accumolate orders =TRUE and also extra accomulation are made in trends
when Equity=600000 then quit
It looks like that most profit this year is within this timeframe.
But I still don’t like that within the last year it does not make any money overall- so I change the timeframe that for 2016 is profitable
defparam flatbefore=070000
defparam flatafter=120000
(But of cause the NoTradingAfter=17 will never be an issue)
*************
I also tried to play with traling stops, but with no luck or profit!!
//-------------------------------------------------------------------------
// Main code : 5magic3 newtest9.0
//-------------------------------------------------------------------------
defparam cumulateorders=false
defparam preloadbars=2000
defparam flatbefore=070000
defparam flatafter=230000
ONCE Tenkansen=0
ONCE Kijunsen=0
ONCE SenkouSpanA=0
ONCE SenkouSpanB=0
ONCE TenkansenBelow=0
ONCE KijunsenBelow=0
ONCE ChikouBelow=0
ONCE Bullish0=0
ONCE Bullish1=0
ONCE Bearish0= 0
ONCE Bearish1= 0
NoMomentum1=75
candlesperiods=2
//REM Money Management
Capital = 1000
Risk = 0.03
StopLoss = 10 // Could be our variable X
// Calculate contracts
equity = Capital + StrategyProfit
maxrisk = round(equity*Risk)
PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize)
If PositionSize>100 then
PositionSize=100
endif
//REM ICHIMOKU DEFINITI
Tenkansen = (highest[9](high)+lowest[9](low))/2
Kijunsen = (highest[26](high)+lowest[26](low))/2
SenkouSpanA = (Tenkansen[26]+Kijunsen[26])/2
SenkouSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
Chikou = close[26]
//**************************************
//************** REM LONG***************
//**************************************
// BULLISH/BEARISH CANDLE TEST AND CONDITION
Bullish0 = close > SenkouSpanA and close > SenkouSpanB and open < close
Bullish1 = close [1]> SenkouSpanA and close[1] > SenkouSpanB and open[1] < close[1]
Bearish0 = close < SenkouSpanA and close < SenkouSpanB and open > close
Bearish1 = close[1] < SenkouSpanA and close[1] < SenkouSpanB and open[1] > close[1]
//ICHIMOKU TEST AND LONG CONDITION
TenkansenAbove = Tenkansen > SenkouSpanA and Tenkansen > SenkouSpanB
KijunsenAbove = Kijunsen > SenkouSpanA and Kijunsen > SenkouSpanB
ChikouAbove = Chikou > SenkouSpanA[26] and Chikou > SenkouSpanB[26]
//VOLITALE TEST AND CONDITION
If ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMomentum1 THEN
condition=0
Else
condition=1
endif
//ENTER/EXIT LONG MARKET TEST
IF condition and Bullish0 and Bullish1 and TenkansenAbove and KijunsenAbove and ChikouAbove THEN
BUY PositionSize CONTRACTS AT MARKET
if low crosses under kijunsen then
sell AT MARKET
endif
ENDIF
//**************************************
//************** REM SHORT**************
//**************************************
//ICHIMOKU TEST AND SHORT CONDITION
TenkansenBelow = Tenkansen < SenkouSpanA and Tenkansen < SenkouSpanB
KijunsenBelow = Kijunsen < SenkouSpanA and Kijunsen < SenkouSpanB
ChikouBelow = Chikou < SenkouSpanA[26] and Chikou < SenkouSpanB[26]
//ENTER/EXIT SHORT MARKET TEST
IF condition and Bearish0 and Bearish1 and TenkansenBelow and KijunsenBelow and ChikouBelow THEN
SELLSHORT PositionSize CONTRACTS AT MARKET
if high crosses over kijunsen then
EXITSHORT AT MARKET
endif
ENDIF
// REM stop and profit
SL=109
set stop ploss SL
//Debugging
//GRAPH SenkouSpanB COLOURED(0,0,255) AS "Take Profit" //Blue
//GRAPH SenkouSpanA COLOURED(255,0,0) AS "Stop Loss" //Red
//GRAPH Chikou COLOURED(0,0,0) AS "chikou" //Black
//GRAPH TP COLOURED(0,255,255) AS "TP" //Aqua
//GRAPH SL COLOURED(0,255,0) AS "SL" //Lime
//GRAPH xxx COLOURED(0,255,255) AS "TreBarsAbove" //Aqua
//GRAPH xxx COLOURED(255,0,0) AS "TreBarsBelow" //red
//GRAPH condition COLOURED(255,0,0) AS "condition" //red
****************
//————————————————————————- // Main code : 5magic3 newtest9.5 //————————————————————————- defparam cumulateorders=TRUE defparam preloadbars=2000 defparam flatbefore=070000 defparam flatafter=120000 ONCE Tenkansen=0 ONCE Kijunsen=0 ONCE SenkouSpanA=0 ONCE SenkouSpanB=0 ONCE TenkansenBelow=0 ONCE KijunsenBelow=0 ONCE ChikouBelow=0 ONCE Bullish0=0 ONCE Bullish1=0 ONCE Bearish0= 0 ONCE Bearish1= 0 //Trading Variables NoMomentum1=75 candlesperiods=2 NoTradingAfter=17 //REM Money Management Capital = 1000 Risk = 0.03 StopLoss = 10 // Could be our variable X // Calculate contracts equity = Capital + StrategyProfit maxrisk = round(equity*Risk) PositionSize = abs(round((maxrisk/StopLoss)/PointValue)*pipsize) If PositionSize>100 then PositionSize=100 endif //REM ICHIMOKU DEFINITION Tenkansen = (highest[9](high)+lowest[9](low))/2 Kijunsen = (highest[26](high)+lowest[26](low))/2 SenkouSpanA = (Tenkansen[26]+Kijunsen[26])/2 SenkouSpanB = (highest[52](high[26])+lowest[52](low[26]))/2 Chikou = close[26] //************************************** //************** REM LONG*************** //************************************** // BULLISH/BEARISH CANDLE TEST AND CONDITION Bullish0 = close > SenkouSpanA and close > SenkouSpanB and open < close Bullish1 = close [1]> SenkouSpanA and close[1] > SenkouSpanB and open[1] < close[1] Bearish0 = close < SenkouSpanA and close < SenkouSpanB and open > close Bearish1 = close[1] < SenkouSpanA and close[1] < SenkouSpanB and open[1] > close[1] //ICHIMOKU TEST AND LONG CONDITION TenkansenAbove = Tenkansen > SenkouSpanA and Tenkansen > SenkouSpanB KijunsenAbove = Kijunsen > SenkouSpanA and Kijunsen > SenkouSpanB ChikouAbove = Chikou > SenkouSpanA[26] and Chikou > SenkouSpanB[26] //VOLITALE TEST AND CONDITION If ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMomentum1 THEN condition=0 Else condition=1 endif //ENTER/EXIT LONG MARKET TEST IF condition and Bullish0 and Bullish1 and TenkansenAbove and KijunsenAbove and ChikouAbove THEN //IF condition and Bullish0 and Bullish1 and TenkansenAbove and KijunsenAbove THEN BUY PositionSize CONTRACTS AT MARKET if low crosses under kijunsen then sell AT MARKET ENDIF ENDIF //Adding extra position if in good trend IF CurrentHour < NoTradingAfter and BARINDEX-TRADEINDEX(1)>1 AND Close-TRADEPRICE(1)>10 AND LongOnMarket then// AND condition and Bullish0 and Bullish1 and TenkansenAbove and KijunsenAbove then// and ChikouAbove THEN Buy PositionSize CONTRACTS AT MARKET if low crosses under kijunsen then sell AT MARKET ENDIF ENDIF //************************************** //************** REM SHORT************** //************************************** //ICHIMOKU TEST AND SHORT CONDITION TenkansenBelow = Tenkansen < SenkouSpanA and Tenkansen < SenkouSpanB KijunsenBelow = Kijunsen < SenkouSpanA and Kijunsen < SenkouSpanB ChikouBelow = Chikou < SenkouSpanA[26] and Chikou < SenkouSpanB[26] //ENTER/EXIT SHORT MARKET TEST IF condition and Bearish0 and Bearish1 and TenkansenBelow and KijunsenBelow and ChikouBelow THEN SELLSHORT PositionSize CONTRACTS AT MARKET if high crosses over kijunsen then EXITSHORT AT MARKET endif ENDIF //Adding extra position if in good trend IF CurrentHour < NoTradingAfter and BARINDEX-TRADEINDEX(1)>1 AND TRADEPRICE(1)-Close>20 AND ShortOnMarket then // AND condition and Bearish0 and Bearish1 and TenkansenBelow and KijunsenBelow and ChikouBelow THEN SELLSHORT PositionSize CONTRACTS AT MARKET if low crosses under kijunsen then sell AT MARKET ENDIF ENDIF // REM stop and profit StopLoss=109 set stop ploss StopLoss IF equity>50000 THEN QUIT ENDIF //Debugging //GRAPH SenkouSpanB COLOURED(0,0,255) AS “Take Profit” //Blue //GRAPH SenkouSpanA COLOURED(255,0,0) AS “Stop Loss” //Red //GRAPH Chikou COLOURED(0,0,0) AS “chikou” //Black //GRAPH TP COLOURED(0,255,255) AS “TP” //Aqua //GRAPH SL COLOURED(0,255,0) AS “SL” //Lime //GRAPH xxx COLOURED(0,255,255) AS “TreBarsAbove” //Aqua //GRAPH xxx COLOURED(255,0,0) AS “TreBarsBelow” //red //GRAPH condition COLOURED(255,0,0) AS “condition” //red //GRAPH Indicator COLOURED(255,0,0) AS “Longentry” //red //GRAPH LongEntry COLOURED(255,0,0) AS “Longentry” //red //Graph ind COLOURED(255,0,0) AS “condition” //redAnd something with the
//Volitale test
If ABS(highest[candlesperiods](high)-lowest[candlesperiods](low))< NoMomentum1 THEN
condition=0
Else
condition=1
endif
If it not in the code will not generate Any Money??? That’s is very strange and just a coincident derived from an idea
Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.
My first code and strategy
This topic contains 18 replies,
has 2 voices, and was last updated by Elsborgtrading
10 years, 1 month ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 07/21/2016 |
| Status: | Active |
| Attachments: | No files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.