NexusFi: Find Your Edge


Home Menu

 





MultiCharts Autotrading question


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one larssan with 1 posts (0 thanks)
    2. looks_two Nevi with 1 posts (0 thanks)
    3. looks_3 Big Mike with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 2,706 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

MultiCharts Autotrading question

(login for full post details)
  #1 (permalink)
 larssan 
Gothenburg, Sweden
 
Experience: Advanced
Platform: MultiCharts
Broker: Gain Capital
Trading: ES
Posts: 11 since Dec 2009
Thanks Given: 1
Thanks Received: 2

Hello,

I would like to start by saying thanks for a great forum as this is my first post.
I'm a mechanical trader from Sweden using MultiCharts.
So far I have traded manually but in order to learn more about programming I was thinking of automate my systems.
Some of it I figured out but now I've run in to some problems.

When using my "Backtesting" code for automatic trading I found lot of logical errors when the orders are executed.
I'm no experienced programmer so I try here to see if anyone can help me out.

 
Code
if marketposition = 1 and shorttrade1 = false then begin
        longtrade1 = true;
        lstp1 = InitialLongStop1 ;

        
            if UseMoveToBreakEven and h >= entryprice+BreakEvenFactor
            then begin
                lstp1 = MaxList(lstp1, entryprice);
                sell ("ExitLong1BE") from Entry ("Long1") next bar at lstp1 stop;
                end;    
                
            if UseTrailing and time >= TrailingStartTime and TrailLevel > lstp1
            then begin
                lstp1 = MaxList(lstp1, TrailLevel );
                sell ("ExitLong1 TRAIL") from Entry ("Long1") next bar at TrailLevel stop;
                end;    
            
            if time >= CloseTime then
                sell ("ExitLong1 EOD") from Entry ("Long1") this bar at c;
    
            if time < NoNewPositionsTime and shorttrade1 = false then begin
                sellshort ("Short2") 1 contract next bar at SellLevel stop;
                sstp2 = InitialShortStop2;
                BuyToCover ("InitExit Short2") from Entry ("Short2") next bar at sstp2 stop;
                    
            end;
The main problem is that to many orders are sent at the same time.

The problems I found so far:

1. If MarketPosition = 1 and UseTrailing = true
(I'm long and have a initial stop&reverse in the market and also using a trailing stop)
If the trailing stop level moves one tick above the initial stop level the trailing is active.
Now I have a stop order at the trailinglevel and a stop&reverse order one tick below.
The stop&reverse order is twice as big as my current position. (flat+short)
The problem i see is that if the market moves really fast I'll be flat at the trailing level and short twice the initial position at the stop&reverse level.
When I trade this manually I put in one order at the trailing level to make me flat and one order at the stop&reverse order to make me short.
I'll attach a pic to make it easier to understand what I mean. (It shows a short position but the issue is the same)
Auto Trading:


Manual Trading:



2. If MarketPosition = 1 and UseMoveToBreakEven = true
Basically same problem.

I'll try to explain the logic I'm looking for:
- If I'm long 1 contract I want to have a stop&reverse at a specified level below the entryprice.
(Flat and Short at the same level.)

- If I'm long 1 contract and using UseTrailing and the trailing stop is above the initial stop&reverse I want to Sell 1 contract at the trailing level and 1 contract at the initial stop&reverse level.
(Flat and Short at two different levels.)

- If I'm long 1 contract and using MoveToBreakEven and the BreakEven level is above the initial stop&reverse I want to Sell 1 contract at the BreakEven level and 1 contract at the initial stop&reverse level.
(Flat and Short at two different levels.)

- If I'm long 1 contract and using MoveToBreakEven and UseTrailing I want to sell 1 contract at the highest of the two and 1 contract at the initial stop&reverse level.
(Flat and Short at two different levels.)

Hope you understand what I'm trying to describe....

If anyone can give me some ideas I'd really appreciate it.

Thanks, Lars

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Request for MACD with option to use different MAs for fa …
NinjaTrader
Trader Dale [email protected] or Scammer Dale
Trading Reviews and Vendors
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
30 thanks
Supertradersams Thread Journal on NQ/MNQ
25 thanks
Deaddogs Stock Trading
23 thanks
GFIs1 1 DAX trade per day journal
22 thanks
Daytrading ES & NQ
13 thanks

(login for full post details)
  #3 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,234 since Jun 2009
Thanks Given: 33,106
Thanks Received: 101,351


Let's take one at a time. Can you re-state item 1 again? I'm having a hard time following, although I must admit my eyes are so bad today (allergies) I can barely see the screen.

It seems like you are doing a bracket order breakout? (you mentioned reversing)?

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


For the best trading education, watch our webinars
Searching for trading reviews? Review this list


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #4 (permalink)
Nevi
phoenix az
 
Posts: 4 since Aug 2011
Thanks Given: 0
Thanks Received: 1

I don’t have multicharts, I use tradestation
Tradestation has a setting called “Wait for UR Out Confirmation” before it reverses direction.
Another setting is to only allow max 1 contracts at a time in each direction.

Without platform settings mentioned above implemented, orders as close as this could be a problem even in moderate trading conditions.

Another thing in your code is
h >= entryprice+BreakEvenFactor
If this is a trailing a long entry and the bar after entry is a very long bar, the high could pull the trail level up into the bar, stopping you out, long trailing is usually done from the low of the bar.
Nevi

Reply With Quote





Last Updated on September 8, 2011


© 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