NexusFi: Find Your Edge


Home Menu

 





sell this bar, not next bar, is that possible?


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one KhaosTrader with 40 posts (4 thanks)
    2. looks_two Nicolas11 with 27 posts (24 thanks)
    3. looks_3 Bimi with 2 posts (2 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
      Best Posters
    1. looks_one Jura with 3 thanks per post
    2. looks_two Bimi with 1 thanks per post
    3. looks_3 Nicolas11 with 0.9 thanks per post
    4. looks_4 KhaosTrader with 0.1 thanks per post
    1. trending_up 25,962 views
    2. thumb_up 33 thanks given
    3. group 3 followers
    1. forum 68 posts
    2. attach_file 16 attachments




 
Search this Thread

sell this bar, not next bar, is that possible?

  #21 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

Ok, I put the command : print ("ticksize = " + numtoStr(TickSize,2));

gives me:
ticksize = 0.01

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Trade idea based off three indicators.
Traders Hideout
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
 
  #22 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

OK.
And what is the value of StopSize?
Not the one in your code.
But the one in the inputs of the strategy in MultiCharts "Format Signal".

Visit my NexusFi Trade Journal Reply With Quote
  #23 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21


Here are the values

Started this thread Reply With Quote
  #24 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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.

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #25 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

ok i will do what you are suggesting, thanks again for your great help Nicolas

Started this thread Reply With Quote
Thanked by:
  #26 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

it looks like the stop is not getting triggered, check this out... if i expand the chart..

Started this thread Reply With Quote
  #27 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

Please post the code. Otherwise, how could we analyze?

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #28 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21

ok i hardcoded stops, and here is the code, and it should have entered in the circle area but it didnt




code:


inputs:
target1 (50),
target2(100),
target3(300),
stopsize(75),
buyCushion (.20),
BE2(0) , // 0=false, 1 = true
BE3(0); // 0=false, 1 = true

vars:
TickSize (MinMove/PriceScale),
smav (0),
emav (0),
hmav(0),
t1 (target1*TickSize),
t2 (target2*TickSize),
t3 (target3*TickSize),
st1 (1),
st2 (1),
st3 (1),
buyTrigger(0);


[IntrabarOrderGeneration = true]


// open new positions


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;




end;





// manage open orders

if MarketPosition = 1 then begin


st1 = EntryPrice - (stopsize * TickSize);
st2 = iff(BE2 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));
st3 = iff(BE3 = 1, EntryPrice, EntryPrice-(stopsize * TickSize));

//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;

end;

if MarketPosition = -1 then begin

st1 = EntryPrice + (stopsize * TickSize);
st2 = iff(BE2 = 1, EntryPrice, EntryPrice+(stopsize * TickSize));
st3 = iff(BE3 = 1, EntryPrice, EntryPrice+(stopsize * TickSize));

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;


end;

Started this thread Reply With Quote
  #29 (permalink)
 
Nicolas11's Avatar
 Nicolas11 
near Paris, France
 
Experience: Beginner
Platform: -
Trading: -
Posts: 1,071 since Aug 2011
Thanks Given: 2,232
Thanks Received: 1,769

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?
 
Code
print(Date:8:0," ", Time:4:0, " --> CurrentShares = ", CurrentShares);
2. delete "and BarStatus(1) = 2"

Any improvement?

Nicolas

Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #30 (permalink)
 KhaosTrader 
San Jose
 
Experience: Intermediate
Platform: NinjaTrader, Esignal
Trading: Stocks
Posts: 107 since Jan 2012
Thanks Given: 40
Thanks Received: 21


Nicolas,

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?

Thanks,

Jeff

Started this thread Reply With Quote




Last Updated on August 22, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts