Finding Max Open Profit - EasyLanguage Programming | futures io social day trading
futures io futures trading


Finding Max Open Profit
Updated: Views / Replies:2,717 / 10
Created: by Turbosteve Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Finding Max Open Profit

  #1 (permalink)
Elite Member
Sydney Nsw Australia
 
Futures Experience: Intermediate
Platform: Amibroker, Multicharts
Broker/Data: I.B, CQG
Favorite Futures: NQ, 6E, SPI
 
Posts: 18 since Jun 2012
Thanks: 50 given, 8 received

Finding Max Open Profit

Hi All

Im trying to plot a trailing stop on my chart of the current open trade. I need to find the Max profit that was achieved with the aim of closing the trade when 50% of the open profit is lost. I have tried OpenEntryMaxProfitPerContract and MaxContractProfit but its not getting the result I hope for. It appears to be using the second last bar, not the last bar to work out the Max Profit (I think).

Heres some code I have been playing with;


if LastBarOnChart then
begin

nMaxProfit = OpenEntryMaxProfitPerContract(0); // current position max profit
nTL_TrailStop = nMaxProfit * ( nTrailPercStop_i/100 ); // default 45%
nTrail = ( entryprice(0) + nTL_TrailStop );
nTL_St_Date = currentdate ;
nTrailingStopLine = tl_new(nTL_St_Date -1 ,0100, nTrail, nTL_St_Date,2300, nTrail);
tl_setsize( nTrailingStopLine , 3);
tl_setcolor( nTrailingStopLine , green);

end;

Theres probably an easy solution which doesnt involve Highest High or something like like.

Stephen

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Sydney Nsw Australia
 
Futures Experience: Intermediate
Platform: Amibroker, Multicharts
Broker/Data: I.B, CQG
Favorite Futures: NQ, 6E, SPI
 
Posts: 18 since Jun 2012
Thanks: 50 given, 8 received


I think LastBarOnChart is actually triggered for the second last bar?

This could be causing the last bar not to be evaluated?

Reply With Quote
 
  #4 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 661 received


Turbosteve View Post
I think LastBarOnChart is actually triggered for the second last bar?

This could be causing the last bar not to be evaluated?

If you have bars with minute time stamps (HHmm, for example 8:09 am) then LastBarOnChart is triggered on the last bar. However, if you have bars with seconds time stamps (HHmmss, 8:09:34 am), then LastBarOnChart_s should be used.

Btw, just always use LastBarOnChart_s since that also works correctly with minute bars.

Btw 2, if you intend to backtest this code, it might be advisable to use MarketPosition instead of LastBarOnChart_s. Something like this:

 
Code
if (MarketPosition(0) <> 0) then begin 

	nMaxProfit = OpenEntryMaxProfitPerContract(0); // current position max profit
	// other code here

end;

Reply With Quote
The following user says Thank You to Jura for this post:
 
  #5 (permalink)
Elite Member
Sydney Nsw Australia
 
Futures Experience: Intermediate
Platform: Amibroker, Multicharts
Broker/Data: I.B, CQG
Favorite Futures: NQ, 6E, SPI
 
Posts: 18 since Jun 2012
Thanks: 50 given, 8 received

Im now very sure that it is evaluating the second last bar not the last.

Any Idea's how to evaluate the Last bar as well. Its in a Signal not indicator.

Reply With Quote
 
  #6 (permalink)
Elite Member
Sydney Nsw Australia
 
Futures Experience: Intermediate
Platform: Amibroker, Multicharts
Broker/Data: I.B, CQG
Favorite Futures: NQ, 6E, SPI
 
Posts: 18 since Jun 2012
Thanks: 50 given, 8 received

Thanks Jura

Im using the code in a Signal and test MarketPosition(0) = 1.

I think the problem is Im using it on Daily Bars only. I dont have access to intra day data as Im still evaluating Multicharts (for the last 2 weeks). I will be backtesting on intra day data once I buy Multicharts.

Perhaps this problem I am coming up with is a limitation which is exposed only on Daily Data. On an intra day Signal test I would be using 5min and 1hr charts and then the issue is not such a big deal.

Your thoughts?

P.S I have been reading some of your replies last night. Your obviously a very good programmer.

Reply With Quote
The following user says Thank You to Turbosteve for this post:
 
  #7 (permalink)
 Vendor: tradingcode.net 
The Netherlands
 
Futures Experience: None
Platform: MultiCharts, TradingView
Favorite Futures: ...
 
Jura's Avatar
 
Posts: 774 since Apr 2010
Thanks: 2,347 given, 661 received


Turbosteve View Post
I think the problem is Im using it on Daily Bars only.

That's possible; I've also experienced problems with the last daily bar not being evaluated by the code. It turned out that I had the wrong session template with an instrument with a exchange time zone that was different from mine.

You can change the session template by double-clicking on the instrument, tab Settings, and then Sessions.

Btw, you can easily test if the code processes all bars (including the last) with:
 
Code
Print("Bar date time: ", FormatDate("dd-MM-yyyy", ELDateToDateTime(Date)), FormatTime(" HH:mm:ss", ELTimeToDateTime_s(Time_s)));
The information in the PowerLanguage Editor output log will then show for the last bar the same date time as on the chart. If that's not the case, you may need to change your session settings.

Reply With Quote
The following user says Thank You to Jura for this post:
 
  #8 (permalink)
Elite Member
Newcastle, Australia
 
Futures Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker/Data: IB
Favorite Futures: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 177 received

Why can't you just use the current bars high price - entry price.


Sent from my GT-I9100T using Tapatalk 2

Reply With Quote
 
  #9 (permalink)
Elite Member
Sydney Nsw Australia
 
Futures Experience: Intermediate
Platform: Amibroker, Multicharts
Broker/Data: I.B, CQG
Favorite Futures: NQ, 6E, SPI
 
Posts: 18 since Jun 2012
Thanks: 50 given, 8 received

Jura

The last bar Date printed was the second last bar Date not the last bar Date (today). Changing session template or timezone didnt help either. Im from Australia and testing on the XJO daily data. Thanks for the help though.

Hi NW27

High will give you the high of the second last bar in a Signal. Obviously in an Indicator it will give you the last bar.

I tried this a few hours ago;

nMaxProfit = Highest(high[0], barsSinceEntry) - entryprice(0);

Again its looking at the second last bar even though the Last bar (today) is higher.

I think its how the Multicharts backtesting engine works. It will give the correct signal on the next bar as it assumes you cant give a signal until the bar is closed AND the next bar is opened. Like setting a buy / sell on next bar. eg sell ("Above 3 Week 50% Stop") next bar at (MyWeekly50 - 10) Stop;

BTW NW27. I have been reading this forum for a few weeks and notice you trade SPI. I want to get historical SPI data and a live data feed. Any hints? ( I have been using IG Markets for a few years but want to backtest and auto execute).

Reply With Quote
 
  #10 (permalink)
Elite Member
Newcastle, Australia
 
Futures Experience: Intermediate
Platform: Multicharts 8 - Full Version
Broker/Data: IB
Favorite Futures: SPI,FTSE100, 6E, 6A
 
Posts: 285 since Oct 2010
Thanks: 108 given, 177 received


Steve
For a quick fix of SPI data, goto Ampfutures and get a demo multicharts user account.

Neil

Sent from my GT-I9100T using Tapatalk 2

Reply With Quote
The following 2 users say Thank You to NW27 for this post:

Reply



futures io > > > > > Finding Max Open Profit

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding (ZSharkTrendStochChop2) blkreign69 Traders Hideout 4 December 10th, 2011 04:53 AM
Max number of open positios andy335 NinjaTrader Programming 2 November 17th, 2011 11:45 AM
Volitility indicator question - Open - Open / open - close / close to open andresimon NinjaTrader 2 September 27th, 2010 01:33 AM
Finding your edge! George Psychology and Money Management 2 September 22nd, 2010 07:49 PM
Finding Music websouth Off-Topic 6 November 29th, 2009 05:22 PM


All times are GMT -4. The time now is 03:05 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.16 seconds with 19 queries on phoenix via your IP 54.145.16.43