SCALPING STRATEGY (VWAP/MACD35)
- This topic has 2 replies, 2 voices, and was last updated 3 years ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › SCALPING STRATEGY (VWAP/MACD35)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
DEFPARAM CumulateOrders = True // Cumulating positions activated // Definition of code parameters SL = AverageTrueRange[14](close) * 2.0 PT = SL * 1.5 STEPFACTOR1 = 0.5 STEPFACTOR2 = 0.25 //VWAP calculation // NoSunday = 0 //1=skip Sunday's IF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THEN SumVolPrice = 0 SumVol = 0 ENDIF IF Volume > 0 THEN IF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND Not NoSunday) THEN SumVolPrice = SumVolPrice + (Volume * close) SumVol = SumVol + Volume VWAP = SumVolPrice / SumVol ENDIF ENDIF indicator1 = MACDline[5,35,5](close) indicator2 = MACDSignal[5,35,5](close) timeframe(DEFAULT) // Conditions to enter long positions IF close > VWAP AND indicator1 CROSSES OVER indicator2 THEN BUY 10 CONTRACT AT MARKET ENDIF IF close < VWAP AND indicator1 CROSSES UNDER indicator2 THEN SELLSHORT 10 CONTRACT AT MARKET // Stops and targets SET STOP pTRAILING SL SET TARGET pPROFIT PT //====== Trailing Stop mechanism - start ===== trailingstart = (stepfactor1 * SL ) trailingstep = (stepfactor2 * SL ) //resetting variables when no trades are on market if not onmarket then priceexit = 0 endif //case LONG order if longonmarket then //first move (breakeven) IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THEN priceexit = tradeprice(1) + trailingstep*pointsize ENDIF //next moves IF priceexit>0 THEN P2 = close-priceexit >= trailingstart*pointsize IF P2 THEN priceexit = priceexit + trailingstep*pointsize ENDIF ENDIF ENDIF //case SHORT order if shortonmarket then //first move (breakeven) IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THEN priceexit = tradeprice(1) - trailingstep*pointsize ENDIF //next moves IF priceexit>0 THEN P2 = priceexit-close >= trailingstart*pointsize IF P2 THEN priceexit = priceexit - trailingstep*pointsize ENDIF ENDIF ENDIF //exit on trailing stop price levels if onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP ENDIF //====== Trailing Stop mechanism - end ===== |
Could you please, check this code.
ENDIF is missing between lines 29 and 30.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
DEFPARAM CumulateOrders = True // Cumulating positions activated // Definition of code parameters SL = AverageTrueRange[14](close) * 2.0 PT = SL * 1.5 STEPFACTOR1 = 0.5 STEPFACTOR2 = 0.25 //VWAP calculation // NoSunday = 0 //1=skip Sunday's IF (BarIndex = 0) OR (OpenDay <> OpenDay[1]) THEN SumVolPrice = 0 SumVol = 0 ENDIF IF Volume > 0 THEN IF (OpenDayOfWeek <> 0) OR (OpenDayOfWeek = 0 AND Not NoSunday) THEN SumVolPrice = SumVolPrice + (Volume * close) SumVol = SumVol + Volume VWAP = SumVolPrice / SumVol ENDIF ENDIF indicator1 = MACDline[5,35,5](close) indicator2 = MACDSignal[5,35,5](close) timeframe(DEFAULT) // Conditions to enter long positions IF close > VWAP AND indicator1 CROSSES OVER indicator2 THEN BUY 10 CONTRACT AT MARKET ENDIF IF close < VWAP AND indicator1 CROSSES UNDER indicator2 THEN SELLSHORT 10 CONTRACT AT MARKET ENDIF // Stops and targets SET STOP pTRAILING SL SET TARGET pPROFIT PT //====== Trailing Stop mechanism - start ===== trailingstart = (stepfactor1 * SL ) trailingstep = (stepfactor2 * SL ) //resetting variables when no trades are on market if not onmarket then priceexit = 0 endif //case LONG order if longonmarket then //first move (breakeven) IF priceexit=0 AND close-tradeprice(1) >= trailingstart*pointsize THEN priceexit = tradeprice(1) + trailingstep*pointsize ENDIF //next moves IF priceexit>0 THEN P2 = close-priceexit >= trailingstart*pointsize IF P2 THEN priceexit = priceexit + trailingstep*pointsize ENDIF ENDIF ENDIF //case SHORT order if shortonmarket then //first move (breakeven) IF priceexit=0 AND tradeprice(1)-close >= trailingstart*pointsize THEN priceexit = tradeprice(1) - trailingstep*pointsize ENDIF //next moves IF priceexit>0 THEN P2 = priceexit-close >= trailingstart*pointsize IF P2 THEN priceexit = priceexit - trailingstep*pointsize ENDIF ENDIF ENDIF //exit on trailing stop price levels if onmarket and priceexit>0 then EXITSHORT AT priceexit STOP SELL AT priceexit STOP ENDIF //====== Trailing Stop mechanism - end ===== |
Find exclusive trading pro-tools on