New Strategy Idea In Development
Forums › ProRealTime English forum › ProOrder support › New Strategy Idea In Development
- This topic has 5 replies, 2 voices, and was last updated 6 years ago by
juanj.
-
-
06/18/2019 at 9:42 PM #100980
Hi Guys
I love the idea of combining statistics and probability with my trading strategies so came up with the following idea;
Considering a single timeframe and looking at how each individual candle is formed we will see that each candle starts with the opening price (previous closing price) then make both a high and a low and eventually settle with the closing price.
This means that the majority of candles have some leg room between the opening price and it’s high and low. These wicks are usually referred to as the candle ‘shadow’
So the basic idea here is to try and leverage this phenomenon by entering a trade at the opening price of a candle and scalping some points for a profit.
To do this we need to first establish the statistical advantage or probability of the trade to succeed.
This means we need to evaluate the current market condition by looking at some of the previous candles to see which direction to trade as well as how many points to target.
We also need to take into consideration the spread and whether statistically speaking there are enough points to make the trade worthwhile.
So here is what I have so far:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109Defparam cumulateorders = False//Timeframe: I am thinking that timeframes in the range of 5min to 1Day would work best//Market Hour FilterIf (hour < 9 or (hour = 9 and minute <= 0)) or (hour > 17 or (hour = 17 and minute >= 0)) Thenpossize = 1 //Use 0 to enable filterIf longonmarket ThenSell at marketElsIf shortonmarket ThenExitshort at marketEndIfElsepossize = 1EndIf//variablesSpread = 1 //Enter spread here (For pips use format 0.0001)SpreadVar = 4 // Spread variance factor is used to establish whether there is enough volatility taking into account the market spread (optimize for values between 3-7)ShadowVar = 0.9 // Shadow variance factor is used to account for error in shadow length calculation (optimize for values between 0.8-0.9)RiskReward = 3 // Risk to reward ratio used to calculate stop loss (optimize for values between 1-3)StdDev = 1.2 // Standard deviation used to filter outliers (optimize for values between 1-2)EvalPeriod = 6 // Evaluation period that will be used to make estimations (optimize for values between 3-9)//Initialize VariablesFollowHighGreenA = 0FollowLowGreenA = 0FollowHighRedA = 0FollowLowRedA = 0FGA = 0FRA = 0//Establish the length of upper and lower shadows for candles following both red and green candles in the evaluation periodFor i = 1 to EvalPeriod DoIf close[i+1] > open[i+1] ThenFollowHighGreenA = high[i] - open[i]FollowLowGreenA = open[i] - low[i]FGA = FGA + 1ElsIf close[i+1] < open[i+1] ThenFollowHighRedA = high[i] - open[i]FollowLowRedA = open[i] - low[i]FRA = FRA + 1EndIfNext//Calculate the raw average values of the shadowsFollowHighGreenB = FollowHighGreenA/FGAFollowLowGreenB = FollowLowGreenA/FGAFollowHighRedB = FollowHighRedA/FRAFollowLowRedB = FollowLowRedA/FRA//Test each shadow again similar to above but filter(cut) outliers against STD devaitionFor ii = 1 to EvalPeriod DoIf close[ii+1] > open[ii+1] ThenIf high[ii] - open[ii] <= (StdDev*STD(FollowHighGreenB)) ThenFollowHighGreenC = high[ii] - open[ii]ElseFollowHighGreenC = (StdDev*STD(FollowHighGreenB))EndIfIf open[ii] - low[ii] <= (StdDev*STD(FollowLowGreenB)) ThenFollowLowGreenC = open[ii] - low[ii]ElseFollowLowGreenC = (StdDev*STD(FollowLowGreenB))EndIfElsIf close[ii+1] < open[ii+1] ThenIf high[ii] - open[ii] <= (StdDev*STD(FollowHighRedB)) ThenFollowHighRedC = high[ii] - open[ii]ElseFollowHighRedC = (StdDev*STD(FollowHighRedB))EndIfIf open[ii] - low[ii] <= (StdDev*STD(FollowLowRedB)) ThenFollowLowRedC = open[ii] - low[ii]ElseFollowLowRedC = (StdDev*STD(FollowLowRedB))EndIfEndIfNext//Re-calculate the average values of the shadowsFollowHighGreen = FollowHighGreenC/FGAFollowLowGreen = FollowLowGreenC/FGAFollowHighRed = FollowHighRedC/FRAFollowLowRed = FollowLowRedC/FRA//Validate entry conditions and set targets and stopsIf close > open and FollowHighGreen > FollowLowGreen and ((high - open)*ShadowVar) > (spread*SpreadVar) and ((FollowHighGreen*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenBuy possize contract at marketSet target pprofit FollowHighGreen*ShadowVarSet stop ploss (FollowHighGreen*ShadowVar)/RiskRewardElsIf close > open and FollowHighGreen < FollowLowGreen and ((open - low)*ShadowVar) > (spread*SpreadVar) and ((FollowLowGreen*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenSellshort possize contract at marketSet target pprofit FollowLowGreen*ShadowVarSet stop ploss (FollowLowGreen*ShadowVar)/RiskRewardElsIf close < open and FollowHighRed > FollowLowRed and ((high - open)*ShadowVar) > (spread*SpreadVar) and ((FollowHighRed*ShadowVar)/RiskReward) > (spread * Spreadvar) ThenBuy possize contract at marketSet target pprofit FollowHighRed*ShadowVarSet stop ploss (FollowHighRed*ShadowVar)/RiskRewardElsIf close < open and FollowHighRed < FollowLowRed and ((open - low)*ShadowVar) > (spread*SpreadVar) and ((FollowLowRed*ShadowVar)/RiskReward) > (spread * spreadvar) ThenSellshort possize contract at marketSet target pprofit FollowLowRed*ShadowVarSet stop ploss (FollowLowRed*ShadowVar)/RiskRewardEndIfImprovements would include:
Better ways to sample past candles and arrive at a more accurate ‘average’
Additional filters to enhance probability i.e. volatility filter
06/18/2019 at 10:46 PM #10098306/19/2019 at 11:52 AM #101040Thanks, Grahal, I also hope some of the old timers can jump onboard. I know @Vonasi have done some good work on probability analysis as well.
One of the presumptions I made with the above is that it is useful to consider the color of the candle preceding the candle being analyzed. But thinking about it again last night I am not so sure this is valid. Will have to do a couple of tests.
06/19/2019 at 12:20 PM #101045Maybe colour + body size is the factor to look at and wick sizes and which side wick is the biggest. (You may already have done this as I’ve not had time to go over the code).
When manual trading one’s eyes take all these factors into account without even thinking. If one is asked why did you go Long at that point, often it’s like somebody asking … so why and how did you take a breath (breathe in) just then! 🙂
06/19/2019 at 1:22 PM #101051Just found a couple of mistakes in calculating the average as well as validating them against the spread. Here is the fix:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116Defparam cumulateorders = False//Timeframe: I am thinking that timeframes in the range of 5min to 1Day would work best//Market Hour FilterIf (hour < 9 or (hour = 9 and minute <= 0)) or (hour > 17 or (hour = 17 and minute >= 0)) Thenpossize = 1 //Use 0 to enable filterIf longonmarket ThenSell at marketElsIf shortonmarket ThenExitshort at marketEndIfElsepossize = 1EndIf//variablesSpread = 1 //Enter spread here (For pips use format 0.0001)SpreadVar = 4 // Spread variance factor is used to establish whether there is enough volatility taking into account the market spread (optimize for values between 3-7)ShadowVar = 0.9 // Shadow variance factor is used to account for error in shadow length calculation (optimize for values between 0.8-0.9)RiskReward = 3 // Risk to reward ratio used to calculate stop loss (optimize for values between 1-3)StdDev = 1.2 // Standard deviation used to filter outliers (optimize for values between 1-2)EvalPeriod = 6 // Evaluation period that will be used to make estimations (optimize for values between 3-9)//Initialize VariablesFollowHighGreenA = 0FollowLowGreenA = 0FollowHighRedA = 0FollowLowRedA = 0FGA = 0FRA = 0//Establish the length of upper and lower shadows for candles following both red and green candles in the evaluation periodFor i = 1 to EvalPeriod DoIf close[i+1] > open[i+1] ThenFollowHighGreenA = FollowHighGreenA + (high[i] - open[i])FollowLowGreenA = FollowLowGreenA + (open[i] - low[i])FGA = FGA + 1ElsIf close[i+1] < open[i+1] ThenFollowHighRedA = FollowHighRedA + (high[i] - open[i])FollowLowRedA = FollowLowRedA + (open[i] - low[i])FRA = FRA + 1EndIfNext//Calculate the raw average values of the shadowsFollowHighGreenB = FollowHighGreenA/FGAFollowLowGreenB = FollowLowGreenA/FGAFollowHighRedB = FollowHighRedA/FRAFollowLowRedB = FollowLowRedA/FRA//Initialize VariablesFollowHighGreenC = 0FollowLowGreenC = 0FollowHighRedC = 0FollowLowRedC = 0//Test each shadow again similar to above but filter(cut) outliers against STD devaitionFor ii = 1 to EvalPeriod DoIf close[ii+1] > open[ii+1] ThenIf high[ii] - open[ii] <= (StdDev*STD(FollowHighGreenB)) ThenFollowHighGreenC = FollowHighGreenC + (high[ii] - open[ii])ElseFollowHighGreenC = FollowHighGreenC + (StdDev*STD(FollowHighGreenB))EndIfIf open[ii] - low[ii] <= (StdDev*STD(FollowLowGreenB)) ThenFollowLowGreenC = FollowLowGreenC + (open[ii] - low[ii])ElseFollowLowGreenC = FollowLowGreenC + (StdDev*STD(FollowLowGreenB))EndIfElsIf close[ii+1] < open[ii+1] ThenIf high[ii] - open[ii] <= (StdDev*STD(FollowHighRedB)) ThenFollowHighRedC = FollowHighRedC + (high[ii] - open[ii])ElseFollowHighRedC = FollowHighRedC + (StdDev*STD(FollowHighRedB))EndIfIf open[ii] - low[ii] <= (StdDev*STD(FollowLowRedB)) ThenFollowLowRedC = FollowLowRedC + (open[ii] - low[ii])ElseFollowLowRedC = FollowLowRedC + (StdDev*STD(FollowLowRedB))EndIfEndIfNext//Re-calculate the average values of the shadowsFollowHighGreen = FollowHighGreenC/FGAFollowLowGreen = FollowLowGreenC/FGAFollowHighRed = FollowHighRedC/FRAFollowLowRed = FollowLowRedC/FRA//Validate entry conditions and set targets and stopsIf close > open and FollowHighGreen > FollowLowGreen and (FollowHighGreen *ShadowVar) > (spread*SpreadVar) and ((FollowHighGreen*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenBuy possize contract at marketSet target pprofit FollowHighGreen*ShadowVarSet stop ploss (FollowHighGreen*ShadowVar)/RiskRewardElsIf close > open and FollowHighGreen < FollowLowGreen and (FollowLowGreen *ShadowVar) > (spread*SpreadVar) and ((FollowLowGreen*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenSellshort possize contract at marketSet target pprofit FollowLowGreen*ShadowVarSet stop ploss (FollowLowGreen*ShadowVar)/RiskRewardElsIf close < open and FollowHighRed > FollowLowRed and (FollowHighRed *ShadowVar) > (spread*SpreadVar) and ((FollowHighRed*ShadowVar)/RiskReward) > (spread * Spreadvar) ThenBuy possize contract at marketSet target pprofit FollowHighRed*ShadowVarSet stop ploss (FollowHighRed*ShadowVar)/RiskRewardElsIf close < open and FollowHighRed < FollowLowRed and (FollowLowRed *ShadowVar) > (spread*SpreadVar) and ((FollowLowRed*ShadowVar)/RiskReward) > (spread * spreadvar) ThenSellshort possize contract at marketSet target pprofit FollowLowRed*ShadowVarSet stop ploss (FollowLowRed*ShadowVar)/RiskRewardEndIf06/19/2019 at 2:31 PM #101056So preliminary tests seem to show more robust performance when not considering candle colors and only looking at the average shadow lengths. I would appreciate any ideas on better sampling data to determine trade direction and profit targets.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778Defparam cumulateorders = False//Timeframe: I am thinking that timeframes in the range of 5min to 1Day would work best//Market Hour FilterIf (hour < 9 or (hour = 9 and minute <= 0)) or (hour > 17 or (hour = 17 and minute >= 0)) Thenpossize = 1 //Use 0 to enable filterIf longonmarket ThenSell at marketElsIf shortonmarket ThenExitshort at marketEndIfElsepossize = 1EndIf//variablesSpread = 1 //Enter spread here (For pips use format 0.0001)SpreadVar = 4 // Spread variance factor is used to establish whether there is enough volatility taking into account the market spread (optimize for values between 3-7)ShadowVar = 0.9 // Shadow variance factor is used to account for error in shadow length calculation (optimize for values between 0.8-0.9)RiskReward = 3 // Risk to reward ratio used to calculate stop loss (optimize for values between 1-3)StdDev = 1.2 // Standard deviation used to filter outliers (optimize for values between 1-2)EvalPeriod = 6 // Evaluation period that will be used to make estimations (optimize for values between 3-9)//Initialize VariablesHighA = 0LowA = 0//Establish the length of upper and lower shadows for candles following both red and green candles in the evaluation periodFor i = 1 to EvalPeriod DoHighA = HighA + (high[i] - open[i])LowA = LowA + (open[i] - low[i])Next//Calculate the raw average values of the shadowsHighB = HighA/EvalPeriodLowB = LowA/EvalPeriod//Initialize VariablesHighC = 0LowC = 0//Test each shadow again similar to above but filter(cut) outliers against STD devaitionFor ii = 1 to EvalPeriod DoIf high[ii]-open[ii] <= (StdDev*STD(HighB)) ThenHighC = HighC + (high[ii]-open[ii])ElseHighC = HighC + (StdDev*STD(HighB))EndIfIf open[ii] - low[ii] <= (StdDev*STD(LowB)) ThenLowC = LowC + (open[ii] - low[ii])ElseLowC = LowC + (StdDev*STD(LowB))EndIfNext//Re-calculate the average values of the shadowsHighShadow = HighC/EvalPeriodLowShadow = LowC/EvalPeriod//Validate entry conditions and set targets and stopsIf HighShadow > LowShadow and (HighShadow*ShadowVar) > (spread*SpreadVar) and ((HighShadow*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenBuy possize contract at marketSet target pprofit HighShadow*ShadowVarSet stop ploss (HighShadow*ShadowVar)/RiskRewardElsIf HighShadow < LowShadow and (LowShadow*ShadowVar) > (spread*SpreadVar) and ((LowShadow*ShadowVar)/RiskReward) > (spread * SpreadVar) ThenSellshort possize contract at marketSet target pprofit LowShadow*ShadowVarSet stop ploss (LowShadow*ShadowVar)/RiskRewardEndIf -
AuthorPosts
Find exclusive trading pro-tools on