Topics
24 Dec 2022, 17:20
 739
 1
Replies

ashish.sah.np
11 May 2023, 08:49

No trade is taking place from above trade.
 

And also When i coded a simple crossover and crossunder with Bars.ClosePrices and tried to choose the Heiken Ashi chart during the backtest with my desired timeframe but it seem that it didn’t use Heiken Ashi Candle data for its calculation during backtest.


@ashish.sah.np

ashish.sah.np
21 Dec 2022, 17:32 ( Updated at: 21 Dec 2023, 09:23 )

RE:

PanagiotisChar said:

Hi there,

You need to provide some more information

  1. Which symbol and dates do you backtest?
  2. What exception do you get in the log?

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

Hello there, Thank you for responding and assisting. The attached link is the indicator that I am using.

It ran the following tests for less data successfully:

When I tried to increase the backtesting time, I got the following error:


Also, while running the backtest, the ctrader app began to display "Not Responding" as if it was consuming major app resources, but backtesting other cbots on my PC went smoothly. Is there anything in my code that causes this issue, and is there any solution to it?

https://ctrader.com/algos/indicators/show/3197


@ashish.sah.np

ashish.sah.np
21 Dec 2022, 16:53

RE:

PanagiotisChar said:

Hi again,

Make sure your SL is set outside the spread. Else it won't be placed.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

Is there anyway to check whether SL and TP are inside the spread and to excuse such trades?


@ashish.sah.np

ashish.sah.np
20 Dec 2022, 15:37 ( Updated at: 21 Dec 2023, 09:23 )

RE:

PanagiotisChar said:

Hi there,

Here is your problem

You are passing the volume as quantity but the input should be in units. See below

ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.NormalizeVolumeInUnits(Quantity), "Buy", StopLossBuy, TakeProfitBuy);

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 

 

Hello Thanks for the support. Really appreciate.

Could you please assist me in setting the previous high as a stop loss by converting the price difference in pips correctly? I have tried with the below code, but in the positions tab, T/P and S/L are showing blank for some trades while the majority of trades are closed, so I'm wondering if my below method is correct or not.

And the way I am taking the EMA value, is it correct? This will be a big help for me. Thanks in advance. May God bless your trading portfolio.

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SampleEmacBot : Robot
    {
        [Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
        public double Quantity { get; set; }

        [Parameter("Source", Group = "EMA")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", Group = "EMA", DefaultValue = 5)]
        public int Periods { get; set; }

        private ExponentialMovingAverage ema;

        protected override void OnStart()
        {
            ema = Indicators.ExponentialMovingAverage(Source, Periods);
        }
        protected override void OnBar()
        {
            var currentCandleClose = Bars.ClosePrices.Last(1);
            var currentCandleOpen = Bars.OpenPrices.Last(1);
            var previousCandleHigh = Bars.HighPrices.Last(2); 
            var previousCandleLow = Bars.LowPrices.Last(2);
            var StopLossBuy = (Math.Abs(previousCandleLow - Bars.OpenPrices.Last(0)))/Symbol.PipSize;
            var TakeProfitBuy = ((Math.Abs(previousCandleLow - Bars.OpenPrices.Last(0)))/Symbol.PipSize)*4;
            var StopLossSell = (Math.Abs(previousCandleHigh - Bars.OpenPrices.Last(0)))/Symbol.PipSize;
            var TakeProfitSell =((Math.Abs(previousCandleHigh- Bars.OpenPrices.Last(0)))/Symbol.PipSize)*4;
            var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);

            if (((previousCandleHigh < ema.Result.Last(2) )&& (currentCandleClose < ema.Result.Last(1))) && (Bars.OpenPrices.Last(0) <= currentCandleClose) )
            {
                ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, "Buy", StopLossBuy, TakeProfitBuy);
            }

            if (((previousCandleLow > ema.Result.Last(2)) && (currentCandleClose > ema.Result.Last(1))) && (Bars.OpenPrices.Last(0) >= currentCandleClose))
            {
                ExecuteMarketOrder(TradeType.Sell, SymbolName, volumeInUnits, "Sell", StopLossSell, TakeProfitSell);
            }
        }
    }
}

@ashish.sah.np