Rooky questionning, Coding a conditionnal entry + a stop loss if done - futures io
futures io futures trading



Rooky questionning, Coding a conditionnal entry + a stop loss if done


Discussion in EasyLanguage Programming

Updated by Big Mike
      Top Posters
    1. looks_one Jeff65 with 4 posts (4 thanks)
    2. looks_two arjfca with 2 posts (0 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 Big Mike with 1 posts (1 thanks)
    1. trending_up 2,381 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 7 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Rooky questionning, Coding a conditionnal entry + a stop loss if done

(login for full post details)
  #1 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received

Hello

I'm trying to code my first signal using Multicharts and their is some concept that I dont understand very well.

My broker is IB and orders should reside on their servers

Interogation 1:
Let say I want to send an order like

1- Conditionnal entry: Buy next bar 100 000 @ 1.3978 stop
2- If #1 is done Conditionnal stop loss sell 100 000 @ 1.3968 stop

How will I code it? I would like both orders to be put on IB server at the same time. The 2' orders is conditionnal to the #1 order be executed.

Interogation2:
If the order # 1 is not executed by the end of the bar, do I need to cancel it? or, Cancel both?

Interogation3:
Entry as been done and stop loss as not been reached. In profit and i would like to protect some profit. How do I modify the stop loss price value?, meaning modifying the #2 order

Interogation4:
How do I select the synchronisation mode. I read that this mode will validate each entry to insure a synchronisation between calculated positions and positions on broker server.

Any help greatly appreciated.

Martin

Reply With Quote

Can you help answer these questions
from other members on futures io?
Stacked Imbalances.
Sierra Chart
Help tracking down catalysts for the ES
Traders Hideout
Help with NQU0 footprint charts during 3 stop-runs
Emini and Emicro Index
help to convert from thinkscript to ninjascript
NinjaTrader
Metastock Xenith Adapter
NinjaTrader
 
 
(login for full post details)
  #3 (permalink)
Gurnee, IL
 
 
Posts: 46 since Apr 2010
Thanks: 17 given, 95 received



arjfca View Post
Interogation 1:
Let say I want to send an order like

1- Conditionnal entry: Buy next bar 100 000 @ 1.3978 stop
2- If #1 is done Conditionnal stop loss sell 100 000 @ 1.3968 stop

How will I code it? I would like both orders to be put on IB server at the same time. The 2' orders is conditionnal to the #1 order be executed.

Both orders are on the sever during the trigger bar. Both are conditional to your "conditional" entry. The code example below might help. I'll try to get to your other questions later today.

 
Code
//1- Conditionnal entry: Buy next bar 100 000 @ 1.3978 stop
//2- If #1 is done Conditionnal stop loss sell 100 000 @ 1.3968 stop
input:
iContracts( 10 ),
iEntryPrice( 1.3978),
iStopInTicks( 10 );

Variables:
MP(0),
Condition(true);

MP = MarketPosition;

If ( Condition = True ) Then
Begin
   If ( MP = 0 ) Then buy iContracts contracts next bar at iEntryPrice stop;
   SetStopLoss( iStopInTicks * iContracts * BigPointValue );
End

Reply With Quote
The following user says Thank You to Jeff65 for this post:
 
(login for full post details)
  #4 (permalink)
Gurnee, IL
 
 
Posts: 46 since Apr 2010
Thanks: 17 given, 95 received


arjfca View Post


Interogation2:
If the order # 1 is not executed by the end of the bar, do I need to cancel it? or, Cancel both?



No need to cancel either order.

Reply With Quote
The following user says Thank You to Jeff65 for this post:
 
(login for full post details)
  #5 (permalink)
Gurnee, IL
 
 
Posts: 46 since Apr 2010
Thanks: 17 given, 95 received


arjfca View Post
Interogation3:
Entry as been done and stop loss as not been reached. In profit and i would like to protect some profit. How do I modify the stop loss price value?, meaning modifying the #2 order

You don't need to modify the original stop lost created by SetStopLoss. You can simply create a new stop loss that trails your profitable trade. Here are two ways.

 
Code
input:
iContracts( 10 ),
iEntryPrice( 1.3978),
iStopInTicks( 10 );

Variables:
NewStopPrice(0),
Stop$(0),
MP(0),
Condition(true);

MP = MarketPosition;
Stop$ =  iStopInTicks * iContracts * BigPointValue;

If ( Condition = True ) Then
Begin

   If ( MP = 0 ) Then buy iContracts contracts next bar at iEntryPrice stop;
   
   // This sets a hard stop that is active on the very bar you enter.
   SetStopLoss( Stop$ );
   
End;

// Create dollar trailing stop that follows trade as you make profit. 
SetDollarTrailing( Stop$ );

// ...OR Simply place a stop order at a specific price as profit climbs

If ( OpenPositionProfit > 100 ) Then
Begin
   NewStopPrice = 1.3985; // set your new stop price after profit
   Sell next bar at NewStopPrice stop;
End;

Reply With Quote
The following 2 users say Thank You to Jeff65 for this post:
 
(login for full post details)
  #6 (permalink)
Gurnee, IL
 
 
Posts: 46 since Apr 2010
Thanks: 17 given, 95 received


arjfca View Post
Interogation4:
How do I select the synchronisation mode. I read that this mode will validate each entry to insure a synchronisation between calculated positions and positions on broker server.

Sorry, not familiar with this one.

Reply With Quote
 
(login for full post details)
  #7 (permalink)
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
 
Posts: 263 since Sep 2010
Thanks: 440 given, 91 received

Thanks many time Jeff. I did have a much better undertanding of the subject


HTML Code:
You don't need to modify the original stop lost created by SetStopLoss.
You can simply create a new stop loss that trails your profitable trade. Here are two ways.
My understanding. All stop is control via your PC. All you need is install new value and software will take care of it.


Have a great day and Happy trading time for the new year to come.

Martin

Reply With Quote
 
(login for full post details)
  #8 (permalink)
Site Administrator
Manta, Ecuador
 
Experience: Advanced
Platform: My own custom solution
Trading: Emini Futures
 
Big Mike's Avatar
 
Posts: 49,051 since Jun 2009
Thanks: 31,658 given, 94,926 received


arjfca View Post
Interogation4:
How do I select the synchronisation mode. I read that this mode will validate each entry to insure a synchronisation between calculated positions and positions on broker server.

When adding the signal to your chart, go to Format Signals, then Properties, then Auto Trading tab.



Mike

We're here to help -- just ask

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

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/
Follow me on Twitter Visit my Facebook Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Rooky questionning, Coding a conditionnal entry + a stop loss if done


December 13, 2010


Upcoming Webinars and Events
     



Copyright © 2020 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