Basic coding question
Forums › ProRealTime English forum › ProOrder support › Basic coding question
- This topic has 30 replies, 3 voices, and was last updated 7 years ago by BC.
-
-
05/28/2017 at 10:18 AM #3682905/28/2017 at 2:12 PM #3684005/28/2017 at 7:55 PM #36845
Bin, use GRAPH as below and you will see your StopLossLong never triggers.
1GRAPH Close = StopLossLongSubstitute actual numbers from a bar and you will see why …
1StopLossLong(68) = BuyPrice (12637) - SMA (12569)But nonetheless the code shows profit … well done! Most be room for tweaking / more profit?
GraHal
05/28/2017 at 9:21 PM #36847Guys can you please post the code relative to Bin’s picture in attachment? I’m trying to replicate the results before working on it.
Thank you
Francesco
05/28/2017 at 10:11 PM #36851Forgive me @Bin, what I said in #36845 re Stop Loss not triggering was incorrect … I need to concentrate and not have one eye on the TV! 🙁
Thanks Francesco78, I can’t replicate Bin’s results either with code on this Thread.
I tried to optimise 4 variables for 5m and 15m (not good) and settled on attached for Dax @ 30M. Results over 100,000 bars attached and .itf attached with 4 variables in the Optimiser.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475//defparam preloadbars = 3000defparam cumulateorders =false //true //false//Big Three MAFMA=Average[f](close) //green coloured(0,255,0)MMA=Average[m](close)//blue coloured(0,0,255)SMA=Average[s](close)//red coloured(255,0,0)//High Low Bar SettingCP=cp//Buy SignalB1=low > SMA and low>MMA and low>FMAB2=high >= highest[CP](high)BC=B1 and B2//Buy CandleBC1 = Close[1] < Close[2]BC2 = Close > Close[1]BC3 = Close > OpenBCandle = BC1 and BC2 and BC3//Sell SignalS1=high < FMA and high<MMA and high<SMAS2=low <= lowest[CP](low)SC=S1 and S2//Sell CaandleSC1 = Close[1] > Close[2]SC2 = Close < Close[1]SC3 = Close < OpenSCandle = SC1 and SC2 and SC3//Long Entryif BC and BCandle thenBUY 1 CONTRACT AT MARKETBuyPrice=CloseStopLossLong = BuyPrice - SMAendif//Long Exitif LongonMarket and close crosses under SMA thensell at marketendif//short entryif SC and SCandle then//SELLSHORT min(25,PositionSizeShort) CONTRACT AT MARKETSELLSHORT 1 CONTRACT AT MARKETSellPrice=CloseStopLossShort=SMA-SellPrice//takeProfit = takeProfitShortendif//Short Exitif ShortonMarket and close crosses over SMA thenexitshort at marketendif// Stop Lossif LongonMarket thenSET STOP LOSS StopLossLongendifif ShortonMarket thenSET STOP LOSS StopLossShortendif//graph SMA//graph Tradeprice//graph StopLossLong//graph StopLossShort1 user thanked author for this post.
05/28/2017 at 11:32 PM #36854Sorry Grahal, , I forgot post the updated version with target profit and limited the loss. My bad.
*Big3 V1-3 Take Profit12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576defparam preloadbars = 3000defparam cumulateorders =false//Big Three MAFMA=Average[20](close) //green coloured(0,255,0)MMA=Average[40](close) //blue coloured(0,0,255)SMA=Average[80](close) //red coloured(255,0,0)//High Low Bar SettingCP=3//Buy SignalB1=low > SMA and low>MMA and low>FMAB2=high >= highest[CP](high)BC=B1 and B2//Buy CandleBC1 = Close[1] < Close[2]BC2 = Close > Close[1]BC3 = Close > OpenBCandle = BC1 and BC2 and BC3//Sell SignalS1=high < FMA and high<MMA and high<SMAS2=low <= lowest[CP](low)SC=S1 and S2//Sell CandleSC1 = Close[1] > Close[2]SC2 = Close < Close[1]SC3 = Close < OpenSCandle = SC1 and SC2 and SC3//Long Entryif BC and BCandle then//BUY min(25,PositionSizeLong) CONTRACT AT MARKETBUY 1 CONTRACT AT MARKETBuyPrice=CloseStopLossLong = MIN(100,MAX(30,(BuyPrice - SMA))) //100, 30TakeProfitLong = StopLossLong * 4.5 //1-5StopLoss = StopLossLongTakeProfit = TakeProfitLongendif//Long Exitif LongonMarket and close crosses under SMA thensell at marketendif//short entryif SC and SCandle then//SELLSHORT min(25,PositionSizeShort) CONTRACT AT MARKETSELLSHORT 1 CONTRACT AT MARKETSellPrice=CloseStopLossShort = MIN(60,MAX(10,(SMA - SellPrice))) //60, 10TakeProfitShort = StopLossShort * 2.5 //1-5StopLoss = StopLossShortTakeProfit = TakeProfitShortendif//Short Exitif ShortonMarket and close crosses over SMA thenexitshort at marketendif// Stop LossSET STOP LOSS StopLoss//Target ProfitSET TARGET PROFIT TakeProfitgraph BuyPricegraph SellPricegraph StopLossLonggraph StopLossShort2 users thanked author for this post.
05/29/2017 at 12:56 PM #36886Thanks, on the 1 hour and 30minutes TF is pretty nice.
have you run WF yet?
05/29/2017 at 2:43 PM #36926Hi Francesco
A modified version with WF result attached.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106defparam preloadbars = 3000defparam cumulateorders =false //true //false//Big Three MAFMA=Average[20](close) //green coloured(0,255,0)MMA=Average[40](close)//blue coloured(0,0,255)SMA=Average[80](close)//red coloured(255,0,0)//High Low Bar SettingCP=3// Money ManagementCapital = 2000//Risk = 5 //in %MaxD = 50equity = Capital + StrategyProfit//Time ManagementONCE maxCandlesLongWithoutProfit = 62 // 46, 62ONCE maxCandlesShortWithoutProfit = 72 // 46, 72//Check system account balanceif equity<QuickLevel thenquitendifrecordhighest = MAX(recordhighest,equity)QuickLevel = recordhighest*((100-MaxD)/100)//Buy SignalB1=low > SMA and low>MMA and low>FMAB2=high >= highest[CP](high)BC=B1 and B2//Buy CandleBC1 = Close[1] < Close[2]BC2 = Close > Close[1]BC3 = Close > OpenBCandle = BC1 and BC2 and BC3//Sell SignalS1=high < FMA and high<MMA and high<SMAS2=low <= lowest[CP](low)SC=S1 and S2//Sell CaandleSC1 = Close[1] > Close[2]SC2 = Close < Close[1]SC3 = Close < OpenSCandle = SC1 and SC2 and SC3//Long Entryif BC and BCandle thenBUY 1 CONTRACT AT MARKETBuyPrice=CloseStopLossLong = MIN(100,MAX(30,(BuyPrice - SMA))) //100, 30TakeProfitLong = StopLossLong * 4.5 //1-5StopLoss = StopLossLongTakeProfit = TakeProfitLongendif//Long Exitif LongonMarket and close crosses under SMA thensell at marketendif//short entryif SC and SCandle thenSELLSHORT 1 CONTRACT AT MARKETSellPrice=CloseStopLossShort = MIN(60,MAX(10,(SMA - SellPrice))) //60, 10TakeProfitShort = StopLossShort * 2.5 //1-5StopLoss = StopLossShortTakeProfit = TakeProfitShortendif//Short Exitif ShortonMarket and close crosses over SMA thenexitshort at marketendif// stop and profit managementIF LONGONMARKET THENposProfit = (((close - positionprice) * pointvalue) * countofposition) / pipsizeELSIF SHORTONMARKET THENposProfit = (((positionprice - close) * pointvalue) * countofposition) / pipsizeENDIF//Time Exitm3 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesLongWithoutProfitm4 = posProfit < 0 AND (BarIndex - TradeIndex) >= maxCandlesShortWithoutProfitIF LONGONMARKET AND m3 THENSELL AT MARKETENDIFIF SHORTONMARKET AND m4 THENEXITSHORT AT MARKETENDIF//Stop LossSET STOP LOSS StopLoss//Target ProfitSET TARGET PROFIT TakeProfit05/29/2017 at 2:46 PM #36930looks really good, thanks a lot, any idea if it can be adapted to other markets?
what are the variables you have optimized for the WF if I may ask?
05/29/2017 at 2:57 PM #36937I keep the original idea which using 20, 40, 80 MA and only add the highest/lowest filter and tested with Hang Seng (12.6 spread)and DAX (2.9 spread) only, HS not good because the high spread.
WF only check quit level, I think can take a test on Max stop loss and target profit.
05/29/2017 at 3:33 PM #36938Thanks, I think
CP and
maxCandlesLongWithoutProfit
maxCandlesShortWithoutProfitshould be subjected to backtest.Will try tomorrow05/29/2017 at 4:06 PM #3694405/30/2017 at 6:39 AM #36984I try DJI 30m, 1 hr, 4 hr with fixed MA and CP only but no luck, may be this Big3 idea not soild enough.
1 user thanked author for this post.
05/30/2017 at 9:00 AM #3699905/30/2017 at 9:34 AM #37004I think CP was optimized, I tried myself..
-
AuthorPosts
Find exclusive trading pro-tools on