SCALPING STRATEGY (VWAP/MACD35)
Forums › ProRealTime English forum › ProBuilder support › SCALPING STRATEGY (VWAP/MACD35)
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by efahmy.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
08/13/2021 at 10:26 AM #175225VWAP/MACD35123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475DEFPARAM CumulateOrders = True // Cumulating positions activated// Definition of code parametersSL = AverageTrueRange[14](close) * 2.0PT = SL * 1.5STEPFACTOR1 = 0.5STEPFACTOR2 = 0.25//VWAP calculation//NoSunday = 0 //1=skip Sunday'sIF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THENSumVolPrice = 0SumVol = 0ENDIFIF Volume > 0 THENIF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND Not NoSunday) THENSumVolPrice = SumVolPrice + (Volume * close)SumVol = SumVol + VolumeVWAP = SumVolPrice / SumVolENDIFENDIFindicator1 = MACDline[5,35,5](close)indicator2 = MACDSignal[5,35,5](close)timeframe(DEFAULT)// Conditions to enter long positionsIF close > VWAP AND indicator1 CROSSES OVER indicator2 THENBUY 10 CONTRACT AT MARKETENDIFIF close < VWAP AND indicator1 CROSSES UNDER indicator2 THENSELLSHORT 10 CONTRACT AT MARKET// Stops and targetsSET STOP pTRAILING SLSET TARGET pPROFIT PT//====== Trailing Stop mechanism - start =====trailingstart = (stepfactor1 * SL )trailingstep = (stepfactor2 * SL )//resetting variables when no trades are on marketif not onmarket thenpriceexit = 0endif//case LONG orderif longonmarket then//first move (breakeven)IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THENpriceexit = tradeprice(1) + trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = close-priceexit >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit + trailingstep*pointsizeENDIFENDIFENDIF//case SHORT orderif shortonmarket then//first move (breakeven)IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THENpriceexit = tradeprice(1) - trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = priceexit-close >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit - trailingstep*pointsizeENDIFENDIFENDIF//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPENDIF//====== Trailing Stop mechanism - end =====
Could you please, check this code.
08/13/2021 at 10:36 AM #175227ENDIF is missing between lines 29 and 30.
1 user thanked author for this post.
08/13/2021 at 10:48 AM #175228VWAP/MACD35 Adjusted1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374DEFPARAM CumulateOrders = True // Cumulating positions activated// Definition of code parametersSL = AverageTrueRange[14](close) * 2.0PT = SL * 1.5STEPFACTOR1 = 0.5STEPFACTOR2 = 0.25//VWAP calculation//NoSunday = 0 //1=skip Sunday'sIF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THENSumVolPrice = 0SumVol = 0ENDIFIF Volume > 0 THENIF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND Not NoSunday) THENSumVolPrice = SumVolPrice + (Volume * close)SumVol = SumVol + VolumeVWAP = SumVolPrice / SumVolENDIFENDIFindicator1 = MACDline[5,35,5](close)indicator2 = MACDSignal[5,35,5](close)timeframe(DEFAULT)// Conditions to enter long positionsIF close > VWAP AND indicator1 CROSSES OVER indicator2 THENBUY 10 CONTRACT AT MARKETENDIFIF close < VWAP AND indicator1 CROSSES UNDER indicator2 THENSELLSHORT 10 CONTRACT AT MARKETENDIF// Stops and targetsSET STOP pTRAILING SLSET TARGET pPROFIT PT//====== Trailing Stop mechanism - start =====trailingstart = (stepfactor1 * SL )trailingstep = (stepfactor2 * SL )//resetting variables when no trades are on marketif not onmarket thenpriceexit = 0endif//case LONG orderif longonmarket then//first move (breakeven)IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THENpriceexit = tradeprice(1) + trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = close-priceexit >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit + trailingstep*pointsizeENDIFENDIFENDIF//case SHORT orderif shortonmarket then//first move (breakeven)IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THENpriceexit = tradeprice(1) - trailingstep*pointsizeENDIF//next movesIF priceexit>0 THENP2 = priceexit-close >= trailingstart*pointsizeIF P2 THENpriceexit = priceexit - trailingstep*pointsizeENDIFENDIFENDIF//exit on trailing stop price levelsif onmarket and priceexit>0 thenEXITSHORT AT priceexit STOPSELL AT priceexit STOPENDIF//====== Trailing Stop mechanism - end ===== -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)
Find exclusive trading pro-tools on
Similar topics: