open a new operation in a new instance
open a new operation in a new instance
26 Mar 2020, 09:06
hi how can i do this?
I have an open position on an instance, when this operation reaches the stop loss or take profit, the bot must open another operation in another instance
what is the code to do this?
Replies
luca.tocchi
26 Mar 2020, 09:57
RE:
PanagiotisCharalampous ha detto:
Ciao Luca,
possibile utilizzare l'evento Position.Closed per tracciae quando un posizione parte chiuso e imprevedibile un'azione. Sotto vedi un esempio
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { Positions.Closed += Positions_Closed; } private void Positions_Closed(PositionClosedEventArgs obj) { } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Migliori saluti
Panagiotis
Thanks! ok i use the event closed position. but to open a random instance, at the beginning of the program, without a condition occurring?
@luca.tocchi
PanagiotisCharalampous
26 Mar 2020, 13:47
Hi Luca,
To open a position at the start of the cBot use the OnStart() method.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
26 Mar 2020, 09:24
Hi Luca,
You can use Position.Closed event to monitor when a position is closed and take an appropriate action. See below an example
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous