BitMEX-scaled-orders icon indicating copy to clipboard operation
BitMEX-scaled-orders copied to clipboard

Crossover_BUY order and Cross_under SELL order for market order and trailing limit orders)

Open ingnelson opened this issue 4 years ago • 24 comments

@Effanuel Hello master.

Could you add a new feature like this one: Crossover_BUY and Cross_under SELL ( for market order and trailing limit orders) .

Bitmex website has a more or less this feature , but it is manually. It is using "Stop Market , but unchecking close on trigger box "

image

The program has to save in memory this order or algorithm and execute it when the market achieve that rule (crossover and crossunder) on the selected price ?

I know that every feature you had launched have the best quality .

This features help the traders have more possibility to have a win trade, because the trade is excecuted on the market trend .

This feature help when traders use strategies like these ones :

  • Support and resitance ( Rectangular, triangle or any shape).
  • Cross moving average (EMAs , MA , etc.)

I think many people is going to use it, i think it is very useful. Now that you have Maket orders and Trailing orders would be a little more easy for you.

This orders or algorithm help a lot ; this is a logic and useful feature .

I will wait your reply.

ingnelson avatar Sep 09 '20 23:09 ingnelson

@ingnelson Hey, if I understand correctly, crossover-market-buy would mean, that it would place a market order when the price crosses your set price, and crossover-trailing-buy, the same thing, but with a trailing order?

This feature looks pretty simple, maybe I will be implement it in a day or two.

Effanuel avatar Sep 13 '20 19:09 Effanuel

@Effanuel yes , for market order and trailing order. The client select the order type. I will explain with examples below:

crossover_buy = it triggers only and only when the current price cross from down to up the set-up price .

Example crossover_buy :

image

current price = $1010 We program a crossover_buy at $1000 on the program

So the price goes down to $ 999.5 nothing happen, but if the prices goes up again to 1000 , the program execute the crossover_buy automatically.

Example crossunder_sell:

image

Crossunder_sell = it triggers only and only when the current prices cross from up to down the set-up price .

current price = $1000 We program a crossunder_sell at $1009 on the program.

So the price goes up to $ 1009.5 nothing happen, but if the prices goes down again to 1009 , the program execute the crossunder_sell automatically.

Note : as you see it is not a simple cross price, it has a rule. This is the reason for crossover and crossunder.

This is more than great !!!

ingnelson avatar Sep 14 '20 02:09 ingnelson

Ok, this may be a little more complex. I'll post here as soon as I get some kind of a working prototype.

Effanuel avatar Sep 14 '20 17:09 Effanuel

@Effanuel perfect, first think if there is a way to do it like I said .

Check this repository , maybe it can give you a idea how to implement the crossover and crossunder.

https://github.com/amaduskar/MACD-Based-Trading-Strat/blob/master/MACD%20Based%20Trading%20(1).ipynb

By the way : I was thinking all the week if there is easy way to implement it , but I had only 1 idea , it is not the best option look :

Crossover_buy: The program execute the order on any of this rules :

1)If the current price is "below" the set price , so the program execute the order when the current price touch the set price. 2) If the current price is "above" the set price , so the program execute the order when the current price touch 2 times the set price ( 1 touch when the current price cross from up to down and the second touch when the current price cross again from down to up )

What do you think ? This is a chunk or no so good way do it , right ? Only you know how to implement it , I would like your hear your comments, please.

ingnelson avatar Sep 14 '20 18:09 ingnelson

@ingnelson Yup, my idea was the same. Just instead of touching the same price twice, it would know whether the price has gone below that price, and then gone above.

Effanuel avatar Sep 14 '20 19:09 Effanuel

@Effanuel one last question, just to be sure: The program is going to calculate if the current price is above or below the set price , right ? Example buy cross order :

if the current price is above the set price , the program need 2 times cross . if the current price is below the set price , the program only 1 time cross.

sell cross order :

if the current price is above the set price , the program need 1 time cross . if the current price is below the set price , the program only 2 times cross.

This way we can trade for counter trend trades (the first picture i uploaded on the second message) and break trades. too.

breakup trade example:

image

image

ingnelson avatar Sep 17 '20 02:09 ingnelson

@ingnelson Yes, this is exactly how it would work. The only thing I have a question about is it better to use stop-market without close-on-trigger or let the program handle buying a market order. I would need to see which one is faster.

Effanuel avatar Sep 17 '20 15:09 Effanuel

@Effanuel i think about that too. This depend about the speed the program place the order.

on 2 times cross : on wicks or tail where the price move so so fast: is the program fast enough to place a order after the first cross before the wick or the price move back again ? if the aswer is no , so it would be better the program handle buying a market order after the second cross.

on 1 time cross: i think would be more faster the program handle buying a market order unless the order is placed before the first cross using stop-market without close-on-trigger , but only testing it. so maybe when only is needed 1 time cross is better stop-market without close-on-trigger .

it would be interesting make a test.

ingnelson avatar Sep 17 '20 15:09 ingnelson

@Effanuel If you create 2 bitmex account and place the order on the same price : on the first account use stop-market without close-on-trigger , so placed and it is waiting the current price touch it. on the second account let the program handle buying a market order at the set price. ? this will show who is more faster to execute the order, i think.

ingnelson avatar Sep 17 '20 17:09 ingnelson

I have made an initial implementation on Cross-Orders branch. You can git checkout Cross-Orders and try it yourself. (its not done, so just be aware) I have tried to compare my programs speed vs stop-market, and it seems that my program is slower by about 4 seconds average. The fact that I am using React with Node, the delay is so big. I will take a look at the code, and see what I will be able to do.

Effanuel avatar Sep 17 '20 18:09 Effanuel

@Effanuel could you give all the command i need to type to check or update the cross-order , please ? i do not know how to do it . do i need to clone https://github.com/Effanuel/BitMEX-scaled-orders/tree/Cross-Orders ?

git clone https://github.com/Effanuel/BitMEX-scaled-orders/tree/Cross-Orders
git checkout Cross-Orders

How i do it ? i am not so good with github.

then use the other command to install everything again ?

ingnelson avatar Sep 17 '20 18:09 ingnelson

Just download zip from here https://github.com/Effanuel/BitMEX-scaled-orders/archive/Cross-Orders.zip, and do the same steps you would normally do:

--put API keys in .env file--
cd api/
npm run init:packages
npm run build 
npm run prod

With git checkout you wouldn't need to clone, and before installing packages, you would have to delete node_modules/ folders.

Effanuel avatar Sep 17 '20 19:09 Effanuel

@Effanuel i just try it , the cross order works like you said :) if you could speed up a the program or the code to execute it more faster would be great. on fast movement of the price, the order is executed more or less $ 6 (12 steps) away from the set price. I think it is the delay of using React with Node like you said early.

ingnelson avatar Sep 17 '20 23:09 ingnelson

@ingnelson How is this different from stop market and take profit order? Basically what you want is OCO/OSO type orders http://help.tradestation.com/09_01/tradestationhelp/ob/about_oco_oso_templates.htm

Poilaucul avatar Sep 18 '20 00:09 Poilaucul

@Poilaucul this feature (cross order) could be use as OCO/OSO too.

OCO/OSO = stop-market without close-on-trigger

This new feature has a improvement example when the trader need to buy when the current price is above the set price (2 times cross), because the order always be executed when the current price cross from down to up :) , so we can place the order ahead on time.

We just want to know which order is executed more faster : stop-market without close-on-trigger or a automatically market order

ingnelson avatar Sep 18 '20 01:09 ingnelson

From what I can see, placing a stop-market order instead of letting the program execute market order is faster.

Effanuel avatar Sep 18 '20 09:09 Effanuel

@Effanuel this is my final thought:

on buy order and current price is below the set price : it is better placing a stop-market order without close-on-trigger. on sell order and current price is above the set price : it is better placing a stop-market order without close-on-trigger.

on buy order and current price is above the set price : it is better the program execute the market order after the second cross, because if there is a wick or trail move on the set price we are sure the order is going to be execute it. on sell order and current price is below the set price : it is better the program execute the market order after the second cross, because if there is a wick or trail move on the set price we are sure the order is going to be execute it.

This are the best options for this orders types.

ingnelson avatar Sep 18 '20 16:09 ingnelson

I think we can improve performance, by reducing subscriptions to tickers. There is a file ./client/src/redux/modules/websocket/websocketModules.ts and there is a line 116 that subscribes to tickers:

const subscribe = instrumentTopics(SYMBOLS.XBTUSD, SYMBOLS.ETHUSD, SYMBOLS.XRPUSD);

Try to replace it with this:

const subscribe = instrumentTopics(SYMBOLS.XBTUSD);

It should then subscribe to only XBTUSD and reduce the number of iterations needed to update store on websocket message. From a few tests I have done, it is a little bit faster than before.

Effanuel avatar Sep 18 '20 16:09 Effanuel

Just change the line and do:

cd api/
npm run clean
npm run build
npm run prod

Effanuel avatar Sep 18 '20 17:09 Effanuel

@Effanuel i have testing it all the day the cross feature and i see that placing a stop-market order without close-on-trigger is better because it execute faster the order .

when program execute the market order after the second cross the price moved too much.

So the best option is place the stop-market order without close-on-trigger after the first cross for buy order and current price is below the set price and sell order and current price is above the set price.

on the buy order and current price is above the set price and sell order and current price is below the set price , place the stop-market order without close-on-trigger right away.

ingnelson avatar Sep 18 '20 20:09 ingnelson

@Effanuel I love crossover or crossunder orders :) . We as a traders just need to find the volatility area or the area with 2 or more wicks and place the cross buy
Example :

Screenshot_2020-10-17-09-28-43-884_com tradingview tradingviewapp

Btc like to visit those areas , I think for this reason :

  1. take the liquidity from support or resistance .
  2. touch the stop-loss orders and take their money.

ingnelson avatar Oct 17 '20 15:10 ingnelson

Hi! Very intresting project in my eyes. Thanks for sharing. I get an error on the CrossOrder branch.

Creating an optimized production build... Failed to compile.

./src/containers/CrossOrder/CrossOrderContainer.tsx Attempted import error: 'CROSS_ORDER_CONTAINER' is not exported from 'data-test-ids'.

I'm not sure if its an error on my side or yours. Any input is very appriciated.

andy1245 avatar Nov 12 '20 21:11 andy1245

Hey, sorry for late response. I have been very busy past this month. I will take a look at the problem you are having and will try to release this feature officially tomorrow, which is about 23 hours from this message. @andy1245

Effanuel avatar Nov 12 '20 22:11 Effanuel

Pushed changes to Cross-Orders branch. Try to remove node_modules/ folder, run npm run clean` and repeat the installation steps. The build works for me. @andy1245

Effanuel avatar Nov 12 '20 22:11 Effanuel