Multi timeframe scalp code question
Forums › ProRealTime English forum › ProOrder support › Multi timeframe scalp code question
- This topic has 6 replies, 4 voices, and was last updated 5 years ago by GraHal.
-
-
11/28/2018 at 6:29 PM #85933
Hi. I want to create a simple program for automatic trading that creates small scalping trades using 15 minute and 5 minute charts (5 minute is the default).
I am experimenting with different conditions to open the trade but as an example lets say this is a long trade and the opening condition is that MACDline (12,26,9) crosses over 50 on the 5 minute chart. And the RSI(14) must be below 50 on the 15 minute chart
On the 15 minute chart I have created 2 bands using the ATR. The upper band is the close + the ATR(14) and the lower band is the close – the ATR(14).
When the trade is opened on the close of the 5 minute bar I want the profit target to be the upper ATR band on the 15 minute chart at the time the trade is opened, and the stop loss to be the lower ATR band on the 15 minute chart at the time the trade is opened.
Can you help me to code this please?
11/28/2018 at 7:04 PM #85934Your question is ProOrder related and not a platform support issue so I have moved your post. Posting in the correct forum will have the best chance of getting a solution and will save us moderators a lot of time moving posts around all day!
Please try to post in the correct forum with future posts. 🙂
11/28/2018 at 8:35 PM #85943You mean MACDline (12,26,9) crosses over 0 ?
11/29/2018 at 10:38 AM #8598211/29/2018 at 7:38 PM #86036This the code:
1234567891011121314151617TIMEFRAME(15 minutes, updateonclose)MyRsi = Rsi[14](close)MyAtr = AverageTrueRange[14](close)UpperATR = close + MyAtrLowerATR = close - MyAtrTIMEFRAME(default) //5 minutesMyMacd = MACDline[12,26,9](close)MyConditions = (MyMacd CROSSES OVER 0) AND (MyRsi < 50)IF MyConditions AND Not OnMarket THENBUY 1 CONTRACT AT MARKETTp = ABS(UpperATR - close)Sl = ABS(close - LowerATR)SET TARGET PROFIT TpSET STOP LOSS SlENDIFWhen computing SL and TP I used ABS(() to make sure it’s not a negative number, because UPDATEONCLOSE at line 1 makes TF15 values older than TF5 so a sudden surge on the default TF might cause, even temporarily, a closing price higher/lower than it was when TF15 closed.
If you remove UPDATEONCLOSE then you can also remove ABS() but values on TF15 will be the current ones when the TF5 closes, not when TF15 closed last time.
If you want to try you can even launch the strategy from a 3-minute or 1-minute TF, since 15 is a multiple of 5, 3 and 1 (not 2).
11/30/2018 at 11:53 AM #8607612/01/2018 at 1:53 PM #86144Version 1.4 with Shorts.
If you improve then please post on here so we can all share.
1234567891011121314151617181920212223242526272829303132333435//https://www.prorealcode.com/topic/multi-timeframe-scalp-code-question/DEFPARAM CUMULATEORDERS = FalseTrade = Time > 060000 and Time < 205500TIMEFRAME(1 Hour)MyRsi = Rsi[8](close)MyAtr = AverageTrueRange[2](close)UpperATR = close + MyAtrLowerATR = close - MyAtrTIMEFRAME(default) //3 minutesMyMacd = MACDline[12,26,9](close)MyConditionL = (MyMacd CROSSES OVER 0) AND (MyRsi < 50) and Trade //50IF MyConditionL and not onmarket THENBUY 1 CONTRACT AT MARKETTpL = (UpperATR - close)SlL = (close - LowerATR)SET TARGET PPROFIT TpLSET STOP PLOSS SlLENDIFMyConditionS = (MyMacd CROSSES UNDER 0) AND (MyRsi > 50) and Trade //50IF MyConditionS and not onmarket THENSellShort 1 CONTRACT AT MARKETSLS = (UpperATR - close)TPS = (close - LowerATR)SET TARGET PPROFIT TpSSET STOP PLOSS SlSENDIF//GRAPH UpperATR - close//GRAPH close - LowerATR//GRAPH TPL//GRAPH TPS// -
AuthorPosts
Find exclusive trading pro-tools on