Category Trend  Published on 07/05/2023

Simple Momentum by Singularity

Description

A trading strategy that incorporates price, moving average, and short-term and long-term momentum

 Entry Rules:

  1. Price crossover above the 50-day MA, indicating a potential upward trend.
  2. Moving average crossover: Confirm the trend by waiting for the 50-day MA to cross above the 200-day MA.
  3. Short-term momentum: The RSI should be above 50, indicating positive short-term momentum.
  4. Long-term momentum: The MACD line should cross above the MACD signal line, indicating positive long-term momentum.

When all four conditions are met, open a long (buy) position.

B. Exit Rules:

  1. Price crossover: Close the position when the price crosses below the 50-day MA, indicating a potential downward trend.
  2. Fixed Pips

 

I did not backtest the robot, please do your own research, if you have any questions, pls do not hesitate to ask: singalgolab@gmail.com


using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MovingAverageMomentumStrategy : Robot
    {
        [Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 1)]
        public int StopLossPips { get; set; }

        [Parameter("short MA Period", DefaultValue = 50, MinValue = 1)]
        public int masPeriod { get; set; }

        [Parameter("long MA Period", DefaultValue = 200, MinValue = 1)]
        public int malPeriod { get; set; }

        [Parameter("RSI Period", DefaultValue = 14, MinValue = 1)]
        public int rsiPeriod { get; set; }

        [Parameter("Take Profit (pips)", DefaultValue = 40, MinValue = 1)]
        public int TakeProfitPips { get; set; }

        [Parameter("Volume", DefaultValue = 10000)]
        public int volume { get; set; }


        private MovingAverage ma50;
        private MovingAverage ma200;
        private RelativeStrengthIndex rsi;
        private MacdCrossOver macd;

        protected override void OnStart()
        {
            ma50 = Indicators.MovingAverage(Bars.ClosePrices, masPeriod, MovingAverageType.Exponential);
            ma200 = Indicators.MovingAverage(Bars.ClosePrices, malPeriod, MovingAverageType.Exponential);
            rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, rsiPeriod);
            macd = Indicators.MacdCrossOver(Bars.ClosePrices, 12, 26, 9);
        }

        protected override void OnBar()
        {

           

            bool isPriceAboveMa50 = Bars.ClosePrices.Last(1) > ma50.Result.Last(1);
            bool isMa50AboveMa200 = ma50.Result.Last(1) > ma200.Result.Last(1);
            bool isRsiAbove50 = rsi.Result.Last(1) > 50;
            bool isMacdAboveSignal = macd.MACD.Last(1) > macd.Signal.Last(1);

            bool isPriceBelowMa50 = Bars.ClosePrices.Last(1) < ma50.Result.Last(1); ;
            bool isMa50BelowMa200 = ma50.Result.Last(1) < ma200.Result.Last(1);
            bool isRsiBelow50 = rsi.Result.Last(1) < 50;
            bool isMacdBelowSignal = macd.MACD.Last(1) < macd.Signal.Last(1);

            if (Positions.Count != 0)
            {
                foreach (var position in Positions)
                {
                    if (position.TradeType == TradeType.Sell && isPriceAboveMa50)
                    {
                        position.Close();
                    }
                    else if (position.TradeType == TradeType.Buy && isPriceBelowMa50)
                    {
                        position.Close();

                    }
                }
            }

            if (isPriceAboveMa50 && isMa50AboveMa200 && isRsiAbove50 && isMacdAboveSignal && Positions.Count ==0)
            {
   


                ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "MovingAverageMomentum", StopLossPips, TakeProfitPips);
            }
            else if (isPriceBelowMa50 && isMa50BelowMa200 && isRsiBelow50 && isMacdBelowSignal && Positions.Count == 0)
            {



                ExecuteMarketOrder(TradeType.Sell, SymbolName, volume, "MovingAverageMomentum", StopLossPips, TakeProfitPips);
            }
        }


    }
}


SI
singalgolab

Joined on 07.05.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: simple Momentum, singularity algolab.algo
  • Rating: 0
  • Installs: 848
  • Modified: 07/05/2023 19:45
Comments
Log in to add a comment.
WA
wavapon551 · 1 year ago

This web page is mostly a stroll-via for the entire info you needed about this and didn’t know who to ask. Glimpse here, and also you’ll definitely uncover it. [Reply]how to be a credit card processor

FO
focexa1861 · 1 year ago

Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You definitely know what youre talking about, why waste your intelligence on just posting videos to your site when you could be giving us something informative to read? Miss feather hair extensionsselling payment processing

VO
vojarit154 · 1 year ago

Great site you have listed here, offers useful material which may assist any one Also in the event everyone will be intresting in escort ladies, you should contact us.Packers and Movers Hyderabad to Kolkata