NexusFi: Find Your Edge


Home Menu

 





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


Discussion in EasyLanguage Programming

Updated
      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,886 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 7 posts
    2. attach_file 1 attachments




 
Search this Thread

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

  #1 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

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

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #3 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97



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
Thanked by:
  #4 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


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
Thanked by:
  #5 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


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
Thanked by:
  #6 (permalink)
Jeff65
Gurnee, IL
 
Posts: 46 since Apr 2010
Thanks Given: 17
Thanks Received: 97


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
  #7 (permalink)
 arjfca 
Montreal, Canada
 
Experience: Intermediate
Platform: Multicharts
Broker: Interactive Broker
Trading: Forex
Posts: 263 since Sep 2010
Thanks Given: 440
Thanks Received: 91

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

Started this thread Reply With Quote
  #8 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,463 since Jun 2009
Thanks Given: 33,237
Thanks Received: 101,661


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 the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving 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
Thanked by:




Last Updated on December 13, 2010


© 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