Toolbar not Launching on Startup  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Toolbar not Launching on Startup

Postby Jobauma » 19 Nov 2018

Hi.

I have an indicator (with a toolbar) that does not launch on startup, but I can manually change the status in "Format indicators..." to "on", after startup. Then it works. :D

Error message:

Code: Select all

Messsage: Error in study “[Indicator Name]
(EUR.USD-3 Minute)” :
Custom ToolBar can not be created.
Unable to run the study.
Please manually change the Status of the study in
Format Study window.
I'm wondering what is wrong with the toolbar code. :(



Best regards,
Johannes Hillestad Baumann

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Bug: Toolbar not Launching on Startup

Postby Svetlana MultiCharts » 21 Nov 2018

Hello, Johannes

This behaviour is not reproduced on our end. Please send us an example of study with which the issue is replicated, and step-by-step instruction how to reproduce it.

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 22 Nov 2018

Hi.

Thanks for your reply.

Here is the ToolBar Code:

Code: Select all

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;






namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
[RecoverDrawings(false)]



public class _Jobauma_BuySell_ToolBar_Illustration : IndicatorObject
{
private double m_ToolBar_Set_Point;

int m_ToolBar_Setback = 0,
m_ToolBar_TakeProfit = 210, m_ToolBar_StopLoss = 50,
m_ToolBar_Breakeven_PlusPoints = 80, m_ToolBar_Breakeven_Step = 0,
m_ToolBar_Trailing_PlusPoints = 130, m_ToolBar_Trailing_Step = 50;



private bool m_Buy, m_Sell, m_Delete;



private bool m_Toolbar_Inited = false;



public _Jobauma_BuySell_ToolBar_Illustration( object _ctx ) : base(_ctx)
{
}



protected override void Create()
{
}



private void TSB_Buy( object Sender, EventArgs E )
{
m_Buy = true;
m_Sell = false;
}

private void TSB_Sell( object Sender, EventArgs E )
{
m_Sell = true;
m_Buy = false;
}

private void TSB_Delete( object Sender, EventArgs E )
{
m_Delete = true;

m_Buy = false;
m_Sell = false;
}



private void NUD_Setback_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_Setback != NewValue.Value )
m_ToolBar_Setback = (int)NewValue.Value;
}

private void NUD_TakeProfit_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_TakeProfit != NewValue.Value )
m_ToolBar_TakeProfit = (int)NewValue.Value;
}

private void NUD_StopLoss_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_StopLoss != NewValue.Value )
m_ToolBar_StopLoss = (int)NewValue.Value;
}

private void NUD_BreakevenPlusPoints_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_Breakeven_PlusPoints != NewValue.Value )
m_ToolBar_Breakeven_PlusPoints = (int)NewValue.Value;
}

private void NUD_BreakevenStep_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_Breakeven_Step != NewValue.Value )
m_ToolBar_Breakeven_Step = (int)NewValue.Value;
}

private void NUD_TrailingPlusPoints_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_Trailing_PlusPoints != NewValue.Value )
m_ToolBar_Trailing_PlusPoints = (int)NewValue.Value;
}

private void NUD_TrailingStep_Changed( object Sender, EventArgs E )
{
var NewValue = (NumericUpDown)Sender;

if ( m_ToolBar_Trailing_Step != NewValue.Value )
m_ToolBar_Trailing_Step = (int)NewValue.Value;
}



private void AddItemToolStrip( ToolStrip TB, ToolStripItem Item )
{
Item.Tag = this;
TB.Items.Add(Item);
}



protected override void StartCalc()
{
if (!m_Toolbar_Inited)
{
ChartToolBar.AccessToolBar( TB =>
{
{
var TSB = new ToolStripButton
{
Text = "Buy"
};

TSB.Click += TSB_Buy;
AddItemToolStrip( TB, TSB );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var TSB = new ToolStripButton
{
Text = "Sell"
};

TSB.Click += TSB_Sell;
AddItemToolStrip( TB, TSB );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var TSB = new ToolStripButton
{
Text = "Delete"
};

TSB.Click += TSB_Delete;
AddItemToolStrip( TB, TSB );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Setback:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 233,
Increment = 10,
Value = m_ToolBar_Setback
};

NUD.ValueChanged += NUD_Setback_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Take Profit:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 1000,
Increment = 10,
Value = m_ToolBar_TakeProfit
};

NUD.ValueChanged += NUD_TakeProfit_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Stop Loss:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 987,
Increment = 10,
Value = m_ToolBar_StopLoss
};

NUD.ValueChanged += NUD_StopLoss_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Breakeven Plus Points:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 987,
Increment = 10,
Value = m_ToolBar_Breakeven_PlusPoints
};

NUD.ValueChanged += NUD_BreakevenPlusPoints_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Breakeven Step:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 987,
Increment = 10,
Value = m_ToolBar_Breakeven_Step
};

NUD.ValueChanged += NUD_BreakevenStep_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Trailing Plus Points:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 987,
Increment = 10,
Value = m_ToolBar_Trailing_PlusPoints
};

NUD.ValueChanged += NUD_TrailingPlusPoints_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}

AddItemToolStrip( TB, new ToolStripSeparator() );

{
var N = new ToolStripButton
{
Text = "Trailing Step:"
};

AddItemToolStrip( TB, N );
}

{
var NUD = new NumericUpDown
{
Minimum = 0,
Maximum = 987,
Increment = 10,
Value = m_ToolBar_Trailing_Step
};

NUD.ValueChanged += NUD_TrailingStep_Changed;
AddItemToolStrip( TB, new ToolStripControlHost(NUD) );
}
});

m_Toolbar_Inited = true;
}
}



protected override void CalcBar()
{
if ( m_Buy || m_Sell )
{
// Code Trigger.

m_Buy = false;
m_Sell = false;
}

if (m_Delete)
{
// Code Trigger.

m_Delete = false;
}
}



protected override void Destroy()
{
if (m_Toolbar_Inited)
{
ChartToolBar.AccessToolBar( TB =>
{
var For_Erase = new List<ToolStripItem>();

foreach ( ToolStripItem Item in TB.Items )
if (ReferenceEquals( this, Item.Tag ))
For_Erase.Add(Item);

foreach ( var Item in For_Erase )
TB.Items.Remove(Item);
});
}
}
}
}
I hope there is a solution. :)



Best regards,
Johannes Hillestad Baumann

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 24 Nov 2018

I also get this error ( I attached an image ).

The line of the error (615) is the same as " ChartToolBar.AccessToolBar( TB => ", in the previous ToolBar code i sent.



Best regards,
Johannes Hillestad Baumann
Attachments
MultiCharts Jobauma BuySell - Error.png
(79.83 KiB) Downloaded 755 times

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 24 Nov 2018

By the way, I have to completely remove and insert the indicator if this error occurs. Pressing " Format Indicators... > Status " doesn't work.

User avatar
Svetlana MultiCharts
Posts: 645
Joined: 19 Oct 2017
Has thanked: 3 times
Been thanked: 163 times

Re: Bug: Toolbar not Launching on Startup

Postby Svetlana MultiCharts » 06 Dec 2018

Hello, Jobauma,

We have tried to apply this toolbar and it works correct on our end.
Please come to our Live Chat to demonstrate the issue via remote connection MON-FRI from 6:30 AM to 12:00 PM EST (11:30 AM to 5:00 PM GMT). Live Chat is accessible from our web site http://www.multicharts.com/ (at the top of the page). We'll do our best to help you.

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 07 Dec 2018

Hi.

I use VMware Fusion 11, because I use Apple products. Everything is fine with this emulator. How could you see if this is the issue? Can this be fixed via MultiCharts, or has it to be fixed via VMware Fusion? By the way, I have installed Windows 10 Home on this emulator. :) I have no problems with MultiCharts, except these two errors ( from an indicator ). I followed the ToolBar example included in the installation of MultiCharts, so I guess this has to be the problem. I can not think of anything else.

I hope you needn't buy VMware Fusion to fix this, or to see if it is the issue at all. :)




Best regards,
Johannes Hillestad Baumann

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 15 Dec 2018

Hi.

By the way, I don't think it is VMware Fusion that is the cause, because if it doesn't work with a timeframe, it can work with another one. The behaviour is always the same with a chart that fails to load the ToolBar, and not with one that succeeds to load it.

The reason why the buttons not working all the time can perhaps be a synchronicity issue with VMware Fusion.



Best regards,
Johannes Hillestad Baumann

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup

Postby Jobauma » 15 Dec 2018

I think I've found the problem. If one loads for example 14 charts * 10 workspaces ( just to be sure ), then the error occurs. :)

Why the buttons doesn't trigger all the time, I'm not sure. "TSB_Delete" does, but "TSB_Buy" and "TSB_Sell" doesn't. The code works on "close", but the buttons doesn't seem to remember it's action until a bar closes. In a new version I made "TSB_Delete" triggers "ExecControl.Recalculate();" directly. This works instantaneously every time. It doesn't work indirectly with "bool". I've tried to convert the "bool"-s with " Variable Series ", but I don't know how to integrate "out" with the button methods.



Best regards,
Johannes Hillestad Baumann

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

Re: Bug: Toolbar not Launching on Startup  [SOLVED]

Postby Jobauma » 15 Dec 2018

Yes!

I finally found that it is all together just one issue. It seems to be a RAM issue ( with 14 charts * 10 workspaces ). It doesn't matter; all 10 workspaces for one MultiCharts process, or two MultiCharts processes ( with half and half ). I've set up 24 GB of RAM ( 2400 MHz DDR4 · Originally 32 GB ) for the emulator ( VMware Fusion 11 ). Or perhaps it's the CPU. I've set up 6 processor cores ( 2,9 GHz Intel Core i9 · Originally 12 cores ).

Now the buttons respond all the time. :)



Best regards,
Johannes Hillestad Baumann


Return to “MultiCharts .NET”