Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hi
So I have this code that should stop me out x number of cents above HOD. However it seems like if the candle that breaks HOD doesn't have a price within the number of cents I set above HOD, then it waits several candles before it triggers at a much higher price. I need the code to trigger exactly when the condition is.(Not taking into account slippage with realtime data) this is from backtesting the code on AMC from 09.27.22 :
Ex1: Stop price is set at 2 cents above HOD (7.37). Here it stops me out at 7.39 (which it should, since its 2 cents above HOD (this is also the highest price of the same candle that breaks HOD):
Ex2:
Stop price is set at 3 cents above HOD (7.37). Here it stops me out at 7.46, 3 candles after it breaks HOD. It should have stopped me out at next candle at 7.4:
here is the code:
If I use int (to force it to be a integer) the same thing happens.
Anyone know what's going on?
Can you help answer these questions from other members on NexusFi?
I would suggest checking the values within your code to make sure that they are what you expect them to be (either using the print reserved word or the debugger).
Your screenshot cuts some important pieces from the code, but it appears you might be evaluating SetStopLoss conditionally. Depending on the condition you are using this might be causing delays.
The only condition is that the short market position is not equal to 0. It takes the high of day minus the entryprice and plus the 3 cents, so when the market position reach that amount it should stop me out.
no, it should not. You are updating the stop with every higher high, though. Maybe you are simply moving the stop away and this is causing the delay.
I would suggest checking the values within your code to make sure that they are what you expect them to be (either using the print reserved word or the debugger).
Hi, I counted the number of cents its above the new candle that makes the new HOD, and it make sense to where it stopped out. Now I just have to find a way for it to stop out at correct price. I can either calculate it from the previous high of day, if there is such a function. OR I can:
(highD(0)-entryprice)*number of shares shorted = normal risk value (dollars)
+
(multiple the number of shares shorted with 5 cents = extra risk value)
=
Total dollar amount to lose
Then have a code to stop me out when total dollar amount is reached. I'm gone try that.