Previous Candle High Low breakout bot
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);
}
}
}