Moving Averages to prevent unnecessary trades opening
Forums › ProRealTime English forum › ProOrder support › Moving Averages to prevent unnecessary trades opening
- This topic has 6 replies, 3 voices, and was last updated 2 years ago by nonetheless.
-
-
11/21/2021 at 2:24 PM #181986
Hi There,
I have been looking for code, I have been trying to code a 2 Moving Average as part of my trading system.
50 Period Moving Average
200 Period Moving Average
when the 50 MA has crossed over on top of the 200 MA, then my trading system will only take buy/long Trades
and when the 200MA has crossed over on top of the 50, then the trading system will only take Sell/Short Trades
I am trying to eliminate, the trading system from going against the trend and only taking Buy/Long trades when the market is on the up and Short/Sell trades when the Market is moving down.
I would like to attach this code into an existing trading system.
11/21/2021 at 3:49 PM #181989There you go;
123456789Sma50 = average[50,0](close)Sma200 = average[200,0](close)UPtrend = Sma50 > Sma200DOWNtrend = Sma50 < Sma200If MyLongConditions and UPtrend ThenBuy at MarketElsIf MyShortConditions and DOWNtrend ThenSellShort at MarketEndif1 user thanked author for this post.
11/21/2021 at 7:29 PM #18199211/21/2021 at 8:00 PM #181997Hello again,
So when I implement the code I get this message coming up:
The Following variable is undefined: MyLongConditions, MyShortConditions
Thanks again
11/21/2021 at 8:04 PM #181998MyLongConditions and MyShortConditions will be the existing conditions from the system you are adding this to.
11/21/2021 at 8:06 PM #18199912345678910111213141516171819202122//EURUSD 1 Hour//Buy when RSI crosses over Bollinger Down then Buy 1A = RSI[13](Close)B = BollingerDown[25](Close)C = BollingerUp[25](Close)IF A < 3 AND Close < B THENBUY 1 SHARE AT MARKETENDIF//When RSI crosses over close out tradeSma50 = average[50,0](close)Sma200 = average[200,0](close)UPtrend = Sma50 > Sma200DOWNtrend = Sma50 < Sma200If MyLongConditions and UPtrend ThenBuy at MarketElsIf MyShortConditions and DOWNtrend ThenSellShort at MarketEndifIF A > 75 AND Close > C THENSELL AT MARKETENDIF11/21/2021 at 8:09 PM #1820001234567891011121314151617//EURUSD 1 Hour//Buy when RSI crosses over Bollinger Down then Buy 1A = RSI[13](Close)B = BollingerDown[25](Close)C = BollingerUp[25](Close)//When RSI crosses over close out tradeSma50 = average[50,0](close)Sma200 = average[200,0](close)UPtrend = Sma50 > Sma200DOWNtrend = Sma50 < Sma200IF A < 3 AND Close < B and UPtrend ThenBuy 1 contract at MarketElsIf A > 75 AND Close > C and DOWNtrend ThenSellShort 1 contract at MarketEndif2 users thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on