find local maximum in history
Created at 02 Feb 2021, 02:50
find local maximum in history
02 Feb 2021, 02:50
What the Robot needs to do is, finding the local maximum in history.
In OnStart, I use a loop to have access to previous bars of days but I need to find the index of local maximums hours as well as days (into extremumsdaily and extremumshourly).
Any Idea how I can loop in both daily and hourly bars?
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.Collections.Generic;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class multitemp : Robot
{
public List<int> extremumsdaily = new List<int>();
public List<int> extremumshourly = new List<int>();
protected override void OnStart()
{
// Put your initialization logic here
Bars barsD1 = MarketData.GetBars(TimeFrame.Daily);
Bars barsH1 = MarketData.GetBars(TimeFrame.Hour);
int Index = barsH1.Count - 1;
int Indexdaily = barsD1.Count - 1;
var MaxLine = barsD1.HighPrices.Last(Indexdaily);
for (int i = Index; i > 0; i--)
{
// FIND MAX
if (MaxLine < barsD1.ClosePrices.Last(i))
{
// find hourly and daily indexes here
MaxLine = barsD1.HighPrices.LastValue;
extremumsdaily.Add( showingBars.Count - 1);
}
}
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}