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)
Looks OK.
I cannot reproduce your problem on my computer, so it is difficult for me to help you.
I suggest that you replace all "at st1", "at st2" and "at st3" by "at EntryPrice-0.75" for long and "at EntryPrice+0.75" for long.
If it works, try to put again your current code, but step by step:
Begin with "at EntryPrice-75*TickSize"
Then more and more sophisticated until you understand at which step the problem appear.
if MarketPosition = 0 and barstatus(1) = 2 and Low >= Low[1] and High >= High[1] then begin
//and time>1000 and (time <1600)
//Print("This is the closing tick of the bar.");
// print ("this is buyTrigger = "+ NumToStr(buyTrigger ,0));
// print ("timea = " + NumToStr(Time,0));
print ("ticksize = " + numtoStr(TickSize,2));
//Buy ("Enter Long") 300 Shares Next Bar At (High+buypoint) stop;
Buy ("Enter Long") 300 Shares Next Bar At high stop;
//SellShort("Enter Short") 300 Shares Next Bar at (Low-buypoint) stop;
//print ("this is ticksize = "+ NumToStr(ticksize ,2));
//print ("this is enter = "+ NumToStr(entryprice ,2));
// print ("this is stop = "+ NumToStr(st1 ,2));
// print ("this is stopsize = "+ NumToStr(stopsize ,2));
//
if CurrentShares = 100 then begin
Sell("Exit L300-CS100 Target") 100 Shares next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS100 Stop") 100 Shares next Bar at (EntryPrice-1) Stop;
end;
if CurrentShares = 200 then begin
Sell("Exit L200-CS200 Target") 100 Shares Next Bar at (EntryPrice + t2) Limit;
Sell("Exit L200-CS200 Stop") 100 Shares Next Bar at (EntryPrice-1) Stop;
Sell("Exit L300-CS200 Target") 100 Shares Next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS200 Stop") 100 Shares Next Bar at (EntryPrice-1) Stop;
end;
if CurrentShares = 300 then begin
print ("*********barstatus at exit commands = " + NumToStr(barstatus(1),0));
Sell("Exit L100-CS300 Target") 100 Shares Next Bar at (EntryPrice + t1) Limit;
Sell("Exit L100-CS300 Stop") 100 Shares Next Bar at (EntryPrice-1) Stop;
Sell("Exit L200-CS300 Target") 100 Shares Next Bar at (EntryPrice + t2) Limit;
Sell("Exit L200-CS300 Stop") 100 Shares Next Bar at (EntryPrice-1) Stop;
Sell("Exit L300-CS300 Target") 100 Shares Next Bar at (EntryPrice + t3) Limit;
Sell("Exit L300-CS300 Stop") 100 Shares Next Bar at (EntryPrice-1) Stop;
end;
if CurrentShares = 100 then begin
BuyToCover("Exit S300-CS100 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS100 Stop") 100 Shares Next Bar at st3 Stop;
end;
if CurrentShares = 200 then begin
BuyToCover("Exit S200-CS200 Target") 100 Shares Next Bar at (EntryPrice - t2) Limit;
BuyToCover("Exit S200-CS200 Stop") 100 Shares Next Bar at st2 Stop;
BuyToCover("Exit S300-CS200 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS200 Stop") 100 Shares Next Bar at st3 Stop;
end;
if CurrentShares = 300 then begin
BuyToCover("Exit S100-CS300 Target") 100 Shares Next Bar at (EntryPrice - t1) Limit;
BuyToCover("Exit S100-CS300 Stop") 100 Shares Next Bar at st1 Stop;
BuyToCover("Exit S200-CS300 Target") 100 Shares Next Bar at (EntryPrice - t2) Limit;
BuyToCover("Exit S200-CS300 Stop") 100 Shares Next Bar at st2 Stop;
BuyToCover("Exit S300-CS300 Target") 100 Shares Next Bar at (EntryPrice - t3) Limit;
BuyToCover("Exit S300-CS300 Stop") 100 Shares Next Bar at st3 Stop;
end;
Please use the [ CODE] tags around your code next time.
I still cannot reproduce the problem on my side.
And the problem seems to evolve on your side.
On your last screenshot, the problem does not seem linked to stops, since the last trade was correctly stopped. And you were flat afterwards.
This time, the issue seems that the strategy does not enter trade whereas it is supposed to.
Could you:
1. print the time and the value of CurrentShares at each candle in order to check that you are flat when you are supposed to be flat?
I need the " BarStatus(1) = 2" because I want to enter on the next bar on the break of the prior bar high...
I entered the
print(Date:8:0," ", Time:4:0, " --> CurrentShares = ", CurrentShares);
But I cant decipher the time, is it possible to put the # of shares held Below the bar itself?
Another approach to this whole thing would be to use a 1 minute chart, then what I would do is somehow get the high and the low of the rounded last hour bar... Then if it breaks above that in the next hour it would be a long. That would be the best way.
So that way, I would do the following: I would need a function that would get me the highest high and lowest low of the stock during the rounded hour timeframe: 10:00am to 10:59am , 11:00am to 11:59 am. then I can enter on next bar, and do a lot more elegant stop strategies... Do you know how i can write such a function that can do that?