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.
There you go;
Sma50 = average[50,0](close)
Sma200 = average[200,0](close)
UPtrend = Sma50 > Sma200
DOWNtrend = Sma50 < Sma200
If MyLongConditions and UPtrend Then
Buy at Market
ElsIf MyShortConditions and DOWNtrend Then
SellShort at Market
Endif
Hello again,
So when I implement the code I get this message coming up:
The Following variable is undefined: MyLongConditions, MyShortConditions
Thanks again
MyLongConditions and MyShortConditions will be the existing conditions from the system you are adding this to.
//EURUSD 1 Hour
//Buy when RSI crosses over Bollinger Down then Buy 1
A = RSI[13](Close)
B = BollingerDown[25](Close)
C = BollingerUp[25](Close)
IF A < 3 AND Close < B THEN
BUY 1 SHARE AT MARKET
ENDIF
//When RSI crosses over close out trade
Sma50 = average[50,0](close)
Sma200 = average[200,0](close)
UPtrend = Sma50 > Sma200
DOWNtrend = Sma50 < Sma200
If MyLongConditions and UPtrend Then
Buy at Market
ElsIf MyShortConditions and DOWNtrend Then
SellShort at Market
Endif
IF A > 75 AND Close > C THEN
SELL AT MARKET
ENDIF
//EURUSD 1 Hour
//Buy when RSI crosses over Bollinger Down then Buy 1
A = RSI[13](Close)
B = BollingerDown[25](Close)
C = BollingerUp[25](Close)
//When RSI crosses over close out trade
Sma50 = average[50,0](close)
Sma200 = average[200,0](close)
UPtrend = Sma50 > Sma200
DOWNtrend = Sma50 < Sma200
IF A < 3 AND Close < B and UPtrend Then
Buy 1 contract at Market
ElsIf A > 75 AND Close > C and DOWNtrend Then
SellShort 1 contract at Market
Endif