Copy button for Values

Created at 08 Jan 2025, 11:03
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AL

algobeginner

Joined 15.12.2024

Copy button for Values
08 Jan 2025, 11:03


Hello Everyone , 

I'm trying to create a simple indicator to copy open candle price , but I'm struggle to find logic to copy into clipboard and not only into log or file .

Here is example I have used which doesn't function because I'm stuck :

using cAlgo.API;


 

namespace cAlgo

{

 

[Indicator("Open Value Indicator", TimeZone = TimeZones.UTC, AccessRights = AccessRights.None, IsOverlay = true)]

public class OpenValueIndicator : Indicator

{

private Button copyOpenValueButton;

private double openValue;


 

protected override void Initialize()

{

// Create a button to copy the open value

copyOpenValueButton = new Button

{

Text = "Copy",

Margin = 10,

HorizontalAlignment = HorizontalAlignment.Right,

VerticalAlignment = VerticalAlignment.Top

};


 

// Subscribe to the button click event

copyOpenValueButton.Click += CopyOpenValueButton_Click;


 

// Add the button to the chart

Chart.AddControl(copyOpenValueButton);

}


 

// handler

private void CopyOpenValueButton_Click(ButtonClickEventArgs obj)

{

// pen value of the current candle

openValue = Bars.OpenPrices.Last(0); // Get the open price of the current candle


 

// Log

Print("Copied Open Value: " + openValue.ToString("F5"));

}


 

// Calculate method {empty}

public override void Calculate(int index)

{

 

}

}

}


@algobeginner
Replies