NexusFi: Find Your Edge


Home Menu

 





Help exit a trade in easylanguage!


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one kidvic with 4 posts (1 thanks)
    2. looks_two sptrader with 2 posts (0 thanks)
    3. looks_3 ABCTG with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 3,138 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 8 posts
    2. attach_file 0 attachments




 
Search this Thread

Help exit a trade in easylanguage!

  #1 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3

If close>close[1] then buy this bar at close;
{Target & Stop Exits go here}
now, I have seen that you can have something like
setprofittarget(300)
and
setstoploss(100)
and while this will get you out when you have made 300 or lost 100, this is NOT what I want.
I want to be able to give it a price value.
For example, you enter at the close and the price you paid is 20.50, and you want to get out at 25.50
How do I tell it to get me when the last is 25.50? I do not want to tell it to get me out at 5.00 because that price target can change.

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Increase in trading performance by 75%
The Elite Circle
How to apply profiles
Traders Hideout
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
29 thanks
Tao te Trade: way of the WLD
24 thanks
Diary of a simple price action trader
21 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
10 thanks
  #3 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 701


Maybe something like this:
If marketposition = 1 then sell next bar at 25.50 limit;
I think it may only be valid only for the next bar though.

Reply With Quote
  #4 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3


sptrader View Post
Maybe something like this:
If marketposition = 1 then sell next bar at 25.50 limit;
I think it may only be valid only for the next bar though.

Thanks @sptrader
It is only for next bar. I've read the reserved word definition.
This won't work. Thanks anyway. This is frustrating .

Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

kidvic,

sptrader's suggestion will work on all bars as long as MarketPosition = 1 - the order won't get cancelled at the end of the next bar.
You can also use the build in profit target and stop loss from your first post, but instead of using fixed values you can change them according to the price you want to exit at.
Look into the reserved word SetStopShare and then you can just use the difference between your entry and exit in dollars as the value for the target.

Regards,
ABCTG


kidvic View Post
Thanks @sptrader
It is only for next bar. I've read the reserved word definition.
This won't work. Thanks anyway. This is frustrating .


Follow me on Twitter Reply With Quote
  #6 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3


ABCTG View Post
kidvic,

sptrader's suggestion will work on all bars as long as MarketPosition = 1 - the order won't get cancelled at the end of the next bar.
You can also use the build in profit target and stop loss from your first post, but instead of using fixed values you can change them according to the price you want to exit at.
Look into the reserved word SetStopShare and then you can just use the difference between your entry and exit in dollars as the value for the target.

Regards,
ABCTG

 
Code
If MarketPosition = 0 then
    Begin
    If Open > Close then 
    Begin
      Buy ("Enter long") 1 Contract This Bar At Close;
    End;
    

    If MarketPosition = 1 then 
    Begin
     
      Sell ("Exit long") 1 Contract Next Bar At Market;
    End;
end
So this is what I have. The script enters a position, but It does NOT exit my position at next bar as I have told it to do.
it should know that I have a marketposition of 1 since I can visually see an entry on the chart.
What is going on? Why isn't it getting me out?

Reply With Quote
  #7 (permalink)
 
sptrader's Avatar
 sptrader 
Colorado
 
Experience: Advanced
Platform: MultiCharts
Broker: IB & Iqfeed
Trading: ES , CL
Posts: 535 since Apr 2010
Thanks Given: 1,097
Thanks Received: 701

The way it's written, I think it will exit at the close of the next bar... if you want it to exit at the 1st tick of the next bar instead of waiting until the close, you need to use something like: IntrabarOrderGeneration = true; at the beginning of your code.
That's what it's called in Multicharts, I think there is an Easylanguage equivalent, if not the same...

Reply With Quote
  #8 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3


sptrader View Post
The way it's written, I think it will exit at the close of the next bar... if you want it to exit at the 1st tick of the next bar instead of waiting until the close, you need to use something like: IntrabarOrderGeneration = true; at the beginning of your code.
That's what it's called in Multicharts, I think there is an Easylanguage equivalent, if not the same...

When I've used this exact code on my chart on multicharts, it creates an entry, but it doesn't create an exit. It only shows the long entry. It doesn't even get me out at next bar.

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627

kidvic,

this is to be expected from the way you wrote your code. Your exit check is within the MarketPosition = 0 check, so the condition can never become true.

Regards,
ABCTG


kidvic View Post
When I've used this exact code on my chart on multicharts, it creates an entry, but it doesn't create an exit. It only shows the long entry. It doesn't even get me out at next bar.


Follow me on Twitter Reply With Quote




Last Updated on June 19, 2015


© 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