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)
i am using the following code to get only one trade a day but the simulation show few trades a day
what am i doing wrong ?
thanks
variables:
tradesCounter(0);
[IntraBarOrderGeneration = TRUE]
If Date <> Date[1] then begin
tradesCounter = 0;
end;
If (marketposition (0) = 0) and (tradesCounter < 1)then begin
Buy ("BUY-LONG") next bar at market;
end;
If marketposition (0) <> 0 then begin
Sell ("STOPLOSS") next bar at EntryPrice - 0.5;
end;
If ( Marketposition(0) <> 0 ) and (Marketposition(1) <> Marketposition(0) ) then tradesCounter = tradesCounter+ 1;
Setexitonclose;
Can you help answer these questions from other members on NexusFi?
welcome to futures.io. I would suggest to use the Print reserved to check the value that tradesCounter has throughout your code. This will help you in tracking the problem down.
I would also suggest checking (again the print reserved word can be helpful) when your conditional statement "If ( Marketposition(0) <> 0 ) and (Marketposition(1) <> Marketposition(0) )" is true.
thanks
i tried it but it didnt work for me...
when debugging the code i saw that
If Date <> Date[1] then tradesCounter = 0;
tradesCounter is set back to 0 although the date didnt change
meaning a new date => tradesCounter is set to 0 then the Buy kicks in but then on next round although we still on same date tradesCounter is set to 0 again
I am not sure I follow you. The condition "Date <> Date[1]" is only true for two bars that have a different date.
As the code @SMCJB posted is using Intrabar Ordergeneration the tradeCounter variable should be declared as intrabarpersist. Otherwise it won't hold its value between the ticks.