//BUYING PART!!
if (!invested && symbolData.Factor >= 3 && symbolData.LowestAverage >= price) // && _btc > _minPosition
{
if (symbolData.MacdChange >= 0 & symbolData.MacdChange < 2)//&& symbolData.MacdChange < 2
{
//PLACING ORDER
var quantity = NormalizeQuantity(symbol, btcAmount / data[symbol].Close);
if (quantity == 0) continue;
MarketOrder(symbol, quantity);
Plot("Trades", "AANKOOP", price);
Debug($"Aankoop: {symbol} {data[symbol].Price} ter waarde van {usdAmount}"); // Als het order gemaakt is word dit bevestigd door de debug
Notify.Email("david.wittevronghel@gmail.com", "TradeAlert",$"Gekocht {symbol} op {data[symbol].Price}");
Log($"prijs {price} en Max 24uur {symbolData.MaxExchange} en MIN 24uur {symbolData.MinExchange}");
symbolData.TargetPrice = price * (1 + _targetPercent); //DETERMINE WICH SELLING PRICE WHEN PROFIT.
symbolData.StopPrice = price * (1 - _stopPercent); //DETERMINE WICH SELLING PRICE WHEN LOSS.
}
}
//SELLING PART!!
if (invested)
{
if (price >= symbolData.TargetPrice)
{
Debug($"Verkoop Winst: {symbol} {data[symbol].Price}"); // Als het order gemaakt is word dit bevestigd door de debug
Plot("BTC", "Holdings", Portfolio.CashBook["BTC"].Amount);
Plot("Trades", "VERKOOP WINST \n", price);
var tag = $"+1% WINST VERKOCHT {symbol} op {data[symbol].Price}";
// Alex: let's tag the order instead of adding to the logs
LimitOrder(symbol,-symbolData.Holding, symbolData.TargetPrice);
//Liquidate(symbol, tag);
//MarketOrder(symbol, -symbolData.Holding);
//Log(tag);
//Notify.Email("...@gmail.com", "TradeAlert", tag);
}
if (price < symbolData.StopPrice)
{
Debug($"Verkoop Verlies: {symbol} {data[symbol].Price}"); // Als het order gemaakt is word dit bevestigd door de debug
Plot("BTC", "Holdings", Portfolio.CashBook["BTC"].Amount);
Plot("Trades", "VERKOOP VERLIES \n", price);
var tag = $"-10% VERLIES VERKOCHT {symbol} op {data[symbol].Price}";
// Alex: let's tag the order instead of adding to the logs
LimitOrder(symbol,-symbolData.Holding, symbolData.StopPrice);
//Liquidate(symbol, tag);
//MarketOrder(symbol, -symbolData.Holding);
//Log(tag);
//Notify.Email("...@gmail.com", "TradeAlert", tag);
}
}
I have several types of sell orders. (Liquidate,, MarketOrder)
But the problem with Liquidate or Marketorder is when I want 1% profit with the Targetprice the order isn't sold with 1% profit. Mostly it is less than 1%.
And also the exchange fee is 0.2% taker fee and 0.1% maker fee.
But now I want a LimitOrder cause then the order will only be executes when the Targetprice or Stopprice is reached.
My question is now: is the LimitOrder inplemented correctly for both sell orders?
Thanks in advance,
David
Derek Melchin
Hi Vronghel,
For assistance setting TP and SL orders, refer to this thread.
In addition, our Reality Modeling documentation outlines how to set maker and taker fees. Refer to the Bitfinex Fee Model as an example.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Vronghel
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!