Previous Candle High Low breakout bot

Created at 25 Jan 2023, 23:13
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 breakout bot
25 Jan 2023, 23:13


Hey guys.. I made this somehow but when i move from currency pairs to Oil or gold or silver. This bot confuses me on Volume and even on Calculation of PIPS..

 

Can someone fix this for me so it can run on all Symbols..

 

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