Host
Host's avatar

Info

Username:Host
Name:Host
Member since: 04 Dec 2022
Country:Brazil

Favorite symbols:

USDMXN

About

None

Signature

None

Last Algorithm Comments

@CBot MacD Market timer help spot error:  23 Jan 2023, 13:32


using System; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals;   namespace cAlgo.Robots {     [Robot(AccessRights = AccessRights.None)]     public class MACDMarketTimerV2 : Robot     {         [Parameter("Label", Group = "Label", DefaultValue = " MACDMarketTimerV2,RSI,MACD")]         public string Label { get; set; }         [Parameter("Sentiment: Buy", Group = "Basic Setup", DefaultValue = true)]         public bool Buy { get; set; }           [Parameter("Sentiment: Sell", Group = "Basic Setup", DefaultValue = true)]         public bool Sell { get; set; }         [Parameter("Max Trades", Group = "Basic Setup", DefaultValue = 1, MinValue = 1)]         public int TradeCount { get; set; }         [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 0.01, MinValue = 0.01, Step = 0.01)]         public double Quantity { get; set; }         [Parameter("Stop Loss ", Group = "Protection", DefaultValue = 100)]         public int StopLoss { get; set; }         [Parameter("Take Profit", Group = "Protection", DefaultValue = 100)]         public int TakeProfit { get; set; }         [Parameter("Start Hour", Group = "Market Time", DefaultValue = 10.0)]         public double StartTime { get; set; }         [Parameter("Stop Hour", Group = "Market Time", DefaultValue = 12.0)]         public double StopTime { get; set; }         [Parameter("MME Slow", Group = "MA", DefaultValue = 16)]         public int MmeSlow { get; set; }           [Parameter("MME Fast", Group = "MA", DefaultValue = 12)]         public int MmeFast { get; set; }                 [Parameter("Source", Group = "RSI")]         public DataSeries Source { get; set; }           [Parameter("Periods", Group = "RSI", DefaultValue = 19)]         public int Periods { get; set; }                                [Parameter(" Period", Group="MACD",DefaultValue = 9)]         public int Period { get; set; }           [Parameter(" Long Cycle",Group="MACD", DefaultValue = 26)]         public int LongCycle { get; set; }           [Parameter(" Short Cycle",Group="MACD", DefaultValue = 12)]         public int ShortCycle { get; set; }                                       private MovingAverage i_MA_slow;         private MovingAverage i_MA_fast;         private RelativeStrengthIndex rsi;         private DateTime Starttime;         private DateTime Stoptime;                        private MacdCrossOver macd;         private double volumeInUnits;                           protected override void OnStart()                  {             i_MA_slow = Indicators.MovingAverage(Bars.ClosePrices, MmeSlow, MovingAverageType.Exponential);             i_MA_fast = Indicators.MovingAverage(Bars.ClosePrices, MmeFast, MovingAverageType.Exponential);             rsi = Indicators.RelativeStrengthIndex(Source, Periods);             macd=Indicators.MacdCrossOver(LongCycle, ShortCycle, Period);             volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);                          Starttime = Server.Time.Date.AddHours(StartTime);             Stoptime = Server.Time.Date.AddHours(StopTime);             }         protected override void OnBar()         {             if (!MarketTime())                 return;                              if (Positions.FindAll(Label, SymbolName).Length <= TradeCount)             {                 SendTrade();             }         }                  private void SendTrade()         {             var MACDLine = macd.MACD.Last(1);             var PrevMACDLine = macd.MACD.Last(2);             var Signal = macd.Signal.Last(1);             var PrevSignal = macd.Signal.Last(2);                          if (rsi.Result.LastValue > 25 && rsi.Result.LastValue < 70)             {                 if (MACDLine > Signal && PrevMACDLine < PrevSignal && Buy)                 {                     if (i_MA_fast.Result.LastValue > i_MA_slow.Result.LastValue)                     {                         ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, Label, StopLoss, TakeProfit);                     }                 }                 else if (MACDLine < Signal && PrevMACDLine > PrevSignal && Sell)                 {                     if (i_MA_fast.Result.LastValue < i_MA_slow.Result.LastValue)                     {                         ExecuteMarketOrder(TradeType.Sell, SymbolName, volumeInUnits, Label, StopLoss, TakeProfit);                     }                 }             }         }         private bool MarketTime()         {             var CorrentHour = Server.Time.TimeOfDay.TotalHours;                 if (CorrentHour > StartTime && CorrentHour < StopTime)                     return true;                 else                     return false;         }         protected override void OnError(Error result)         {             if (result.Code == ErrorCode.NoMoney)                 Stop();         }     } }

@CBot MacD Market timer help spot error:  23 Jan 2023, 13:32


I am also learning. I started a few days ago, but I'm very focused. If you don't mind, I made some changes, like the organization in the code structure, which is something important, and the option to decide how many operations can be performed in a row. But, answering your question, I believe that what you did wrong is having mentioned Default==Sell and Default==Buy. In this case, it is only necessary to mention only the variant, which, if true, will follow the code.

Last Forum Posts

@Help with indicador Fractals API:  20 Dec 2022, 16:05


PanagiotisChar said:

Hi there,

Here you go

i_fractal = Indicators.Fractals(param_fractal_period);

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Thank you very much!!

@Help with indicador Fractals API:  19 Dec 2022, 16:38


Can someone help me to fix this Fractals indicator error?

I've studied and researched and I couldn't get any references to correct.

using System;
using System.Collections;
using System.Linq;
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 ADXFractals : Robot
    {

        [Parameter("SMA Slow", DefaultValue = 100, MinValue = 50, MaxValue = 1000, Step = 50)]
        public int ma_slow_period { get; set; }

        [Parameter("SMA Fast", DefaultValue = 30, MinValue = 10, MaxValue = 100, Step = 10)]
        public int ma_fast_period { get; set; }

        [Parameter("MA Cross", DefaultValue = 30, MinValue = 10, MaxValue = 200, Step = 10)]
        public int param_ma_cross_period { get; set; }

        [Parameter("ADX Min Value", DefaultValue = 20, MinValue = 10, MaxValue = 100, Step = 1)]
        public int param_adx_min { get; set; }

        [Parameter("ADX Max Value", DefaultValue = 40, MinValue = 30, MaxValue = 100, Step = 5)]
        public int param_adx_max { get; set; }

        [Parameter("Fractal Period", DefaultValue = 10, MinValue = 10, MaxValue = 100, Step = 10)]
        public int param_fractal_period { get; set; }

        [Parameter("Fractal diff", DefaultValue = 0, MinValue = 0, MaxValue = 10, Step = 1)]
        public int param_fractal_diff { get; set; }

        [Parameter("Min SL", DefaultValue = 30, MinValue = 5, MaxValue = 100, Step = 1)]
        public int param_min_stop_loss { get; set; }

        [Parameter("Max SL", DefaultValue = 50, MinValue = 30, MaxValue = 50, Step = 5)]
        public int param_max_stop_loss { get; set; }

        [Parameter("Min TP", DefaultValue = 30, MinValue = 5, MaxValue = 50, Step = 5)]
        public int param_min_take_profit { get; set; }

        [Parameter("Max TP", DefaultValue = 50, MinValue = 30, MaxValue = 50, Step = 1)]
        public int param_max_take_profit { get; set; }

        [Parameter("Volume Units", DefaultValue = 100000, MinValue = 1000, MaxValue = 1000000, Step = 1000)]
        public int volume_units { get; set; }

        private MovingAverage i_MA_slow;
        private MovingAverage i_MA_fast;
        private DirectionalMovementSystem i_ADXR;
        private RelativeStrengthIndex i_RSI;
        private Fractals i_fractal;

        protected override void OnStart()
        {
            i_MA_slow = Indicators.MovingAverage(Bars.ClosePrices, ma_slow_period, MovingAverageType.Simple);
            i_MA_fast = Indicators.MovingAverage(Bars.ClosePrices, ma_fast_period, MovingAverageType.Simple);
            i_ADXR = Indicators.DirectionalMovementSystem(20);
            i_RSI = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14);
            i_fractal = Indicators.GetIndicator<Fractals>(param_fractal_period);
        }

        protected override void OnTick()
        {
            if (Positions.FindAll("MA", SymbolName).Length == 0)
            {
                if (i_ADXR.ADX.LastValue > param_adx_min && i_ADXR.ADX.LastValue < param_adx_max)
                    if (i_RSI.Result.LastValue < 60)
                        if (i_MA_fast.Result.HasCrossedAbove(i_MA_slow.Result.LastValue, param_ma_cross_period))
                            if (Symbol.Bid > i_MA_fast.Result.LastValue)
                            {
                                Open_Buy_Order();
                                return;
                            }
                if (i_ADXR.ADX.LastValue > param_adx_min && i_ADXR.ADX.LastValue < param_adx_max)
                    if (i_RSI.Result.LastValue > 40)
                        if (i_MA_fast.Result.HasCrossedBelow(i_MA_slow.Result.LastValue, param_ma_cross_period))
                            if (Symbol.Bid < i_MA_fast.Result.LastValue)
                            {
                                Open_Sell_Order();
                                return;
                            }
            }
        }

        private void Open_Buy_Order()
        {
            double tp = 0, sl = 0;
            tp = getTakeProfit(TradeType.Buy);
            sl = getStopLoss(TradeType.Buy);
            if (tp > param_min_take_profit && tp < param_max_take_profit && sl > param_min_stop_loss && sl < param_max_stop_loss)
                ExecuteMarketOrder(TradeType.Buy, SymbolName, volume_units, "MA", sl + param_fractal_diff, tp - param_fractal_diff);
        }


        private void Open_Sell_Order()
        {
            double tp = 0, sl = 0;
            tp = getTakeProfit(TradeType.Sell);
            sl = getStopLoss(TradeType.Sell);
            if (tp > param_min_take_profit && tp < param_max_take_profit && sl > param_min_stop_loss && sl < param_max_stop_loss)
                ExecuteMarketOrder(TradeType.Sell, SymbolName, volume_units, "MA", sl + param_fractal_diff, tp - param_fractal_diff);
        }


        private double getTakeProfit(TradeType type)
        {
            double tp = 0;
            if (type == TradeType.Buy)
            {
                for (int i = i_fractal.UpFractal.Count; i > 0; i--)
                {
                    if (!double.IsNaN(i_fractal.UpFractal[i]))
                    {
                        if ((i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize > param_min_take_profit)
                            if ((i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize < param_max_take_profit)
                            {
                                tp = (i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize;
                                break;
                            }
                    }
                }
            }

            if (type == TradeType.Sell)
            {
                for (int i = i_fractal.DownFractal.Count; i > 0; i--)
                {
                    if (!double.IsNaN(i_fractal.DownFractal[i]))
                    {
                        if ((Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize > param_min_stop_loss)
                            if ((Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize < param_max_stop_loss)
                            {
                                tp = (Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize;
                                break;
                            }
                    }
                }
            }

            return tp;
        }

        private double getStopLoss(TradeType type)
        {
            double sl = 0;
            if (type == TradeType.Buy)
            {
                for (int i = i_fractal.DownFractal.Count; i > 0; i--)
                {
                    if (!double.IsNaN(i_fractal.DownFractal[i]))
                    {
                        if ((Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize > param_min_stop_loss)
                            if ((Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize < param_max_stop_loss)
                            {
                                sl = (Symbol.Bid - i_fractal.DownFractal[i]) / Symbol.PipSize;
                                break;
                            }
                    }
                }

            }

            if (type == TradeType.Sell)
            {
                for (int i = i_fractal.UpFractal.Count; i > 0; i--)
                {
                    if (!double.IsNaN(i_fractal.UpFractal[i]))
                    {
                        if ((i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize > param_min_take_profit)
                            if ((i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize < param_max_take_profit)
                            {
                                sl = (i_fractal.UpFractal[i] - Symbol.Bid) / Symbol.PipSize;
                                break;
                            }
                    }
                }
            }

            return sl;
        }
    }
}

@Backtesting not working in NET 6.0. Working fine in NET 4.x:  17 Dec 2022, 19:41


15/11/2022 21:00:00.000 | CBot instance [H # Test, EURUSD, m5] started.
15/11/2022 21:00:00.000 | CBot instance [H # Test, EURUSD, m5] process was unexpectedly terminated.

@Program does not recognize the correct compiler:  15 Dec 2022, 17:24


Spotware said:

Dear trader,

Our question has not been answered yet. What is the problem with using the x64 compiler? What do you mean when you say

does not work the .NET 6.0

What does not work?

Usually the problem is when the x86 appears instead of the x64, because the TEMP variable that points to the relevant directory has been overriden. The x64 compiler is the correct one to use.

Best regards,

cTrader Team

Background testing, optimization and the robot itself on the demo or real account does not work.

@Program does not recognize the correct compiler:  15 Dec 2022, 11:19


Spotware said:

Dear trader,

Could you please provide more information about your issue? It is not obvious from the screenshots you have sent what the problem is. What does not work if you use the x64 compiler?

Best regards,

cTrader Team

Everything is fine. So I have a computer and a notebook. In both, cTrader is installed. In both, the SDK .NET 6.0.403 compiler is installed, of both types, 32 and 64bits. Both use Windows 11 Pro. On the computer, cTrader only recognizes the 32bit SDK 6.0.403 compiler, it doesn't recognize the 64bit one, but the .NET 6.0 works normally. The notebook only recognizes the compiler SDK .NET 6.0.403 of 64Bits, does not recognize the 32bits, does not work the .NET 6.0.
I believe that the fact that the notebook's cTrader is not recognizing the correct compiler, which would be the .NET x86 SDK, would be causing me this problem.
 

How could I do to make the program recognize the 32bit compiler?

The first screenshot is from cTrader on the notebook.


The second screenshot is from the computer cTrader.

@Program does not recognize the correct compiler:  14 Dec 2022, 12:10


My Trader for Notebook platform is not working on .NET 6.0, but on my PC it works fine. I found that on my PC it works with the 6.0.403 x86 compiler (Most updated), but on the notebook the platform does not recognize the x86 compiler, only the x64. How do I make the platform recognize x86?

A clean installation of the program has already been carried out and there were even people who had to format Windows, but it did not solve it. The problem is in the program not recognizing the correct compilation.

Plataform for Notebook recognize x64, Not working .NET 6.0

In previous print, the Notebook plataform recognize only compiler x64, not working .NET 6 Automate bots

Plataform for PC recognize x86, work fine .NET 6.0

This print, the plataform for PC recognize compiler x86. Work fine .NET 6.0 Automate bots

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.