Any way to get symbol type ie forex/index/cash etc
Any way to get symbol type ie forex/index/cash etc
29 Jul 2022, 17:49
Hi,
Any way to get symbol type ie forex/index/cash etc?
Regards
Vivek
Replies
paolo.panicali
02 Aug 2022, 18:40
( Updated at: 21 Dec 2023, 09:22 )
This is the easiest way for me
Hi, indexes has numerical digits and less than 3 decimals, forex have minimum 3 decimals...there are some exceptions but you can start from here if you want... the Symbol interface can help...
Bye
// Symbol Recognizer by paolo panicali 2022
//indexes have numerical digits, forex has more than 2 decimals...
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SymbolRecognizerCtrader : Indicator
{
public override void Calculate(int index)
{
if (index == 0)
{
string SymbolName = Symbol.Name;
int Counter = 0;
int val;
for (int i = 0; i < SymbolName.Length; i++)
{
if (Char.IsDigit(SymbolName[i]))
Counter++;
}
if (Counter > 0)
Print("Hello, I am an Index and my name is " + Symbol.Name);
if (Symbol.Digits >= 3)
Print("Hello, I am a Forex, my name is " + Symbol.Name);
}
}
}
}
@paolo.panicali
paolo.panicali
02 Aug 2022, 19:01
( Updated at: 21 Dec 2023, 09:22 )
also Symbol.VolumeInUnitsStep
Symbol.VolumeInUnitsStep returns 1 for indexes, 1000 for Forex, 50 for crude oil....you can use that to categorize a symbol
Print(Symbol.VolumeInUnitsStep);
Bye
@paolo.panicali
Anka Software
03 Aug 2022, 01:27
RE: also Symbol.VolumeInUnitsStep
Hi,
Can we get an enhancement to Symbol class with a Category property added?
Vivek
@Anka Software
paolo.panicali
03 Aug 2022, 01:48
maybe it already exists , frankly I do not know
Hi Vivek maybe it already exists, I have no idea.
bye.
@paolo.panicali
Anka Software
03 Aug 2022, 01:57
RE: maybe it already exists , frankly I do not know
paolo.panicali said:
Hi Vivek maybe it already exists, I have no idea.
bye.
Checked, it doesnt. Panagiotis, please respond.
@Anka Software
PanagiotisCharalampous
03 Aug 2022, 10:16
Hi Vivek,
No there is not.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
Anka Software
03 Aug 2022, 10:20
RE:
PanagiotisCharalampous said:
Hi Vivek,
No there is not.
Best Regards,
Panagiotis
Hi Panagiotis,
Can you take it as an enhancement request?
Vivek
@Anka Software
PanagiotisCharalampous
03 Aug 2022, 10:35
Hi Vivek,
You can post suggestions here.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
firemyst
02 Aug 2022, 16:08
RE:
Anka Software said:
Maybe create C# HashSet objects calle "forex", "index", "cash" etc. IN each Has object, add the symbols you'll be trading that you would classify as forex, index, cash, etc, respectively.
@firemyst