Ichimoku + stochastic strategy, help needed
Forums › ProRealTime English forum › ProBuilder support › Ichimoku + stochastic strategy, help needed
- This topic has 7 replies, 3 voices, and was last updated 4 years ago by robertogozzi.
-
-
05/17/2020 at 3:18 PM #131982
Hi,
Im trying to build an tradebot and I´m trying to learn.
This is what I´m working with:
123456789101112131415161718192021222324252627282930313233343536373839404142// --- settingsKPeriod = 25Slowing = 3DPeriod = 3ATRperiod = 20maPeriod = 20maMethod = 0overBought = 80overSold = 20// --- end of settingsmyRSI = RSI[14](close)//Smoothing the RSI value on 10 periodsSmoothRSI = Average[10](myRSI)RETURN myRSI, SmoothRSI coloured(121,45,180)// --- Property settingsDefParam DrawOnLastBarOnly = true// Price = 1 // (1=true/0=false)// Kijun = 1 // ------// Cloud = 1 // ------// Lagging = 1 // ------// Label = 1 // ------// --- endTenkansen = (highest[9](High)+lowest[9](Low))/2Kijunsen = (highest[26](High)+lowest[26](Low))/2//Chikou = Close[26]SenkouSA = (Tenkansen[26]+Kijunsen[26])/2SenkouSB = (highest[52](High[26])+lowest[52](Low[26]))/2// shortstochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)rsiSignal = change(rsi) < 0ichiSellSignal = chikou < sourceInput[chikouDisplacement-1]sellSignal = stochSellSignal and rsiSignal and ichiSellSignalshortProfitPerc = input(title="Short Take Profit (%)", minval=0.0, step=0.1, defval=0.6) / 100shortLossPerc = input(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=0.5) / 100I know its not working and I would need some guidelines from you guys here how to keep going on. Much thanks!
,,Franro
05/17/2020 at 3:50 PM #131988Stick to highlighted basic rules, among which:
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
it doesn’t work because it’s not written in ProRealTime language, at least the last two lines (provided the first ones have been correctly converted).
Maybe someone knowing that language might help.
05/17/2020 at 4:11 PM #131992Plus you have a DEFPARAM in the middle of the code and it should always be at the beginning and you have a RETURN in the middle of the code when it should always be at the end.
You say you are building a ‘tradebot’ but this is an indicator that you are working on and not an auto strategy.
05/22/2020 at 9:02 AM #13275912345678910111213141516171819202122232425262728293031323334353637383940414243444546474849// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM preloadbars = 5000//Money Management DaxMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=2ENDIFif MM = 1 thenONCE startpositionsize = 1ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE factor2 = 20 // tier 2 factorONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE tier1 = 105 // DAX €1 IG first tier margin limitONCE maxpositionsize = 1050 // DAX €1 IG tier 2 margin limitONCE minpositionsize = 1 // enter minimum position allowedIF Not OnMarket THENpositionsize = startpositionsize + Strategyprofit/(factor*margin)ENDIFIF Not OnMarket THENIF startpositionsize + Strategyprofit/(factor*margin) > tier1 thenpositionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 //incorporating tier 2 marginENDIFIF Not OnMarket THENif startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THENpositionsize = minpositionsize //keeps positionsize from going below allowed minimumENDIFIF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize thenpositionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limitENDIFENDIFENDIFENDIFCtime = time >= 090000 and time < 173000// --- stochasticmySMI = SmoothedStochastic[14,3](close)// --- rsimyRSI = RSI[14](close)// --- ichimoku cloudTenkansen = (highest[9](High)+lowest[9](Low))/2Kijunsen = (highest[26](High)+lowest[26](Low))/2//Chikou = Close[26]SenkouSA = (Tenkansen[26]+Kijunsen[26])/2SenkouSB = (highest[52](High[26])+lowest[52](Low[26]))/205/22/2020 at 9:05 AM #132760Thanks for the help guys. I hope I´m learing in the right direction.
Can someone help me set up the short condition:
// shortstochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)rsiSignal = change(rsi) < 0ichiSellSignal = chikou < sourceInput[chikouDisplacement–1]sellSignal = stochSellSignal and rsiSignal and ichiSellSignalThis easily means short when
stochasticfast > 80 and cross under (stochFast, stochSlow)rsi is moving downclose is less than chikou (lagging span)And all of them together to short.05/22/2020 at 9:10 AM #132764As it is coded it will work on v11, since it has Ichimoku keywords that are missing in v10.3 (but can be easily replaced).
Now you only need to write the code to enter and exit trades.
1 user thanked author for this post.
05/22/2020 at 10:39 AM #132788Oh I have v10.3 this is the condition for enter short trade
// shortstochSellSignal = stochFast > stochSellSignalInput and crossunder(stochFast, stochSlow)rsiSignal = change(rsi) < 0ichiSellSignal = chikou < sourceInput[chikouDisplacement–1]sellSignal = stochSellSignal and rsiSignal and ichiSellSignalThis easily means short when
stochasticfast > 80 and cross under (stochFast, stochSlow)rsi is moving downclose is less than chikou (lagging span)Im just unsure how to write them in prt and I would like some help with that from someone here at the forum 😀05/23/2020 at 12:44 PM #132939There you go. I commented unused Ichimoku definitions and added TP & SL to make it work for testing purposes:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM preloadbars = 5000ONCE startpositionsize = 1ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE factor2 = 20 // tier 2 factorONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE tier1 = 105 // DAX €1 IG first tier margin limitONCE maxpositionsize = 1050 // DAX €1 IG tier 2 margin limitONCE minpositionsize = 1 // enter minimum position allowed//Money Management DaxMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=2ELSEIF Not OnMarket THENpositionsize = startpositionsize + Strategyprofit/(factor*margin)IF startpositionsize + Strategyprofit/(factor*margin) > tier1 thenpositionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 //incorporating tier 2 marginif startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THENpositionsize = minpositionsize //keeps positionsize from going below allowed minimumENDIFIF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize thenpositionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limitENDIFENDIFENDIFENDIFCtime = time >= 090000 and time < 173000// --- stochasticmySMIk = SmoothedStochastic[14,3](close)mySMId = average[5](mySMIk)// --- rsimyRSI = RSI[14](close)// --- ichimoku cloud////Tenkansen = (highest[9](high) + lowest[9](low)) / 2 //Fast MA//Kijunsen = (highest[26](high) + lowest[26](low)) / 2 //Slow MA//SenkouSA = (tenkansen[26] + kijunsen[26]) / 2 //Span A//SenkouSB = (highest[52](high[26]) + lowest[52](low[26])) / 2 //Span BChikou = close[26] //Chikou//c1 = mySMIk > 80c2 = mySMIk CROSSES UNDER mySMIdc3 = myRSI < myRSI[1]c4 = close < ChikouIF c1 AND c2 AND c3 AND c4 AND Not Onmarket AND cTime THENSELLSHORT PositionSize contract at MarketSet Target pProfit 100Set Stop pLoss 50ENDIF -
AuthorPosts
Find exclusive trading pro-tools on