How to reference another Symbol in an indicator?
How to reference another Symbol in an indicator?
21 Jan 2021, 04:00
Is there a way to reference the current GbpUsd price in this indicator where GbpUsd is in brackets?
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ATRPIPWithEMA : Indicator
{
private SimpleMovingAverage High;
private SimpleMovingAverage Low;
private double C;
private double Volume;
private double VolumeUsd;
private double lot;
private double Lot;
protected override void Initialize()
{
High = Indicators.SimpleMovingAverage(Bars.HighPrices, 1);
Low = Indicators.SimpleMovingAverage(Bars.LowPrices, 1);
C = High.Result.LastValue - Low.Result.LastValue;
Volume = (0.57 * High.Result.LastValue) / C;
VoluemUsd = Volume * (GbpUsd)
lot = 100000 * High.Result.LastValue;
Lot = Volume / lot;
}
public override void Calculate(int index)
{
if (index == 0)
DisplayPositionSizeRiskOnChart();
}
private void DisplayPositionSizeRiskOnChart()
{
string text = " Lot " + " = " + Math.Round(Lot, 2);
ChartObjects.DrawText("Lot", text, StaticPosition.TopLeft, Colors.FloralWhite);
}
}
}
Replies
jackhpfilerrowson
21 Jan 2021, 12:36
RE:
firemyst said:
Here is some sample code off the top of my head on how to reference another symbol within the current one:
Symbols.GetSymbol(MarketData.GetBars(Bars.TimeFrame, "GBPUSD").SymbolName);
Thanks, ill give it a go
@jackhpfilerrowson
... Deleted by UFO ...
... Deleted by UFO ...
firemyst
21 Jan 2021, 04:59
Here is some sample code off the top of my head on how to reference another symbol within the current one:
@firemyst