LocalStorageScope on Mac
LocalStorageScope on Mac
13 Mar 2024, 09:02
Good day,
I tried this piece of code of the LocalStorage from your documentation (I am on Mac M1) :
https://help.ctrader.com/ctrader-automate/guides/local-storage/#how-to-use-local-storage
string messageLocalStorage = LocalStorage.GetString("Example Message");
if (messageLocalStorage is not null) {
MessageBox.Show(messageLocalStorage);
} else{
LocalStorage.SetString("Example Message", "This is just an example message");
}
But finally I can't retrieve with the GetString, I have always an empty MessageBox.
Could you help?
Thank you
Replies
sebastien.t
13 Mar 2024, 15:21
( Updated at: 14 Mar 2024, 05:57 )
RE: LocalStorageScope on Mac
PanagiotisCharalampous said:
Hi there,
Can you share the complete cBot code you are using and screenshots of your log after executing the cBot?
Best regards,
Panagiotis
My code of the Cbot is definitly too long to share (and also don't want to share all my trading rules….).
But here is my test at the very beginning of the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using Microsoft.VisualBasic;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.FullAccess)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 120)]
public int OfDepthCalculation { get; set; }
private TextBlock _DOFTextBlock, _H4OFTextBlock, _H1OFTextBlock, _TradeAllowTextBlock, _TradeAVailableTextBlock;
private Telegram telegram = new Telegram();
private Grid grid;
protected override void OnStart()
{
string messageLocalStorage = LocalStorage.GetString("Example-Message");
if (messageLocalStorage is not null)
{
MessageBox.Show(messageLocalStorage);
} else{
LocalStorage.SetString("Example-Message", "This is just an example message");
}
Screenshot of the log :
Thank you for your help
@sebastien.t
sebastien.t
13 Mar 2024, 20:50
( Updated at: 14 Mar 2024, 05:57 )
RE: RE: LocalStorageScope on Mac
sebastien.t said:
PanagiotisCharalampous said:
Hi there,
Can you share the complete cBot code you are using and screenshots of your log after executing the cBot?
Best regards,
Panagiotis
My code of the Cbot is definitly too long to share (and also don't want to share all my trading rules….).
But here is my test at the very beginning of the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using Microsoft.VisualBasic;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.FullAccess)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 120)]
public int OfDepthCalculation { get; set; }
private TextBlock _DOFTextBlock, _H4OFTextBlock, _H1OFTextBlock, _TradeAllowTextBlock, _TradeAVailableTextBlock;
private Telegram telegram = new Telegram();
private Grid grid;
protected override void OnStart()
{
string messageLocalStorage = LocalStorage.GetString("Example-Message");
if (messageLocalStorage is not null)
{
MessageBox.Show(messageLocalStorage);
} else{
LocalStorage.SetString("Example-Message", "This is just an example message");
}
Screenshot of the log :
Thank you for your help
That s all good. I fixed my issue. It was some special character inside the key.
@sebastien.t
PanagiotisCharalampous
13 Mar 2024, 10:49
Hi there,
Can you share the complete cBot code you are using and screenshots of your log after executing the cBot?
Best regards,
Panagiotis
@PanagiotisCharalampous