BUY and SELL buttons set int value for OnTick and OnBar

Created at 07 Nov 2022, 19:21
FR

freek.kammeijer

Joined 07.11.2022

BUY and SELL buttons set int value for OnTick and OnBar
07 Nov 2022, 19:21


Hello,


Beginner automater here trying to create an application for my trading. Maybe there is an easier way, please let me know :)

I modified the SAMPLE TRADING PANEL code a bit.

I don't want the buttons to execute an order when clicked since the OnTick will check if I want to place a BUY or SELL order and also check if other parameters are met.

So Im trying to set a certain value if the SELL or BUY button is clicked so that the OnTick and OnBar are able to read and modify it.

For instance pressing BUY will return value 2 and SELL will return value 3.

 

public class MyRobot: Robot

....

 

public int orderType { get; set; }

.....

 

Section OnTick()

      if orderType = 2 && other parameters are met

      BUY code

      If orderType = 3 && other parameters are met

      SELL code

 

Section OnBar()

     OrderType = 0;

 

  public class TradingPanel : CustomControl

......

  public int orderTypeTP { get; set; }
 

  private Button CreateTradeButton(string text, Style style, TradeType tradeType)
        {
            var tradeButton = new Button
            {
                Text = text,
                Style = style,
                Height = 25
            };

            tradeButton.Click += args => StateValue(tradeType, orderType); 

            return tradeButton;
        }

        private void StateValue(TradeType tradeType, orderTypeTP)
        {
            if (tradeType == 0)
            {
                orderTypeTP = 2; //Buy int
                _robot.Print(orderType);
            }
            else
            {
                orderTypeTP = 3; //Sell int
                _robot.Print(orderType);
            }
        }

......

I can print the correct values but I do not know how send those over to the MyRobot class so the OnTick and OnBar can work with it.

I've tried creating new instances etc but Im just in the dark tbh.

 


@freek.kammeijer