user2105237
user2105237

Reputation: 525

Ideas to change the price value using javascript on Trading View Order

I am working on order automation for Trading View. Although I have been able to make some progress, changing the price for limit orders (as well as the quantity, any number) has been a challenge. I am able to change the value on the input but it doesn't really get updated in the app model (hence the buy button never reflects the change).

Any help will be highly appreciated.

Best enter image description here

Upvotes: 0

Views: 378

Answers (1)

Abror Abdullaev
Abror Abdullaev

Reputation: 279

Sometimes the view of the value is not bidirectional connected to the hidden input field. Seems like the trading app is using some reactive framework, they usually integrate some UI components library, and those libraries hide the real input field in behind the beautiful mask of the ux oriented view on the front side.

Here you have 2 options

  1. Try to set the value of hidden input field in behind the component and try to send the request to see if the new value is fetched, no matter if its visible on front or no

  2. I think more user friendly option, to trigger the events on the HTML elements, this will require more research from your side to learn how to trigger events and check the results of those events step by steps. If you already know it then it will be fast. For Example:

// Let's say pure js

// Keep in mind, id of element, not a hidden input field.
const dropdown = document.getElementById('idOfHTMLElement');
dropdown.click(); // After click the options of the dropdown should appear

const options = Array.from(document.getElementsByClassName('classNameOfDropDownOption'));
const desiredOption = options.find((option) => option.someConditionLikePriceOrSmthElse: boolean);

desiredOption.click();

// Something like this, not accurate code, please test and correct if you will use this

Upvotes: 1

Related Questions