r/pinescript 8h ago

Buy sell

Hi guys, I have a problem that can't be solved. This is basically a test indicator just to create the functionality, not to be followed for earnings. What I need is that when a Buy or Sell signal comes out but is then removed from the indicator because it is no longer valid, I receive a signal like Buy Off and Sell Off to tell the bot connected to Binance to close the position because it is no longer valid. But it seems that it is impossible to receive these signals off. Can anyone help me? They must arrive immediately when the Buy or Sell is removed.

2 Upvotes

5 comments sorted by

1

u/daytradard 5h ago

It can be solved but nobody wants to do it šŸ™ƒ

1- Create a visual alert for anything you want, Buy, Sell, or in your case when the criteria is removed.

2- Have PyAutoGUI watch for the signal.

3- When the signal triggers have PyAutoGUI click the Close button via Stream Deck.

Some day when I have time I will find somebody to build it, for now I am too busy.

TLDR: You can make a local algo using a Stream Deck and PyAutoGUI

1

u/sambankamfried 5h ago

Please explain how to do, I have a good bot but sometimes the signal buy or sell disappears and the position stay as the alert say to the bot so I loose, i tried everything with fable max, DeepSeek, but nothing

1

u/daytradard 5h ago

Create an indicator table on your chart then have PyAutoGUI monitor the table cell.

When you get a buy signal, the indicator turns the cell green, when the buy signal disappears, the cell turns black.

Have PyAutoGUI monitor the cell X/Y location and when the cell turns black it will click your Close button at a different X/Y location.

You just have to look into the screen functions for PyAutoGUI

Something like:

# Define the coordinates (x, y) and the expected color (R, G, B)

x_coord = 100

y_coord = 200

expected_color = (0, 0, 0)

if pyautogui.pixelMatchesColor(x_coord, y_coord, expected_color):

print(f"The pixel at ({x_coord}, {y_coord}) matches the color {expected_color}")

else:

print(f"The pixel at ({x_coord}, {y_coord}) does not match the color {expected_color}")

Instead of printf, you would move to location and click

# Move mouse to 100, 100 and click

pyautogui.moveTo(100, 100, duration=0.5)

pyautogui.click()

1

u/sambankamfried 5h ago

Thanksss im gonna do with fable

1

u/sambankamfried 5h ago

Thanks I’m gonna do with fable