Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

johni

Buy and Exit

Recommended Posts

anyone has a sample code for the following?

 

buy whn stoch<30 and exit 5 bars from entry

 

if next day stoch is <30 buy another unit and exit 5 bars from entry

 

if next next day stoch is <30 buy another unit and exit 5 bars from entry

 

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry

Share this post


Link to post
Share on other sites
anyone has a sample code for the following?

 

buy whn stoch<30 and exit 5 bars from entry

 

if next day stoch is <30 buy another unit and exit 5 bars from entry

 

if next next day stoch is <30 buy another unit and exit 5 bars from entry

 

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry

 

 

Hi Johni,

 

I am no programmer but I am sure someone here could help you....Bluehorse or Umma.....come on guys, share a hand here

 

thank you

 

TW

Share this post


Link to post
Share on other sites
anyone has a sample code for the following?

 

buy whn stoch<30 and exit 5 bars from entry

 

if next day stoch is <30 buy another unit and exit 5 bars from entry

 

if next next day stoch is <30 buy another unit and exit 5 bars from entry

 

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry

 

Can't help you with actual code because you haven't specified what software it is.

 

But the problem is most likely that exit means exit the entire position - however much you have on.

 

So instead you can replace exit with sell one unit.

Share this post


Link to post
Share on other sites
anyone has a sample code for the following?

 

buy whn stoch<30 and exit 5 bars from entry

 

if next day stoch is <30 buy another unit and exit 5 bars from entry

 

if next next day stoch is <30 buy another unit and exit 5 bars from entry

 

try code them but the second and third entry all exit at the first exit altogether rather 5 bars from entry

 

Hi Johni,

 

There are lots of ways you could do this. It's late at night, and this is the first way that springs into my tired brain (might not be the best):

 

If x<30 then begin
buy "EntryA" 1 contract this bar;
countA=1;
end;

if countA=1 and countA[4]=1 and countA[5]=0 then begin
sell "EntryA" 1 contract this bar;
countA=0;
end;

If x<30 and x[1]<30 then begin
buy "EntryB" 1 contract this bar;
countB=1;
end;

if countB=1 and countB[4]=1 and countB[5]=0 then begin
sell "EntryB" 1 contract this bar;
countB=0;
end;

 

You can suss out EntryC for yourself from this. You'll also need to set up the count variables.

 

Give it a go and let me know how you get on!

 

BlueHorseshoe

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.