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 -- discounts are available after registering.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Im about to blow my head off with frustration on a coding issue i cannot figure out. I have a strat i am running on daily renkos. The entry is not relevant but i am having an issue with my trailing stops in the strategy. The logic i am trying to code is relatively simple.
A trailing stop off the last pivot low that moves up after a new higher pivot low is formed. The initial stop is the higher of the last pivot low or 95% of the entry price. see code excerpt below:
if marketposition = 0 then
begin
if condition7 then buy 100 shares next bar at market;
end;
//Long Stop Language
Condition20 = PivotLowVSBar( 1, low,Leftstrength, rightstrength, rightstrength+1) <> -1 ; // if new pivot low forms this is true
if marketposition = 0 and condition20 then longpivotstop = Low[rightStrength]; // when flat and a new pivot low forms, the intrabarpersist variable longpivotstop is set
//equal to the Low of the bar at the new pivot
if marketposition = 1 and condition20 and Low[rightstrength]>Longpivotstop then LongPivotStop = Low[rightStrength]; // when long and a new pivot forms that is higher than the last
//pivot low, longpivotstop is reset to the new higher low.
if marketposition = 1 then begin
currentlongstop = Entryprice*.95; //sets initial stop to 5% from entryprice
If Longpivotstop > currentlongstop and longpivotstop<last then currentlongstop = longpivotstop;
Sell ( "Pivot LX" ) next bar at currentlongstop stop;
end;
The above code seems to generally work ok but there is something i am missing. See attached screen shot i marked up.
Any ideas with what i am screwing up in my logic? its making me crazy.....
Can you help answer these questions from other members on NexusFi?
Please remember Renko's and backtesting don't go well together. Renko's have false opens, and all backtest results will be false.
Best way to troubleshoot your issue in my opinion would be to print the trailing stop price to a debug window, along with a time stamp, so you can see what is happening.
I assume if you change the dataseries to something less exotic, like a 1-range bar, that it works correctly? If so, likely the issue is the Renko bar itself and the false prices.
You could make the first dataseries a 1-range, and the second dataseries your Renko. MultiCharts only allows execution on the first dataseries. Signals could be generated from the secondary series.
hey mike - i did what you said and figured out my logic issue. if anyone wants the code for trailing pivots i came up with i can post. many thanks
one quick follow up question - I am struggling with coding renkos as data2 for triggering entries and exits. my issue comes with data1 (regular minute bars) having many more bars than data2 (renkos). when there are no renkos in data2 - i get entries and exits on data1.
Im sure there is some boneheaded function i am missing. I tried using "barstatus <> = -1" but that only fixed some of my incorrect entries on data1.
I have been having trouble creating the code to make a simple renko strategy in easylanguage. Anyway you could share your code? I'd be happy to help you figure out any problems you may be having if that adds any value. Anything would be appreciated.
The biggest problem with Renkos and backtesting is that MC will assume the entry is at open which is pretty much impossible. So I created a BACKTESTING version of my signal to be used ONLY for backtesting, where my signal instructions are the same, but the entries and exits are THIS BAR ON CLOSE... instead of next bar market, limit whatever. This bar on close will give you the closest to real results you will get. I did this and now my live trading results are very similar to my backtesting.