Previous Candle High Low order execute !!!!

Created at 26 Jan 2023, 00:34
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MO

moiz.forex

Joined 05.09.2022

Previous Candle High Low order execute !!!!
26 Jan 2023, 00:34


Guys, This bot is made on a system that when the current candle price will touch the high of previous candle it will Place SELL ORDER and when the current candle price will touch the low of previous candle then it will Execute BUY ORDER. I am doing the strategy on Weekly Candles.

My issues is that when i change symbols like GOLD, OIL, Forex. The bot doesnt work good. I guess some volume Parameter and TP and SL pips are not made accurately... 

Can someone help me fix this so it can run on all sybmols with accurate tp and sl

 

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MyAlgo : Robot
    {
        [Parameter("Take Profit (pips)", DefaultValue = 20, MinValue = 1)]
        public int TakeProfit { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 10, MinValue = 1)]
        public int StopLoss { get; set; }

        [Parameter("Volume", DefaultValue = 1, MinValue = 0.5)]
        public int Volume { get; set; }

        protected override void OnBar()
        {
            double previousCandleHigh = Bars.HighPrices.Last(1);
            double previousCandleLow = Bars.LowPrices.Last(1);

            if (Bars.ClosePrices.LastValue > previousCandleHigh)
                ExecuteMarketOrder(TradeType.Sell,SymbolName,Symbol.NormalizeVolumeInUnits(Volume), "Sell on High", StopLoss * Symbol.PipValue, TakeProfit * Symbol.PipValue);

            if (Bars.ClosePrices.LastValue < previousCandleLow)
                ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.NormalizeVolumeInUnits(Volume), "Buy on Low", StopLoss * Symbol.PipValue, TakeProfit * Symbol.PipValue);
        
    }
}
}


@moiz.forex